|
1 | | -inputs: |
2 | 1 | { |
3 | 2 | modulesPath, |
4 | | - config, |
5 | 3 | pkgs, |
6 | 4 | lib, |
7 | 5 | ... |
8 | 6 | }: |
9 | 7 | { |
| 8 | + # Reduce closure size (https://github.com/nix-community/nixos-images/blob/main/nix/noninteractive.nix) |
| 9 | + |
10 | 10 | disabledModules = [ |
11 | 11 | # This module adds values to multiple lists (systemPackages, supportedFilesystems) |
12 | 12 | # which are impossible/unpractical to remove, so we disable the entire module. |
13 | 13 | "profiles/base.nix" |
14 | 14 | ]; |
15 | 15 |
|
16 | 16 | imports = [ |
17 | | - (modulesPath + "/installer/netboot/netboot-minimal.nix") |
18 | 17 | # reduce closure size by removing perl |
19 | 18 | "${modulesPath}/profiles/perlless.nix" |
20 | 19 | # FIXME: we still are left with nixos-generate-config due to nixos-install-tools |
21 | 20 | { system.forbiddenDependenciesRegexes = lib.mkForce [ ]; } |
22 | 21 | ]; |
23 | 22 |
|
24 | | - boot.initrd.compressor = "xz"; |
25 | | - |
26 | | - system.stateVersion = config.system.nixos.release; |
27 | | - |
28 | | - nix.settings = { |
29 | | - extra-experimental-features = [ |
30 | | - "nix-command" |
31 | | - "flakes" |
32 | | - ]; |
33 | | - accept-flake-config = true; |
34 | | - }; |
35 | | - |
36 | | - # https://github.com/nix-community/nixos-images/blob/main/nix/kexec-installer/module.nix#L50 |
37 | | - system.build.kexecInstallerTarball = pkgs.runCommand "kexec-tarball" { } '' |
38 | | - mkdir xnodeos $out |
39 | | - cp "${config.system.build.netbootRamdisk}/initrd" xnodeos/initrd |
40 | | - cp "${config.system.build.kernel}/${config.system.boot.loader.kernelFile}" xnodeos/bzImage |
41 | | - cp "${config.system.build.kexecScript}" xnodeos/install |
42 | | - cp "${pkgs.pkgsStatic.kexec-tools}/bin/kexec" xnodeos/kexec |
43 | | - tar -czvf $out/OSkexec-${pkgs.stdenv.hostPlatform.system}.tar.gz xnodeos |
44 | | - ''; |
45 | | - |
46 | | - # https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/installer/netboot/netboot.nix#L120 |
47 | | - # Modify kexec-boot to pass env variables to kexec environment |
48 | | - system.build.kexecScript = lib.mkForce ( |
49 | | - pkgs.writeScript "kexec-boot" '' |
50 | | - #!/usr/bin/env bash |
51 | | - SCRIPT_DIR=$( cd -- "$( dirname -- "''${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) |
52 | | - ''${SCRIPT_DIR}/kexec --load ''${SCRIPT_DIR}/bzImage \ |
53 | | - --initrd=''${SCRIPT_DIR}/initrd \ |
54 | | - --command-line "init=${config.system.build.toplevel}/init ${toString config.boot.kernelParams} && $(cat << EOF |
55 | | -
|
56 | | - export XNODE_OWNER="''${XNODE_OWNER}" && export DOMAIN="''${DOMAIN}" && export ACME_EMAIL="''${ACME_EMAIL}" && export USER_PASSWD="''${USER_PASSWD}" && export ENCRYPTED="''${ENCRYPTED}" |
57 | | - EOF |
58 | | - )" |
59 | | - ''${SCRIPT_DIR}/kexec -e |
60 | | - '' |
61 | | - ); |
62 | | - |
63 | | - systemd.services.install-xnodeos = { |
64 | | - wantedBy = [ "multi-user.target" ]; |
65 | | - description = "Install XnodeOS."; |
66 | | - wants = [ "network-online.target" ]; |
67 | | - after = [ "network-online.target" ]; |
68 | | - serviceConfig = { |
69 | | - Type = "oneshot"; |
70 | | - User = "root"; |
71 | | - Group = "root"; |
72 | | - RemainAfterExit = true; |
73 | | - }; |
74 | | - path = [ |
75 | | - pkgs.libuuid |
76 | | - pkgs.jq |
77 | | - pkgs.curl |
78 | | - pkgs.nix |
79 | | - pkgs.nixos-install |
80 | | - inputs.disko.packages.${pkgs.system}.default |
81 | | - inputs.nixos-facter.packages.${pkgs.system}.default |
82 | | - pkgs.sbctl |
83 | | - pkgs.clevis |
84 | | - ]; |
85 | | - script = lib.readFile ./install.sh; |
86 | | - }; |
87 | | - |
88 | | - # Reduce closure size (https://github.com/nix-community/nixos-images/blob/main/nix/noninteractive.nix) |
89 | 23 | documentation.enable = false; |
90 | 24 | documentation.man.man-db.enable = false; |
91 | 25 | system.installer.channel.enable = false; |
|
0 commit comments