systemd-stage-1: Use x-initrd.mount for better unit dependencies
This commit is contained in:
@@ -460,21 +460,6 @@ in {
|
|||||||
(v: let n = escapeSystemdPath v.where;
|
(v: let n = escapeSystemdPath v.where;
|
||||||
in nameValuePair "${n}.automount" (automountToUnit n v)) cfg.automounts);
|
in nameValuePair "${n}.automount" (automountToUnit n v)) cfg.automounts);
|
||||||
|
|
||||||
# The unit in /run/systemd/generator shadows the unit in
|
|
||||||
# /etc/systemd/system, but will still apply drop-ins from
|
|
||||||
# /etc/systemd/system/foo.service.d/
|
|
||||||
#
|
|
||||||
# We need IgnoreOnIsolate, otherwise the Requires dependency of
|
|
||||||
# a mount unit on its makefs unit causes it to be unmounted when
|
|
||||||
# we isolate for switch-root. Use a dummy package so that
|
|
||||||
# generateUnits will generate drop-ins instead of unit files.
|
|
||||||
packages = [(pkgs.runCommand "dummy" {} ''
|
|
||||||
mkdir -p $out/etc/systemd/system
|
|
||||||
touch $out/etc/systemd/system/systemd-{makefs,growfs}@.service
|
|
||||||
'')];
|
|
||||||
services."systemd-makefs@" = lib.mkIf needMakefs { unitConfig.IgnoreOnIsolate = true; };
|
|
||||||
services."systemd-growfs@" = lib.mkIf needGrowfs { unitConfig.IgnoreOnIsolate = true; };
|
|
||||||
|
|
||||||
# make sure all the /dev nodes are set up
|
# make sure all the /dev nodes are set up
|
||||||
services.systemd-tmpfiles-setup-dev.wantedBy = ["sysinit.target"];
|
services.systemd-tmpfiles-setup-dev.wantedBy = ["sysinit.target"];
|
||||||
|
|
||||||
|
|||||||
@@ -140,7 +140,10 @@ let
|
|||||||
else if config.fsType == "reiserfs" then "-q"
|
else if config.fsType == "reiserfs" then "-q"
|
||||||
else null;
|
else null;
|
||||||
in {
|
in {
|
||||||
options = mkIf config.autoResize [ "x-nixos.autoresize" ];
|
options = mkMerge [
|
||||||
|
(mkIf config.autoResize [ "x-nixos.autoresize" ])
|
||||||
|
(mkIf (utils.fsNeededForBoot config) [ "x-initrd.mount" ])
|
||||||
|
];
|
||||||
formatOptions = mkIf (defaultFormatOptions != null) (mkDefault defaultFormatOptions);
|
formatOptions = mkIf (defaultFormatOptions != null) (mkDefault defaultFormatOptions);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -165,7 +168,7 @@ let
|
|||||||
+ (if fs.device != null then escape fs.device
|
+ (if fs.device != null then escape fs.device
|
||||||
else if fs.label != null then "/dev/disk/by-label/${escape fs.label}"
|
else if fs.label != null then "/dev/disk/by-label/${escape fs.label}"
|
||||||
else throw "No device specified for mount point ‘${fs.mountPoint}’.")
|
else throw "No device specified for mount point ‘${fs.mountPoint}’.")
|
||||||
+ " " + escape (rootPrefix + fs.mountPoint)
|
+ " " + escape fs.mountPoint
|
||||||
+ " " + fs.fsType
|
+ " " + fs.fsType
|
||||||
+ " " + escape (builtins.concatStringsSep "," (fs.options ++ (extraOpts fs)))
|
+ " " + escape (builtins.concatStringsSep "," (fs.options ++ (extraOpts fs)))
|
||||||
+ " " + (optionalString (!excludeChecks)
|
+ " " + (optionalString (!excludeChecks)
|
||||||
@@ -328,7 +331,9 @@ in
|
|||||||
)}
|
)}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
boot.initrd.systemd.contents."/etc/fstab".source = initrdFstab;
|
boot.initrd.systemd.storePaths = [initrdFstab];
|
||||||
|
boot.initrd.systemd.managerEnvironment.SYSTEMD_SYSROOT_FSTAB = initrdFstab;
|
||||||
|
boot.initrd.systemd.services.initrd-parse-etc.environment.SYSTEMD_SYSROOT_FSTAB = initrdFstab;
|
||||||
|
|
||||||
# Provide a target that pulls in all filesystems.
|
# Provide a target that pulls in all filesystems.
|
||||||
systemd.targets.fs =
|
systemd.targets.fs =
|
||||||
|
|||||||
@@ -1084,8 +1084,8 @@ in
|
|||||||
what = "overlay";
|
what = "overlay";
|
||||||
type = "overlay";
|
type = "overlay";
|
||||||
options = "lowerdir=/sysroot/nix/.ro-store,upperdir=/sysroot/nix/.rw-store/store,workdir=/sysroot/nix/.rw-store/work";
|
options = "lowerdir=/sysroot/nix/.ro-store,upperdir=/sysroot/nix/.rw-store/store,workdir=/sysroot/nix/.rw-store/work";
|
||||||
wantedBy = ["local-fs.target"];
|
wantedBy = ["initrd-fs.target"];
|
||||||
before = ["local-fs.target"];
|
before = ["initrd-fs.target"];
|
||||||
requires = ["sysroot-nix-.ro\\x2dstore.mount" "sysroot-nix-.rw\\x2dstore.mount" "rw-store.service"];
|
requires = ["sysroot-nix-.ro\\x2dstore.mount" "sysroot-nix-.rw\\x2dstore.mount" "rw-store.service"];
|
||||||
after = ["sysroot-nix-.ro\\x2dstore.mount" "sysroot-nix-.rw\\x2dstore.mount" "rw-store.service"];
|
after = ["sysroot-nix-.ro\\x2dstore.mount" "sysroot-nix-.rw\\x2dstore.mount" "rw-store.service"];
|
||||||
unitConfig.IgnoreOnIsolate = true;
|
unitConfig.IgnoreOnIsolate = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user