Skip to content

Commit b9ea481

Browse files
nixos/systemd-boot: replace substituteAll with replaceVarsWith
1 parent 83d43b4 commit b9ea481

File tree

1 file changed

+48
-50
lines changed

1 file changed

+48
-50
lines changed

nixos/modules/system/boot/loader/systemd-boot/systemd-boot.nix

Lines changed: 48 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ let
3131

3232
edk2ShellEspPath = "efi/edk2-uefi-shell/shell.efi";
3333

34-
systemdBootBuilder = pkgs.substituteAll rec {
34+
systemdBootBuilder = pkgs.replaceVarsWith {
3535
name = "systemd-boot";
3636

3737
dir = "bin";
@@ -40,68 +40,66 @@ let
4040

4141
isExecutable = true;
4242

43-
inherit (builtins) storeDir;
43+
replacements = rec {
44+
inherit (builtins) storeDir;
4445

45-
inherit (pkgs) python3;
46+
inherit (pkgs) python3;
4647

47-
systemd = config.systemd.package;
48+
systemd = config.systemd.package;
4849

49-
bootspecTools = pkgs.bootspec;
50+
bootspecTools = pkgs.bootspec;
5051

51-
nix = config.nix.package.out;
52+
nix = config.nix.package.out;
5253

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;
5455

55-
configurationLimit = if cfg.configurationLimit == null then 0 else cfg.configurationLimit;
56+
configurationLimit = if cfg.configurationLimit == null then 0 else cfg.configurationLimit;
5657

57-
inherit (cfg)
58-
consoleMode
59-
graceful
60-
editor
61-
rebootForBitlocker
62-
;
58+
inherit (cfg)
59+
consoleMode
60+
graceful
61+
editor
62+
rebootForBitlocker
63+
;
6364

64-
inherit (efi) efiSysMountPoint canTouchEfiVariables;
65+
inherit (efi) efiSysMountPoint canTouchEfiVariables;
6566

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;
6869

69-
nixosDir = "/EFI/nixos";
70+
nixosDir = "/EFI/nixos";
7071

71-
inherit (config.system.nixos) distroName;
72+
inherit (config.system.nixos) distroName;
7273

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+
'';
7684

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+
};
105103
};
106104

107105
finalSystemdBootBuilder = pkgs.writeScript "install-systemd-boot.sh" ''

0 commit comments

Comments
 (0)