about summary refs log tree commit diff
diff options
context:
space:
mode:
authorsefidel <contact@sefidel.net>2024-02-03 04:11:52 +0900
committersefidel <contact@sefidel.net>2024-02-03 04:11:52 +0900
commitceca24e64a2d0aa452d6b0fe702eab303d6a83e6 (patch)
treeb07596aebf38d5512161df47a74f2baba0ed5233
parent5854407ab4aba08fdae5c4e74ad12fb98090be10 (diff)
downloadnixrc-ceca24e64a2d0aa452d6b0fe702eab303d6a83e6.tar.gz
nixrc-ceca24e64a2d0aa452d6b0fe702eab303d6a83e6.zip
feat(modules): add persistence
-rw-r--r--modules/persistence.nix43
1 files changed, 43 insertions, 0 deletions
diff --git a/modules/persistence.nix b/modules/persistence.nix
new file mode 100644
index 0000000..3131d61
--- /dev/null
+++ b/modules/persistence.nix
@@ -0,0 +1,43 @@
+{ config, lib, ... }:
+
+
+with lib;
+let
+  cfg = config.modules.persistence;
+in
+{
+  options.modules.persistence = {
+    enable = mkEnableOption "impermanence persistence";
+
+    storagePath = lib.mkOption {
+      type = types.path;
+      description = ''
+        The path to persistent storage where the real
+        files and directories should be stored.
+      '';
+    };
+
+    directories = mkOption {
+      type = types.listOf types.str;
+      default = [ ];
+    };
+  };
+
+  config = mkIf cfg.enable {
+    fileSystems.${cfg.storagePath}.neededForBoot = true;
+
+    environment.persistence.${cfg.storagePath}.directories = cfg.directories;
+
+    services.openssh.hostKeys = [
+      {
+        path = "${cfg.storagePath}/ssh/ssh_host_ed25519_key";
+        type = "ed25519";
+      }
+      {
+        path = "${cfg.storagePath}/ssh/ssh_host_rsa_key";
+        type = "rsa";
+        bits = 4096;
+      }
+    ];
+  };
+}