2014-04-14 16:26:48 +02:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
lib,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2009-12-17 06:04:36 +00:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2009-12-17 06:04:36 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2024-11-30 20:00:23 +01:00
|
|
|
initScriptBuilder = pkgs.replaceVarsWith {
|
2009-12-17 06:04:36 +00:00
|
|
|
src = ./init-script-builder.sh;
|
|
|
|
isExecutable = true;
|
2024-11-30 20:00:23 +01:00
|
|
|
replacements = {
|
|
|
|
inherit (pkgs) bash;
|
|
|
|
inherit (config.system.nixos) distroName;
|
|
|
|
path = lib.makeBinPath [
|
|
|
|
pkgs.coreutils
|
|
|
|
pkgs.gnused
|
|
|
|
pkgs.gnugrep
|
|
|
|
];
|
|
|
|
};
|
2009-12-17 06:04:36 +00:00
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-12-17 06:04:36 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
boot.loader.initScript = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
2009-12-17 11:43:12 +00:00
|
|
|
default = false;
|
2015-02-23 18:00:21 +01:00
|
|
|
type = types.bool;
|
2009-12-17 06:04:36 +00:00
|
|
|
description = ''
|
|
|
|
Some systems require a /sbin/init script which is started.
|
|
|
|
Or having it makes starting NixOS easier.
|
|
|
|
This applies to some kind of hosting services and user mode linux.
|
|
|
|
|
2013-08-10 21:07:13 +00:00
|
|
|
Additionally this script will create
|
2009-12-17 06:04:36 +00:00
|
|
|
/boot/init-other-configurations-contents.txt containing
|
|
|
|
contents of remaining configurations. You can copy paste them into
|
2013-08-10 21:07:13 +00:00
|
|
|
/sbin/init manually running a rescue system or such.
|
2009-12-17 06:04:36 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-12-17 06:04:36 +00:00
|
|
|
###### implementation
|
|
|
|
|
2012-07-25 11:30:16 -04:00
|
|
|
config = mkIf config.boot.loader.initScript.enable {
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2012-07-25 11:30:16 -04:00
|
|
|
system.build.installBootLoader = initScriptBuilder;
|
2009-12-17 06:04:36 +00:00
|
|
|
|
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
2009-12-17 06:04:36 +00:00
|
|
|
}
|