From b7c5fd93f161cb4e9b3c0870b1e14879ea192b74 Mon Sep 17 00:00:00 2001 From: Will Fancher Date: Tue, 23 May 2023 19:55:48 -0400 Subject: [PATCH] nixos: Support fileSystems..depends with fstab-generator --- nixos/modules/tasks/filesystems.nix | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/nixos/modules/tasks/filesystems.nix b/nixos/modules/tasks/filesystems.nix index cd0ba98ef968..5c95cd3d451e 100644 --- a/nixos/modules/tasks/filesystems.nix +++ b/nixos/modules/tasks/filesystems.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, utils, ... }: +{ config, lib, pkgs, utils, ... }@moduleArgs: with lib; with utils; @@ -136,10 +136,21 @@ let }; - config.options = mkMerge [ + config.options = let + inInitrd = utils.fsNeededForBoot config; + in mkMerge [ (mkIf config.autoResize [ "x-systemd.growfs" ]) (mkIf config.autoFormat [ "x-systemd.makefs" ]) (mkIf (utils.fsNeededForBoot config) [ "x-initrd.mount" ]) + (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 + ) + ) ]; };