blob: 0fbd7425ab6e6fead2b296df58291531f0b04160 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
{
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 "persisting directories and files with impermanence";
directories = lib.mkOption {
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;
inherit (cfg) directories;
users = userDirectories;
files = [
"/etc/machine-id"
];
};
};
}
|