Skip to content

Commit

Permalink
nixos: Fix create-needed-for-boot-dirs dependencies for zfs
Browse files Browse the repository at this point in the history
  • Loading branch information
talyz committed Sep 28, 2024
1 parent 8514fff commit cc8906f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions nixos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -719,8 +719,14 @@ in
matchFileSystems = fs: attrValues (filterAttrs (_: v: v.mountPoint or null == fs) all);
in
concatMap matchFileSystems persistentStoragePaths;
devices =
map (d: "${(escapeSystemdPath d)}.device") (catAttrs "device" fileSystems);
deviceUnits = unique
(map
(fs:
if fs.fsType == "zfs" then
"zfs-import.target"
else
"${(escapeSystemdPath fs.device)}.device")
fileSystems);
createNeededForBootDirs = ''
${concatMapStrings mkMount fileSystems}
${concatMapStrings mkDir neededForBootDirs}
Expand All @@ -731,10 +737,11 @@ in
systemd.services = mkIf config.boot.initrd.systemd.enable {
create-needed-for-boot-dirs = {
wantedBy = [ "initrd-root-device.target" ];
wants = devices;
after = devices;
wants = deviceUnits;
after = deviceUnits;
before = [ "sysroot.mount" ];
serviceConfig.Type = "oneshot";
unitConfig.DefaultDependencies = false;
script = createNeededForBootDirs;
};
};
Expand Down

0 comments on commit cc8906f

Please sign in to comment.