nixos: generalize copy-paste from stage-1 and zfs to utils
commitb267785c43547dbe854c994a91b9f012c9b7812f
authorJan Malakhovski <oxij@oxij.org>
dateTue 23 Aug 2016, 18:01 (10 years ago)
parent8da59c4
nixos/lib/utils.nix+4
@@ -2,6 +2,10 @@ pkgs: with pkgs.lib;
22
33rec {
44
5+ # Check whenever fileSystem is needed for boot
6+ fsNeededForBoot = fs: fs.neededForBoot
7+ || elem fs.mountPoint [ "/" "/nix" "/nix/store" "/var" "/var/log" "/var/lib" "/etc" ];
8+
59 # Check whenever `b` depends on `a` as a fileSystem
610 # FIXME: it's incorrect to simply use hasPrefix here: "/dev/a" is not a parent of "/dev/ab"
711 fsBefore = a: b: ((any (x: elem x [ "bind" "move" ]) b.options) && (a.mountPoint == b.device))
nixos/modules/system/boot/stage-1.nix+1−3
@@ -26,9 +26,7 @@ let
2626 # The initrd only has to mount `/` or any FS marked as necessary for
2727 # booting (such as the FS containing `/nix/store`, or an FS needed for
2828 # mounting `/`, like `/` on a loopback).
29− fileSystems = filter
30− (fs: fs.neededForBoot || elem fs.mountPoint [ "/" "/nix" "/nix/store" "/var" "/var/log" "/var/lib" "/etc" ])
31− config.system.build.fileSystems;
29+ fileSystems = filter utils.fsNeededForBoot config.system.build.fileSystems;
3230
3331
3432 # Some additional utilities needed in stage 1, like mount, lvm, fsck
nixos/modules/tasks/filesystems/zfs.nix+1−3
@@ -38,11 +38,9 @@ let
3838
3939 zfsFilesystems = filter (x: x.fsType == "zfs") config.system.build.fileSystems;
4040
41− isRoot = fs: fs.neededForBoot || elem fs.mountPoint [ "/" "/nix" "/nix/store" "/var" "/var/log" "/var/lib" "/etc" ];
42−
4341 allPools = unique ((map fsToPool zfsFilesystems) ++ cfgZfs.extraPools);
4442
45− rootPools = unique (map fsToPool (filter isRoot zfsFilesystems));
43+ rootPools = unique (map fsToPool (filter fsNeededForBoot zfsFilesystems));
4644
4745 dataPools = unique (filter (pool: !(elem pool rootPools)) allPools);
4846