boot/init: Respect `init=` for upstream NixOS compatibility
We're stripping `init` to add it back next... A bit wasteful, but this
keeps things compatible.
@@ -92,6 +92,13 @@ class Tasks::SwitchRoot < SingletonTask
return generation_parameter.split("=", 2).last
end
+ # Given as a command-line option, from the bootloader (replacement for NixOS's stage-1)
+ init_parameter = System.cmdline().grep(/^init=/).first
+ unless init_parameter.nil?
+ init_parameter = init_parameter.split("=", 2).last
+ return init_parameter.rpartition("/").first
+ end
+
# The default generation
if File.symlink?(File.join(@target, DEFAULT_SYSTEM_LINK))
return DEFAULT_SYSTEM_LINK
