Change:
systemd doesn't respect the option for file systems. Usually this is ok because systemd will mount file systems in the correct topological ordering. The option is useful because it allows you to express dependencies on e.g. the file systems that an FS's lower/upper/work directories exist on. This test should hang forever. Instead, it exits cleanly. The service never exits, so is never mounted, and therefore should never be mounted. So the test should hang. This is also a problem for systemd stage 1, but it's worse because we also have to account for the prefix. We can fix this by adding options for every dependency, and prefixing for the systemd stage 1 file systems.
Do we even need the option? I don't think it's particularly useful. The overlay also shouldn't be a concern since anymore.
Well, currently literally only does anything in scripted stage 1. In stage 2 and in systemd stage 1, you have to use , which is what the stuff does. That's fine, but it's an incompatibility between scripted and systemd stage 1. So we need to either deprecate it or implement it, and it's really easy to implement (I just need to fixup ). It's a handy convenience for people I guess, though far from a necessary one.

Discussion:
<del> { config, lib, pkgs, utils, ... }: </del> <ins> { config, lib, pkgs, utils, ... }@moduleArgs: </ins> with lib; with utils;

}; <del> config.options = mkMerge [ </del> <ins> config.options = let inInitrd = utils.fsNeededForBoot config; in mkMerge [ </ins> (mkIf config.autoResize [ "x-systemd.growfs" ]) (mkIf config.autoFormat [ "x-systemd.makefs" ]) (mkIf (utils.fsNeededForBoot config) [ "x-initrd.mount" ]) <ins> (mkIf # With scripted stage 1, depends is implemented by sorting 'config.system.build.fileSystems' (lib.length config.depends > 0 && (inInitrd -> moduleArgs.config.boot.initrd.systemd.enable)) ( map ( x: "x-systemd.requires-mounts-for=${optionalString inInitrd "/sysroot"}${x}" ) config.depends ) ) </ins> ]; };

config = lib.mkIf (config.overlay.lowerdir != null) { fsType = "overlay"; device = lib.mkDefault "overlay"; <ins> depends = map (x: "${x}") (config.overlay.lowerdir ++ lib.optionals (config.overlay.upperdir != null) [ config.overlay.upperdir config.overlay.workdir ]); </ins> options = let

] ++ lib.optionals (config.overlay.upperdir != null) [ "upperdir=${upperdir}" "workdir=${workdir}" <del> ] ++ (map (s: "x-systemd.requires-mounts-for=${s}") lowerdir); </del> <ins> ]; </ins> }; };

boot.initrd.availableKernelModules = lib.mkIf (initrdFileSystems != { }) [ "overlay" ]; <del> assertions = lib.concatLists (lib.mapAttrsToList (_name: fs: [ { assertion = (fs.overlay.upperdir == null) == (fs.overlay.workdir == null); message = "You cannot define a `lowerdir` without a `workdir` and vice versa for mount point: ${fs.mountPoint}"; } { assertion = (fs.overlay.lowerdir != null && fs.overlay.upperdir == null) -> (lib.length fs.overlay.lowerdir) >= 2; message = "A read-only overlay (without an `upperdir`) requires at least 2 `lowerdir`s: ${fs.mountPoint}"; } ]) config.fileSystems); </del> <ins> assertions = lib.concatLists ( lib.mapAttrsToList (_name: fs: [ { assertion = (fs.overlay.upperdir == null) == (fs.overlay.workdir == null); message = "You cannot define a `lowerdir` without a `workdir` and vice versa for mount point: ${fs.mountPoint}"; } { assertion = (fs.overlay.lowerdir != null && fs.overlay.upperdir == null) -> (lib.length fs.overlay.lowerdir) >= 2; message = "A read-only overlay (without an `upperdir`) requires at least 2 `lowerdir`s: ${fs.mountPoint}"; } ]) overlayFileSystems ) ++ lib.mapAttrsToList (_: fs: { assertion = fs.overlay.upperdir == null -> config.boot.initrd.systemd.enable; message = '' Stage 1 overlay file system ${fs.mountPoint} has no upperdir, which is not supported with scripted initrd. Please enable 'boot.initrd.systemd.enable'. ''; }) initrdFileSystems; </ins> boot.initrd.systemd.services = lib.mkMerge (lib.mapAttrsToList preMountService initrdFileSystems); systemd.services = lib.mkMerge (lib.mapAttrsToList preMountService userspaceFileSystems);

nodes.machine = { config, pkgs, ... }: { boot.initrd.systemd.enable = true; <del> boot.initrd.availableKernelModules = [ "overlay" ]; </del> virtualisation.fileSystems = { "/initrd-overlay" = {