about summary refs log tree commit diff
path: root/modules/common/ark.nix
diff options
context:
space:
mode:
authorAzat Bahawi <azat@bahawi.net>2024-04-21 02:15:42 +0300
committerAzat Bahawi <azat@bahawi.net>2024-04-21 02:15:42 +0300
commite6ed60548397627bf10f561f9438201dbba0a36e (patch)
treef9a84c5957d2cc4fcd148065ee9365a0c851ae1c /modules/common/ark.nix
parent2024-04-18 (diff)
2024-04-21
Diffstat (limited to 'modules/common/ark.nix')
-rw-r--r--modules/common/ark.nix64
1 files changed, 64 insertions, 0 deletions
diff --git a/modules/common/ark.nix b/modules/common/ark.nix
new file mode 100644
index 0000000..84ff6db
--- /dev/null
+++ b/modules/common/ark.nix
@@ -0,0 +1,64 @@
+{
+  config,
+  inputs,
+  lib,
+  ...
+}:
+with lib;
+let
+  cfg = config.nixfiles.modules.ark;
+in
+{
+  imports = [
+    inputs.impermanence.nixosModules.impermanence
+    (mkAliasOptionModule [ "ark" ] [
+      "nixfiles"
+      "modules"
+      "ark"
+    ])
+  ];
+
+  options.nixfiles.modules.ark =
+    let
+      mkListOfAnythingOption = mkOption {
+        type = with types; listOf anything; # Assumed to be matching with the upstream type.
+        default = [ ];
+      };
+    in
+    {
+      enable = mkEnableOption "persistent storage support via impermanence";
+
+      path = mkOption {
+        type = types.str;
+        default = "/ark";
+      };
+
+      directories = mkListOfAnythingOption;
+      files = mkListOfAnythingOption;
+      # hm = {
+      #   directories = mkListOfAnythingOption;
+      #   files = mkListOfAnythingOption;
+      # };
+    };
+
+  config = mkIf cfg.enable {
+    environment.persistence.${cfg.path} = {
+      hideMounts = true;
+      enableDebugging = false;
+      inherit (cfg) directories files;
+    };
+
+    # NOTE We can't reliably[1] use this, so for the time being, this will stay
+    # commented out. Probably forever.
+    #
+    # [1]: https://github.com/nix-community/impermanence/issues/18
+    #
+    # hm = {
+    #   imports = [inputs.impermanence.nixosModules.home-manager.impermanence];
+    #   home.persistence."${cfg.path}/${config.my.home}" = {
+    #     allowOther = false;
+    #     inherit (cfg.hm) directories files;
+    #   };
+    # };
+  };
+}

Consider giving Nix/NixOS a try! <3