summary refs log tree commit diff stats
path: root/modules/by-name/im/impermanence/module.nix
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-12-24 16:09:20 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-12-24 16:09:20 +0100
commitb5fc07416652a445f15946ce7e5fc48766cf6722 (patch)
treede37587f0673e4aea12bc0532ee1b3879ab1e31c /modules/by-name/im/impermanence/module.nix
parentfix(modules/back): Set now needed source code URL environment variable (diff)
downloadnixos-server-b5fc07416652a445f15946ce7e5fc48766cf6722.tar.gz
nixos-server-b5fc07416652a445f15946ce7e5fc48766cf6722.zip
refactor(modules/impermanence): Migrate to by-name while distributing mods
Diffstat (limited to 'modules/by-name/im/impermanence/module.nix')
-rw-r--r--modules/by-name/im/impermanence/module.nix35
1 files changed, 35 insertions, 0 deletions
diff --git a/modules/by-name/im/impermanence/module.nix b/modules/by-name/im/impermanence/module.nix
new file mode 100644
index 0000000..d645bcb
--- /dev/null
+++ b/modules/by-name/im/impermanence/module.nix
@@ -0,0 +1,35 @@
+{
+  config,
+  lib,
+  ...
+}: let
+  cfg = config.vhack.persist;
+in {
+  options.vhack.persist = {
+    enable = lib.mkEnableOption "impermanence";
+
+    directories = lib.mkOption {
+      description = "The list of directories to persist";
+      type = lib.types.listOf (lib.types.coercedTo lib.types.str (d: {directory = d;}) (lib.types.attrsOf lib.types.anything));
+    };
+  };
+
+  config = lib.mkIf cfg.enable {
+    environment.persistence."/srv" = {
+      hideMounts = true;
+      directories =
+        [
+          "/etc/nixos"
+          "/var/log"
+
+          # TODO(@bpeetz): Instead of persisting that, encode each uid/gid directly in the
+          # config. <2024-12-24>
+          "/var/lib/nixos"
+        ]
+        ++ cfg.directories;
+      files = [
+        "/etc/machine-id"
+      ];
+    };
+  };
+}