nixos: apply toposort to fileSystems to support bind and move mounts

And use new `config.system.build.fileSystems` property everywhere.
This commit is contained in:
Jan Malakhovski
2016-08-23 18:14:05 +00:00
parent 2c8ca0d1bd
commit 65d26c4dc1
6 changed files with 43 additions and 19 deletions
+11 -12
View File
@@ -3,7 +3,7 @@
# the modules necessary to mount the root file system, then calls the
# init in the root file system to start the second boot stage.
{ config, lib, pkgs, ... }:
{ config, lib, utils, pkgs, ... }:
with lib;
@@ -23,6 +23,14 @@ 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;
# Some additional utilities needed in stage 1, like mount, lvm, fsck
# etc. We don't want to bring in all of those packages, so we just
# copy what we need. Instead of using statically linked binaries,
@@ -71,7 +79,7 @@ let
ln -sf kmod $out/bin/modprobe
# Copy resize2fs if needed.
${optionalString (any (fs: fs.autoResize) (attrValues config.fileSystems)) ''
${optionalString (any (fs: fs.autoResize) config.system.build.fileSystems) ''
# We need mke2fs in the initrd.
copy_bin_and_libs ${pkgs.e2fsprogs}/sbin/resize2fs
''}
@@ -128,14 +136,6 @@ 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" ])
(attrValues config.fileSystems);
udevRules = pkgs.stdenv.mkDerivation {
name = "udev-rules";
allowedReferences = [ extraUtils ];
@@ -398,9 +398,8 @@ in
};
config = mkIf (!config.boot.isContainer) {
assertions = [
{ assertion = any (fs: fs.mountPoint == "/") (attrValues config.fileSystems);
{ assertion = any (fs: fs.mountPoint == "/") fileSystems;
message = "The fileSystems option does not specify your root file system.";
}
{ assertion = let inherit (config.boot) resumeDevice; in