|
31 | 31 |
|
32 | 32 | edk2ShellEspPath = "efi/edk2-uefi-shell/shell.efi"; |
33 | 33 |
|
34 | | - systemdBootBuilder = pkgs.substituteAll rec { |
| 34 | + systemdBootBuilder = pkgs.replaceVarsWith { |
35 | 35 | name = "systemd-boot"; |
36 | 36 |
|
37 | 37 | dir = "bin"; |
|
40 | 40 |
|
41 | 41 | isExecutable = true; |
42 | 42 |
|
43 | | - inherit (builtins) storeDir; |
| 43 | + replacements = rec { |
| 44 | + inherit (builtins) storeDir; |
44 | 45 |
|
45 | | - inherit (pkgs) python3; |
| 46 | + inherit (pkgs) python3; |
46 | 47 |
|
47 | | - systemd = config.systemd.package; |
| 48 | + systemd = config.systemd.package; |
48 | 49 |
|
49 | | - bootspecTools = pkgs.bootspec; |
| 50 | + bootspecTools = pkgs.bootspec; |
50 | 51 |
|
51 | | - nix = config.nix.package.out; |
| 52 | + nix = config.nix.package.out; |
52 | 53 |
|
53 | | - timeout = if config.boot.loader.timeout == null then "menu-force" else config.boot.loader.timeout; |
| 54 | + timeout = if config.boot.loader.timeout == null then "menu-force" else config.boot.loader.timeout; |
54 | 55 |
|
55 | | - configurationLimit = if cfg.configurationLimit == null then 0 else cfg.configurationLimit; |
| 56 | + configurationLimit = if cfg.configurationLimit == null then 0 else cfg.configurationLimit; |
56 | 57 |
|
57 | | - inherit (cfg) |
58 | | - consoleMode |
59 | | - graceful |
60 | | - editor |
61 | | - rebootForBitlocker |
62 | | - ; |
| 58 | + inherit (cfg) |
| 59 | + consoleMode |
| 60 | + graceful |
| 61 | + editor |
| 62 | + rebootForBitlocker |
| 63 | + ; |
63 | 64 |
|
64 | | - inherit (efi) efiSysMountPoint canTouchEfiVariables; |
| 65 | + inherit (efi) efiSysMountPoint canTouchEfiVariables; |
65 | 66 |
|
66 | | - bootMountPoint = |
67 | | - if cfg.xbootldrMountPoint != null then cfg.xbootldrMountPoint else efi.efiSysMountPoint; |
| 67 | + bootMountPoint = |
| 68 | + if cfg.xbootldrMountPoint != null then cfg.xbootldrMountPoint else efi.efiSysMountPoint; |
68 | 69 |
|
69 | | - nixosDir = "/EFI/nixos"; |
| 70 | + nixosDir = "/EFI/nixos"; |
70 | 71 |
|
71 | | - inherit (config.system.nixos) distroName; |
| 72 | + inherit (config.system.nixos) distroName; |
72 | 73 |
|
73 | | - memtest86 = optionalString cfg.memtest86.enable pkgs.memtest86plus; |
74 | | - |
75 | | - netbootxyz = optionalString cfg.netbootxyz.enable pkgs.netbootxyz-efi; |
| 74 | + checkMountpoints = pkgs.writeShellScript "check-mountpoints" '' |
| 75 | + fail() { |
| 76 | + echo "$1 = '$2' is not a mounted partition. Is the path configured correctly?" >&2 |
| 77 | + exit 1 |
| 78 | + } |
| 79 | + ${pkgs.util-linuxMinimal}/bin/findmnt ${efiSysMountPoint} > /dev/null || fail efiSysMountPoint ${efiSysMountPoint} |
| 80 | + ${lib.optionalString (cfg.xbootldrMountPoint != null) |
| 81 | + "${pkgs.util-linuxMinimal}/bin/findmnt ${cfg.xbootldrMountPoint} > /dev/null || fail xbootldrMountPoint ${cfg.xbootldrMountPoint}" |
| 82 | + } |
| 83 | + ''; |
76 | 84 |
|
77 | | - checkMountpoints = pkgs.writeShellScript "check-mountpoints" '' |
78 | | - fail() { |
79 | | - echo "$1 = '$2' is not a mounted partition. Is the path configured correctly?" >&2 |
80 | | - exit 1 |
81 | | - } |
82 | | - ${pkgs.util-linuxMinimal}/bin/findmnt ${efiSysMountPoint} > /dev/null || fail efiSysMountPoint ${efiSysMountPoint} |
83 | | - ${lib.optionalString (cfg.xbootldrMountPoint != null) |
84 | | - "${pkgs.util-linuxMinimal}/bin/findmnt ${cfg.xbootldrMountPoint} > /dev/null || fail xbootldrMountPoint ${cfg.xbootldrMountPoint}" |
85 | | - } |
86 | | - ''; |
87 | | - |
88 | | - copyExtraFiles = pkgs.writeShellScript "copy-extra-files" '' |
89 | | - empty_file=$(${pkgs.coreutils}/bin/mktemp) |
90 | | -
|
91 | | - ${concatStrings ( |
92 | | - mapAttrsToList (n: v: '' |
93 | | - ${pkgs.coreutils}/bin/install -Dp "${v}" "${bootMountPoint}/"${escapeShellArg n} |
94 | | - ${pkgs.coreutils}/bin/install -D $empty_file "${bootMountPoint}/${nixosDir}/.extra-files/"${escapeShellArg n} |
95 | | - '') cfg.extraFiles |
96 | | - )} |
97 | | -
|
98 | | - ${concatStrings ( |
99 | | - mapAttrsToList (n: v: '' |
100 | | - ${pkgs.coreutils}/bin/install -Dp "${pkgs.writeText n v}" "${bootMountPoint}/loader/entries/"${escapeShellArg n} |
101 | | - ${pkgs.coreutils}/bin/install -D $empty_file "${bootMountPoint}/${nixosDir}/.extra-files/loader/entries/"${escapeShellArg n} |
102 | | - '') cfg.extraEntries |
103 | | - )} |
104 | | - ''; |
| 85 | + copyExtraFiles = pkgs.writeShellScript "copy-extra-files" '' |
| 86 | + empty_file=$(${pkgs.coreutils}/bin/mktemp) |
| 87 | +
|
| 88 | + ${concatStrings ( |
| 89 | + mapAttrsToList (n: v: '' |
| 90 | + ${pkgs.coreutils}/bin/install -Dp "${v}" "${bootMountPoint}/"${escapeShellArg n} |
| 91 | + ${pkgs.coreutils}/bin/install -D $empty_file "${bootMountPoint}/${nixosDir}/.extra-files/"${escapeShellArg n} |
| 92 | + '') cfg.extraFiles |
| 93 | + )} |
| 94 | +
|
| 95 | + ${concatStrings ( |
| 96 | + mapAttrsToList (n: v: '' |
| 97 | + ${pkgs.coreutils}/bin/install -Dp "${pkgs.writeText n v}" "${bootMountPoint}/loader/entries/"${escapeShellArg n} |
| 98 | + ${pkgs.coreutils}/bin/install -D $empty_file "${bootMountPoint}/${nixosDir}/.extra-files/loader/entries/"${escapeShellArg n} |
| 99 | + '') cfg.extraEntries |
| 100 | + )} |
| 101 | + ''; |
| 102 | + }; |
105 | 103 | }; |
106 | 104 |
|
107 | 105 | finalSystemdBootBuilder = pkgs.writeScript "install-systemd-boot.sh" '' |
|
0 commit comments