forked from jan-leila/nix-config
		
	feat: refactored impermanence to be enableable for users on a system
This commit is contained in:
		
							parent
							
								
									337f03b4e7
								
							
						
					
					
						commit
						6d5a07e08f
					
				
					 31 changed files with 61 additions and 56 deletions
				
			
		|  | @ -1,10 +1,9 @@ | |||
| { | ||||
|   lib, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   config = lib.mkIf osConfig.host.impermanence.enable { | ||||
|   config = lib.mkIf (config.impermanence.enable) { | ||||
|     home.persistence."/persist/home/leyla" = { | ||||
|       directories = [ | ||||
|         "desktop" | ||||
|  |  | |||
|  | @ -5,6 +5,7 @@ | |||
|     ./user.nix | ||||
|     ./flipperzero.nix | ||||
|     ./i18n.nix | ||||
|     ./impermanence.nix | ||||
|     ./openssh.nix | ||||
|     ./gnome.nix | ||||
|     ./programs | ||||
|  |  | |||
							
								
								
									
										31
									
								
								modules/home-manager-modules/impermanence.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								modules/home-manager-modules/impermanence.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,31 @@ | |||
| { | ||||
|   config, | ||||
|   lib, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: let | ||||
|   cfg = config.impermanence; | ||||
| in { | ||||
|   options.impermanence = { | ||||
|     enable = lib.mkEnableOption "impermanence for home directory"; | ||||
|   }; | ||||
| 
 | ||||
|   config = lib.mkMerge [ | ||||
|     (lib.mkIf config.impermanence.enable { | ||||
|       assertions = [ | ||||
|         { | ||||
|           assertion = osConfig.impermanence.enable; | ||||
|           message = "impermanence can not be enabled for a user when it is not enabled for a configuration"; | ||||
|         } | ||||
|       ]; | ||||
|     }) | ||||
|     (lib.mkIf osConfig.host.impermanence.enable { | ||||
|       # If impermanence is not enabled for this user but system impermanence is enabled, | ||||
|       # persist the entire home directory as fallback | ||||
|       home.persistence."/persist/home/${config.home.username}" = lib.mkIf (!cfg.enable) { | ||||
|         directories = ["."]; | ||||
|         allowOther = true; | ||||
|       }; | ||||
|     }) | ||||
|   ]; | ||||
| } | ||||
|  | @ -95,7 +95,7 @@ | |||
|           ); | ||||
|         } | ||||
|       ) | ||||
|       (lib.mkIf osConfig.host.impermanence.enable { | ||||
|       (lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           files = lib.lists.flatten ( | ||||
|             builtins.map (hostKey: [".ssh/${hostKey.path}" ".ssh/${hostKey.path}.pub"]) config.programs.openssh.hostKeys | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.bitwarden = { | ||||
|  | @ -16,7 +15,7 @@ | |||
|       ]; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             "${config.xdg.configHome}/Bitwarden" | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.bruno = { | ||||
|  | @ -16,7 +15,7 @@ | |||
|       ]; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             "${config.xdg.configHome}/bruno/" | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.calibre = { | ||||
|  | @ -16,7 +15,7 @@ | |||
|       ]; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             "${config.xdg.configHome}/calibre" | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.davinci-resolve = { | ||||
|  | @ -16,7 +15,7 @@ | |||
|       ]; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             "${config.xdg.dataHome}/DaVinciResolve" | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.dbeaver-bin = { | ||||
|  | @ -16,7 +15,7 @@ | |||
|       ]; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             "${config.xdg.dataHome}/DBeaverData/" | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.discord = { | ||||
|  | @ -16,7 +15,7 @@ | |||
|       ]; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             "${config.xdg.configHome}/discord/" | ||||
|  |  | |||
|  | @ -1,7 +1,6 @@ | |||
| { | ||||
|   lib, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: let | ||||
|   buildProfilePersistence = profile: { | ||||
|  | @ -26,7 +25,7 @@ | |||
|     allowOther = true; | ||||
|   }; | ||||
| in { | ||||
|   config = lib.mkIf (config.programs.firefox.enable && osConfig.host.impermanence.enable) { | ||||
|   config = lib.mkIf (config.programs.firefox.enable && config.impermanence.enable) { | ||||
|     home.persistence."/persist${config.home.homeDirectory}" = lib.mkMerge ( | ||||
|       ( | ||||
|         lib.attrsets.mapAttrsToList | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.freecad = { | ||||
|  | @ -16,7 +15,7 @@ | |||
|       ]; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             "${config.xdg.configHome}/FreeCAD" | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.gimp = { | ||||
|  | @ -16,7 +15,7 @@ | |||
|       ]; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             "${config.xdg.configHome}/GIMP" | ||||
|  |  | |||
|  | @ -16,7 +16,7 @@ | |||
|       ]; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             # configuration | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.inkscape = { | ||||
|  | @ -16,7 +15,7 @@ | |||
|       ]; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             "${config.xdg.configHome}/inkscape" | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.krita = { | ||||
|  | @ -16,7 +15,7 @@ | |||
|       ]; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             "${config.xdg.configHome}/kritarc" | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.libreoffice = { | ||||
|  | @ -16,7 +15,7 @@ | |||
|       ]; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             "${config.xdg.configHome}/libreoffice" | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.makemkv = { | ||||
|  | @ -30,7 +29,7 @@ | |||
|       home.file.".MakeMKV/settings.conf".source = config.lib.file.mkOutOfStoreSymlink config.sops.templates."MakeMKV.settings.conf".path; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             ".MakeMKV" | ||||
|  |  | |||
|  | @ -1,12 +1,11 @@ | |||
| { | ||||
|   lib, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   config = lib.mkIf config.programs.obs-studio.enable (lib.mkMerge [ | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         # TODO: map impermanence for obs | ||||
|       } | ||||
|     ) | ||||
|  |  | |||
|  | @ -1,12 +1,11 @@ | |||
| { | ||||
|   lib, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   config = lib.mkIf config.programs.obsidian.enable (lib.mkMerge [ | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             "${config.xdg.configHome}/obsidian" | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.picard = { | ||||
|  | @ -16,7 +15,7 @@ | |||
|       ]; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             "${config.xdg.configHome}/MusicBrainz" | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.polycule = { | ||||
|  | @ -17,7 +16,7 @@ | |||
|       ]; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           # TODO: check that these are actually the correct folders | ||||
|           # directories = [ | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.prostudiomasters = { | ||||
|  | @ -16,7 +15,7 @@ | |||
|       ]; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             "${config.xdg.configHome}/ProStudioMasters" | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.protonvpn-gui = { | ||||
|  | @ -16,7 +15,7 @@ | |||
|       ]; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             "${config.xdg.configHome}/protonvpn" | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.qbittorrent = { | ||||
|  | @ -16,7 +15,7 @@ | |||
|       ]; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             "${config.xdg.configHome}/qBittorrent" | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.qflipper = { | ||||
|  | @ -16,7 +15,7 @@ | |||
|       ]; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             "${config.xdg.configHome}/qFlipper" | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.signal-desktop-bin = { | ||||
|  | @ -16,7 +15,7 @@ | |||
|       ]; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             "${config.xdg.configHome}/Signal" | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.steam = { | ||||
|  | @ -18,7 +17,7 @@ | |||
|         ]; | ||||
|       } | ||||
|       ( | ||||
|         lib.mkIf osConfig.host.impermanence.enable { | ||||
|         lib.mkIf config.impermanence.enable { | ||||
|           home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|             directories = [ | ||||
|               { | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.tor-browser = { | ||||
|  | @ -16,7 +15,7 @@ | |||
|       ]; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             "${config.xdg.dataHome}/torbrowser" | ||||
|  |  | |||
|  | @ -2,7 +2,6 @@ | |||
|   lib, | ||||
|   pkgs, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   options.programs.ungoogled-chromium = { | ||||
|  | @ -16,7 +15,7 @@ | |||
|       ]; | ||||
|     } | ||||
|     ( | ||||
|       lib.mkIf osConfig.host.impermanence.enable { | ||||
|       lib.mkIf config.impermanence.enable { | ||||
|         home.persistence."/persist${config.home.homeDirectory}" = { | ||||
|           directories = [ | ||||
|             "${config.xdg.configHome}/chromium" | ||||
|  |  | |||
|  | @ -1,10 +1,9 @@ | |||
| { | ||||
|   lib, | ||||
|   config, | ||||
|   osConfig, | ||||
|   ... | ||||
| }: { | ||||
|   config = lib.mkIf (config.services.panoramax.enable && osConfig.host.impermanence.enable) { | ||||
|   config = lib.mkIf (config.services.panoramax.enable && config.host.impermanence.enable) { | ||||
|     # TODO: configure impermanence for panoramax data | ||||
|     # This would typically include directories like: | ||||
|     # - /var/lib/panoramax | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue