diff --git a/flake.lock b/flake.lock index c3400fe..51f6ee8 100644 --- a/flake.lock +++ b/flake.lock @@ -211,6 +211,21 @@ "type": "github" } }, + "impermanence": { + "locked": { + "lastModified": 1737831083, + "narHash": "sha256-LJggUHbpyeDvNagTUrdhe/pRVp4pnS6wVKALS782gRI=", + "owner": "nix-community", + "repo": "impermanence", + "rev": "4b3e914cdf97a5b536a889e939fb2fd2b043a170", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "impermanence", + "type": "github" + } + }, "mnw": { "locked": { "lastModified": 1756659871, @@ -644,6 +659,7 @@ "disko": "disko", "hardware": "hardware", "home-manager": "home-manager", + "impermanence": "impermanence", "niri-flake": "niri-flake", "nix-darwin": "nix-darwin", "nix-secrets": "nix-secrets", diff --git a/flake.nix b/flake.nix index 5a9e543..b10cf6e 100644 --- a/flake.nix +++ b/flake.nix @@ -96,6 +96,7 @@ url = "github:nix-community/home-manager/release-25.05"; inputs.nixpkgs.follows = "nixpkgs"; }; + impermanence.url = "github:nix-community/impermanence"; # 3rd party inputs disko = { diff --git a/hosts/common/core/default.nix b/hosts/common/core/default.nix index 8d5fa96..d86c0b7 100644 --- a/hosts/common/core/default.nix +++ b/hosts/common/core/default.nix @@ -18,6 +18,7 @@ in { imports = lib.flatten [ inputs.home-manager.${platformModules}.home-manager inputs.sops-nix.${platformModules}.sops + inputs.impermanence.${platformModules}.impermanence (map lib.custom.relativeToRoot [ "hosts/common/core/${platform}.nix" diff --git a/hosts/common/core/impermanence.nix b/hosts/common/core/impermanence.nix new file mode 100644 index 0000000..a7e8d4b --- /dev/null +++ b/hosts/common/core/impermanence.nix @@ -0,0 +1,50 @@ +{ + lib, + config, + ... +}: +lib.mkIf config.hostSpec.isImpermanent { + environment.persistence.${config.hostSpec.persistFolder} = { + enable = true; + directories = [ + "/var/log" + "/var/lib/bluetooth" + "/var/lib/nixos" + "/var/lib/systemd/coredump" + "/etc/NetworkManager/system-connections" + ]; + files = [ + "/etc/machine-id" + ]; + users.${config.hostSpec.username} = { + directories = [ + "Downloads" + "Music" + "Pictures" + "Documents" + "Videos" + "VirtualBox VMs" + { + directory = ".gnupg"; + mode = "0700"; + } + { + directory = ".ssh"; + mode = "0700"; + } + { + directory = ".nixops"; + mode = "0700"; + } + { + directory = ".local/share/keyrings"; + mode = "0700"; + } + ".local/share/direnv" + ]; + files = [ + ".screenrc" + ]; + }; + }; +} diff --git a/hosts/nixos/Incarceron/default.nix b/hosts/nixos/Incarceron/default.nix index 3999a26..0cbaffa 100644 --- a/hosts/nixos/Incarceron/default.nix +++ b/hosts/nixos/Incarceron/default.nix @@ -48,6 +48,7 @@ hostSpec = { hostName = "Incarceron"; + isImpermanent = true; persistFolder = "/persist"; };