-
Notifications
You must be signed in to change notification settings - Fork 2
/
module.nix
51 lines (45 loc) · 1.28 KB
/
module.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
{ config, lib, ... }:
let
cfg = config.preservation;
inherit (import ./lib.nix { inherit lib; })
mkRegularMountUnits
mkInitrdMountUnits
mkRegularTmpfilesRules
mkInitrdTmpfilesRules
;
in
{
imports = [
./options.nix
];
config = lib.mkIf cfg.enable {
assertions = [
{
assertion = config.boot.initrd.systemd.enable;
message = "This module cannot be used with scripted initrd.";
}
];
boot.initrd.systemd = {
targets.initrd-preservation = {
description = "Initrd Preservation Mounts";
before = [ "initrd.target" ];
wantedBy = [ "initrd.target" ];
};
tmpfiles.settings.preservation = lib.mkMerge (
lib.flatten (lib.mapAttrsToList mkInitrdTmpfilesRules cfg.preserveAt)
);
mounts = lib.flatten (lib.mapAttrsToList mkInitrdMountUnits cfg.preserveAt);
};
systemd = {
targets.preservation = {
description = "Preservation Mounts";
before = [ "sysinit.target" ];
wantedBy = [ "sysinit.target" ];
};
tmpfiles.settings.preservation = lib.mkMerge (
lib.flatten (lib.mapAttrsToList mkRegularTmpfilesRules cfg.preserveAt)
);
mounts = lib.flatten (lib.mapAttrsToList mkRegularMountUnits cfg.preserveAt);
};
};
}