1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7 initScriptBuilder = pkgs.substituteAll {
8 src = ./init-script-builder.sh;
9 isExecutable = true;
10 inherit (pkgs) bash;
11 path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep];
12 };
13
14in
15
16{
17
18 ###### interface
19
20 options = {
21
22 boot.loader.initScript = {
23
24 enable = mkOption {
25 default = false;
26 type = types.bool;
27 description = ''
28 Some systems require a /sbin/init script which is started.
29 Or having it makes starting NixOS easier.
30 This applies to some kind of hosting services and user mode linux.
31
32 Additionally this script will create
33 /boot/init-other-configurations-contents.txt containing
34 contents of remaining configurations. You can copy paste them into
35 /sbin/init manually running a rescue system or such.
36 '';
37 };
38 };
39
40 };
41
42
43 ###### implementation
44
45 config = mkIf config.boot.loader.initScript.enable {
46
47 system.build.installBootLoader = initScriptBuilder;
48
49 };
50
51}