blob: 857915cacf8e2251f22d9bf5d558b85accc25c20 (
plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
{
config,
lib,
...
}:
with lib; let
cfg = config.local.boot.impermanence;
#TODO: type correcto de files, directories?
entryOption = mkOption {
type = with lib.types; listOf (either str attrs);
default = [];
};
persistPath = "/persist";
trustPath =
if cfg.trust.path != null
then cfg.trust.path
else persistPath;
in {
options.local.boot.impermanence = {
enable = mkEnableOption "root fs impermanence";
files = entryOption;
directories = entryOption;
trust = {
path = mkOption {
type = with lib.types; nullOr path;
default = null;
};
files = entryOption;
directories = entryOption;
};
};
config = mkMerge [
{
local.boot.impermanence = {
directories = [
"/etc/lvm"
"/var/lib/lastlog"
"/var/lib/nixos"
"/var/lib/systemd"
"/var/log"
];
files =
[
"/etc/machine-id"
"/var/lib/logrotate.status"
]
++ optionals config.users.mutableUsers [
"/etc/group"
"/etc/passwd"
"/etc/shadow"
"/etc/subuid"
"/etc/subgid"
];
trust = {
directories = [
"/var/trust"
];
};
};
}
(mkIf cfg.enable {
assertions = [
{
assertion = (config.fileSystems ? ${persistPath}) && config.fileSystems.${persistPath}.neededForBoot;
message = "Impermanence requires ${persistPath} to be a neededForBoot mountpoint";
}
];
environment.persistence = mkMerge [
{
${persistPath} = {
hideMounts = true;
files = cfg.files;
directories = cfg.directories;
};
}
{
${trustPath} = {
hideMounts = true;
files = cfg.trust.files;
directories = cfg.trust.directories;
};
}
];
})
];
}
|