From b267785c43547dbe854c994a91b9f012c9b7812f Mon Sep 17 00:00:00 2001 From: Jan Malakhovski Date: Tue, 23 Aug 2016 18:01:35 +0000 Subject: [PATCH] nixos: generalize copy-paste from stage-1 and zfs to utils --- nixos/lib/utils.nix | 4 ++++ nixos/modules/system/boot/stage-1.nix | 4 +--- nixos/modules/tasks/filesystems/zfs.nix | 4 +--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nixos/lib/utils.nix b/nixos/lib/utils.nix index 56a1e8a1d8b..1ef915d4061 100644 --- a/nixos/lib/utils.nix +++ b/nixos/lib/utils.nix @@ -2,6 +2,10 @@ pkgs: with pkgs.lib; rec { + # Check whenever fileSystem is needed for boot + fsNeededForBoot = fs: fs.neededForBoot + || elem fs.mountPoint [ "/" "/nix" "/nix/store" "/var" "/var/log" "/var/lib" "/etc" ]; + # Check whenever `b` depends on `a` as a fileSystem # FIXME: it's incorrect to simply use hasPrefix here: "/dev/a" is not a parent of "/dev/ab" fsBefore = a: b: ((any (x: elem x [ "bind" "move" ]) b.options) && (a.mountPoint == b.device)) diff --git a/nixos/modules/system/boot/stage-1.nix b/nixos/modules/system/boot/stage-1.nix index 982f4e4a85c..a5c05f3dbba 100644 --- a/nixos/modules/system/boot/stage-1.nix +++ b/nixos/modules/system/boot/stage-1.nix @@ -26,9 +26,7 @@ let # The initrd only has to mount `/` or any FS marked as necessary for # booting (such as the FS containing `/nix/store`, or an FS needed for # mounting `/`, like `/` on a loopback). - fileSystems = filter - (fs: fs.neededForBoot || elem fs.mountPoint [ "/" "/nix" "/nix/store" "/var" "/var/log" "/var/lib" "/etc" ]) - config.system.build.fileSystems; + fileSystems = filter utils.fsNeededForBoot config.system.build.fileSystems; # Some additional utilities needed in stage 1, like mount, lvm, fsck diff --git a/nixos/modules/tasks/filesystems/zfs.nix b/nixos/modules/tasks/filesystems/zfs.nix index 77059fa43ff..c5f41cc338c 100644 --- a/nixos/modules/tasks/filesystems/zfs.nix +++ b/nixos/modules/tasks/filesystems/zfs.nix @@ -38,11 +38,9 @@ let zfsFilesystems = filter (x: x.fsType == "zfs") config.system.build.fileSystems; - isRoot = fs: fs.neededForBoot || elem fs.mountPoint [ "/" "/nix" "/nix/store" "/var" "/var/log" "/var/lib" "/etc" ]; - allPools = unique ((map fsToPool zfsFilesystems) ++ cfgZfs.extraPools); - rootPools = unique (map fsToPool (filter isRoot zfsFilesystems)); + rootPools = unique (map fsToPool (filter fsNeededForBoot zfsFilesystems)); dataPools = unique (filter (pool: !(elem pool rootPools)) allPools);