-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhome-manager.nix
85 lines (85 loc) · 2.11 KB
/
home-manager.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
81
82
83
84
85
{ config, lib, ... }:
let
scriptFor = import ./gen-script.nix lib;
allMounts =
builtins.concatLists
(builtins.attrValues
(builtins.mapAttrs
(mount_path: opts:
if opts.removePrefixDirectory
then [ ]
else
(builtins.map
(entry:
{
inherit mount_path entry;
type = "dir";
}
)
opts.directories)
++
(builtins.map
(entry:
{
inherit mount_path entry;
type = "file";
}
)
opts.files)
)
config.home.persistence
));
binds = builtins.filter builtins.isAttrs # remove nulls
(
builtins.map
({ mount_path, type, entry }:
if type == "dir"
then
(if builtins.isString entry
then { inherit mount_path; root_path = entry; }
else
(if entry.method == "bindfs"
then { inherit mount_path; root_path = entry.directory; }
else null))
else null
)
allMounts);
links = builtins.filter builtins.isAttrs # remove nulls
(builtins.map
({ mount_path, type, entry }:
if type == "dir"
then
(if builtins.isAttrs entry && entry.method == "symlink"
then { inherit mount_path; root_path = entry.directory; }
else null)
else
{
inherit mount_path;
root_path =
if builtins.isString entry
then entry
else entry.file;
}
)
allMounts);
in
{
home.activation = {
persist-retro =
lib.hm.dag.entryBefore
# before
[
"createAndMountPersistentStoragePaths"
"createTargetFileDirectories"
]
(scriptFor binds)
;
persist-retro-link-phase =
lib.hm.dag.entryBefore
[
"checkLinkTargets"
]
(scriptFor links)
;
};
}