-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnixos.nix
80 lines (80 loc) · 2.01 KB
/
nixos.nix
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
{ config, lib, ... }:
let
scriptFor = import ./gen-script.nix lib;
concatMapFlatten = func: attrs:
builtins.concatLists (builtins.attrValues (builtins.mapAttrs func attrs));
getUserBinds =
mount_path: user:
(builtins.map
(entry:
if entry.filePath == entry.home + "/" + entry.file
&& entry.persistentStoragePath == mount_path
then
{
inherit mount_path;
root_path = entry.filePath;
}
else null
)
user.files
)
++
(builtins.map
(entry:
if entry.dirPath == entry.home + "/" + entry.directory
&& entry.persistentStoragePath == mount_path
then
{
inherit mount_path;
root_path = entry.dirPath;
}
else null
)
user.directories
);
binds =
concatMapFlatten
(mount_path: opts:
builtins.filter builtins.isAttrs
(
(builtins.map
(entry:
if entry.dirPath == entry.directory
&& entry.persistentStoragePath == mount_path
then
{
inherit mount_path;
root_path = entry.dirPath;
}
else null
)
opts.directories)
++
(builtins.map
(entry:
if entry.filePath == entry.file
&& entry.persistentStoragePath == mount_path
then
{
inherit mount_path;
root_path = entry.filePath;
}
else null
)
opts.files)
++
(concatMapFlatten
(_name: user: getUserBinds mount_path user)
opts.users
)
)
)
config.environment.persistence
;
in
{
system.activationScripts.createPersistentStorageDirs.deps = [ "persist-retro" ];
system.activationScripts.persist-retro = {
text = scriptFor binds;
};
}