aboutsummaryrefslogtreecommitdiffstats
path: root/modules/by-name
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--modules/by-name/im/impermanence/module.nix50
1 files changed, 42 insertions, 8 deletions
diff --git a/modules/by-name/im/impermanence/module.nix b/modules/by-name/im/impermanence/module.nix
index 1c916e2..0fbd742 100644
--- a/modules/by-name/im/impermanence/module.nix
+++ b/modules/by-name/im/impermanence/module.nix
@@ -1,27 +1,61 @@
{
config,
lib,
+ modules,
...
}: let
cfg = config.vhack.persist;
+
+ userDirectories = lib.debug.traceValSeqN 2 (lib.mapAttrs (_: dirs: {
+ directories =
+ dirs;
+ })
+ cfg.userDirectories);
in {
options.vhack.persist = {
- enable = lib.mkEnableOption "impermanence";
+ enable = lib.mkEnableOption "persisting directories and files with 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));
+ type = lib.types.listOf (lib.types.either lib.types.str (lib.types.submodule {
+ options = {
+ directory = lib.mkOption {
+ type = lib.types.str;
+ };
+ mode = lib.mkOption {
+ type = lib.types.str;
+ };
+ };
+ }));
+ description = "The directories to persist";
+ };
+
+ userDirectories = lib.mkOption {
+ type = lib.attrsOf lib.types.listOf (lib.types.either lib.types.str (lib.types.submodule {
+ options = {
+ directory = lib.mkOption {
+ type = lib.types.str;
+ };
+ mode = lib.mkOption {
+ type = lib.types.str;
+ };
+ };
+ }));
+ default = [];
+ description = "The directories to persist, for each user.";
};
};
+ imports = [
+ modules.impermanence.nixosModules.impermanence
+ ];
+
config = lib.mkIf cfg.enable {
environment.persistence."/srv" = {
hideMounts = true;
- directories =
- [
- "/etc/nixos"
- ]
- ++ cfg.directories;
+ inherit (cfg) directories;
+
+ users = userDirectories;
+
files = [
"/etc/machine-id"
];