nixos/etc: use nixos-init to find etc

nikstur d9e6299a d0c03e4c

Changed files
+4 -19
nixos
modules
system
boot
systemd
etc
+2
nixos/modules/system/boot/systemd/initrd.nix
···
# 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"
+2 -19
nixos/modules/system/etc/etc-activation.nix
···
{
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";
···
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
-
'';
};
}
];