summary refs log tree commit diff
path: root/profiles/impermanence.nix
diff options
context:
space:
mode:
Diffstat (limited to 'profiles/impermanence.nix')
-rw-r--r--profiles/impermanence.nix29
1 files changed, 29 insertions, 0 deletions
diff --git a/profiles/impermanence.nix b/profiles/impermanence.nix
new file mode 100644
index 0000000..5ee9c97
--- /dev/null
+++ b/profiles/impermanence.nix
@@ -0,0 +1,29 @@
+{inputs, ...}: {
+  config,
+  lib,
+  options,
+  ...
+}: let
+  sshHostKeys = builtins.catAttrs "path" config.services.openssh.hostKeys;
+in {
+  imports = [inputs.impermanence.nixosModules.impermanence];
+
+  config = lib.mkMerge [
+    {
+      environment.persistence."/nix/persistent" = {
+        hideMounts = true;
+        directories = [
+          "/var/log"
+          "/var/lib/systemd/coredump"
+          "/tmp" # Make builds not crash by running them on disk instead of RAM (We still clean /tmp on boot)
+        ];
+        files =
+          [
+            "/etc/machine-id"
+          ]
+          ++ sshHostKeys;
+      };
+    }
+    (lib.optionalAttrs (options ? age) {age.identityPaths = map (x: "/nix/persistent" + x) sshHostKeys;})
+  ];
+}