diff --git a/nixos/modules/system/boot/systemd/initrd.nix b/nixos/modules/system/boot/systemd/initrd.nix index 2bf68adc0f92..b1efa96e8672 100644 --- a/nixos/modules/system/boot/systemd/initrd.nix +++ b/nixos/modules/system/boot/systemd/initrd.nix @@ -563,6 +563,8 @@ in # Resolving sysroot symlinks without code exec "${pkgs.chroot-realpath}/bin/chroot-realpath" + # Find the etc paths + "${config.system.nixos-init.package}/bin/find-etc" ] ++ lib.optionals config.system.nixos-init.enable [ "${config.system.nixos-init.package}/bin/initrd-init" diff --git a/nixos/modules/system/etc/etc-activation.nix b/nixos/modules/system/etc/etc-activation.nix index 40cb28d0434f..25c3ea7274a6 100644 --- a/nixos/modules/system/etc/etc-activation.nix +++ b/nixos/modules/system/etc/etc-activation.nix @@ -144,15 +144,10 @@ { initrd-find-etc = { description = "Find the path to the etc metadata image and based dir"; - requires = [ - config.boot.initrd.systemd.services.initrd-find-nixos-closure.name - ]; - after = [ - config.boot.initrd.systemd.services.initrd-find-nixos-closure.name - ]; before = [ "shutdown.target" ]; conflicts = [ "shutdown.target" ]; requiredBy = [ "initrd.target" ]; + path = [ config.system.nixos-init.package ]; unitConfig = { DefaultDependencies = false; RequiresMountsFor = "/sysroot/nix/store"; @@ -160,20 +155,8 @@ serviceConfig = { Type = "oneshot"; RemainAfterExit = true; + ExecStart = "${config.system.nixos-init.package}/bin/find-etc"; }; - - script = # bash - '' - set -uo pipefail - - closure="$(realpath /nixos-closure)" - - metadata_image="$(${pkgs.chroot-realpath}/bin/chroot-realpath /sysroot "$closure/etc-metadata-image")" - ln -s "/sysroot$metadata_image" /etc-metadata-image - - basedir="$(${pkgs.chroot-realpath}/bin/chroot-realpath /sysroot "$closure/etc-basedir")" - ln -s "/sysroot$basedir" /etc-basedir - ''; }; } ];