@@ -3,7 +3,7 @@
33# the modules necessary to mount the root file system, then calls the
44# init in the root file system to start the second boot stage.
55
6−{ config, lib, pkgs, ... }:
6+{ config, lib, utils, pkgs, ... }:
77
88with lib;
99
@@ -23,6 +23,14 @@ let
2323 };
2424
2525
26+ # The initrd only has to mount `/` or any FS marked as necessary for
27+ # booting (such as the FS containing `/nix/store`, or an FS needed for
28+ # 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;
32+
33+
2634 # Some additional utilities needed in stage 1, like mount, lvm, fsck
2735 # etc. We don't want to bring in all of those packages, so we just
2836 # copy what we need. Instead of using statically linked binaries,
@@ -71,7 +79,7 @@ let
7179 ln -sf kmod $out/bin/modprobe
7280
7381 # Copy resize2fs if needed.
74− ${optionalString (any (fs: fs.autoResize) (attrValues config.fileSystems)) ''
82+ ${optionalString (any (fs: fs.autoResize) config.system.build.fileSystems) ''
7583 # We need mke2fs in the initrd.
7684 copy_bin_and_libs ${pkgs.e2fsprogs}/sbin/resize2fs
7785 ''}
@@ -128,14 +136,6 @@ let
128136 ''; # */
129137
130138
131− # The initrd only has to mount / or any FS marked as necessary for
132− # booting (such as the FS containing /nix/store, or an FS needed for
133− # mounting /, like / on a loopback).
134− fileSystems = filter
135− (fs: fs.neededForBoot || elem fs.mountPoint [ "/" "/nix" "/nix/store" "/var" "/var/log" "/var/lib" "/etc" ])
136− (attrValues config.fileSystems);
137−
138−
139139 udevRules = pkgs.stdenv.mkDerivation {
140140 name = "udev-rules";
141141 allowedReferences = [ extraUtils ];
@@ -398,9 +398,8 @@ in
398398 };
399399
400400 config = mkIf (!config.boot.isContainer) {
401−
402401 assertions = [
403− { assertion = any (fs: fs.mountPoint == "/") (attrValues config.fileSystems);
402+ { assertion = any (fs: fs.mountPoint == "/") fileSystems;
404403 message = "The ‘fileSystems’ option does not specify your root file system.";
405404 }
406405 { assertion = let inherit (config.boot) resumeDevice; in