nixos/top-level: Install 'bootStage2' as 'init' in all non-initrd configs (#441777)

This commit is contained in:
Will Fancher
2025-09-10 14:39:32 +00:00
committed by GitHub
3 changed files with 8 additions and 8 deletions

View File

@@ -28,9 +28,7 @@
options = { };
config =
let
initScript = if config.boot.initrd.systemd.enable then "prepare-root" else "init";
in
{
boot.isContainer = true;
boot.postBootCommands = ''
@@ -79,7 +77,7 @@
contents = [
{
source = config.system.build.toplevel + "/${initScript}";
source = config.system.build.toplevel + "/init";
target = "/sbin/init";
}
# Technically this is not required for lxc, but having also make this configuration work with systemd-nspawn.
@@ -104,7 +102,7 @@
pseudoFiles = [
"/sbin d 0755 0 0"
"/sbin/init s 0555 0 0 ${config.system.build.toplevel}/${initScript}"
"/sbin/init s 0555 0 0 ${config.system.build.toplevel}/init"
"/dev d 0755 0 0"
"/proc d 0555 0 0"
"/sys d 0555 0 0"
@@ -113,7 +111,7 @@
system.build.installBootLoader = pkgs.writeScript "install-lxc-sbin-init.sh" ''
#!${pkgs.runtimeShell}
${pkgs.coreutils}/bin/ln -fs "$1/${initScript}" /sbin/init
${pkgs.coreutils}/bin/ln -fs "$1/init" /sbin/init
'';
# networkd depends on this, but systemd module disables this for containers
@@ -122,7 +120,7 @@
systemd.packages = [ pkgs.distrobuilder.generator ];
system.activationScripts.installInitScript = lib.mkForce ''
ln -fs $systemConfig/${initScript} /sbin/init
ln -fs $systemConfig/init /sbin/init
'';
};
}