Skip to content

Commit 8f78cb0

Browse files
authored
replaceVarsWith: fix checkPhase with dir set (#365347)
2 parents ebb8123 + e58e0c1 commit 8f78cb0

22 files changed

Lines changed: 287 additions & 244 deletions

File tree

nixos/modules/programs/command-not-found/command-not-found.nix

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@
1212

1313
let
1414
cfg = config.programs.command-not-found;
15-
commandNotFound = pkgs.substituteAll {
15+
commandNotFound = pkgs.replaceVarsWith {
1616
name = "command-not-found";
1717
dir = "bin";
1818
src = ./command-not-found.pl;
1919
isExecutable = true;
20-
inherit (cfg) dbPath;
21-
perl = pkgs.perl.withPackages (p: [
22-
p.DBDSQLite
23-
p.StringShellQuote
24-
]);
20+
replacements = {
21+
inherit (cfg) dbPath;
22+
perl = pkgs.perl.withPackages (p: [
23+
p.DBDSQLite
24+
p.StringShellQuote
25+
]);
26+
};
2527
};
2628

2729
in

nixos/modules/services/networking/hylafax/systemd.nix

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,27 +49,31 @@ let
4949
preferLocalBuild = true;
5050
} ''mkdir --parents "$out/" ${concatStringsSep "\n" (mapModems mkLine)}'';
5151

52-
setupSpoolScript = pkgs.substituteAll {
52+
setupSpoolScript = pkgs.replaceVarsWith {
5353
name = "hylafax-setup-spool.sh";
5454
src = ./spool.sh;
5555
isExecutable = true;
56-
faxuser = "uucp";
57-
faxgroup = "uucp";
58-
lockPath = "/var/lock";
59-
inherit globalConfigPath modemConfigPath;
60-
inherit (cfg) sendmailPath spoolAreaPath userAccessFile;
61-
inherit (pkgs) hylafaxplus runtimeShell;
56+
replacements = {
57+
faxuser = "uucp";
58+
faxgroup = "uucp";
59+
lockPath = "/var/lock";
60+
inherit globalConfigPath modemConfigPath;
61+
inherit (cfg) spoolAreaPath userAccessFile;
62+
inherit (pkgs) hylafaxplus runtimeShell;
63+
};
6264
};
6365

64-
waitFaxqScript = pkgs.substituteAll {
66+
waitFaxqScript = pkgs.replaceVarsWith {
6567
# This script checks the modems status files
6668
# and waits until all modems report readiness.
6769
name = "hylafax-faxq-wait-start.sh";
6870
src = ./faxq-wait.sh;
6971
isExecutable = true;
70-
timeoutSec = toString 10;
71-
inherit (cfg) spoolAreaPath;
72-
inherit (pkgs) runtimeShell;
72+
replacements = {
73+
timeoutSec = toString 10;
74+
inherit (cfg) spoolAreaPath;
75+
inherit (pkgs) runtimeShell;
76+
};
7377
};
7478

7579
sockets.hylafax-hfaxd = {

nixos/modules/services/web-apps/kasmweb/default.nix

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -140,31 +140,33 @@ in
140140
serviceConfig = {
141141
Type = "oneshot";
142142
TimeoutStartSec = 300;
143-
ExecStart = pkgs.substituteAll {
143+
ExecStart = pkgs.replaceVarsWith {
144144
src = ./initialize_kasmweb.sh;
145145
isExecutable = true;
146-
binPath = lib.makeBinPath [
147-
pkgs.docker
148-
pkgs.openssl
149-
pkgs.gnused
150-
pkgs.yq-go
151-
];
152-
runtimeShell = pkgs.runtimeShell;
153-
kasmweb = pkgs.kasmweb;
154-
postgresUser = "postgres";
155-
postgresPassword = "postgres";
156-
inherit (cfg)
157-
datastorePath
158-
sslCertificate
159-
sslCertificateKey
160-
redisPassword
161-
networkSubnet
162-
defaultUserPassword
163-
defaultAdminPassword
164-
defaultManagerToken
165-
defaultRegistrationToken
166-
defaultGuacToken
167-
;
146+
replacements = {
147+
binPath = lib.makeBinPath [
148+
pkgs.docker
149+
pkgs.openssl
150+
pkgs.gnused
151+
pkgs.yq-go
152+
];
153+
runtimeShell = pkgs.runtimeShell;
154+
kasmweb = pkgs.kasmweb;
155+
postgresUser = "postgres";
156+
postgresPassword = "postgres";
157+
inherit (cfg)
158+
datastorePath
159+
sslCertificate
160+
sslCertificateKey
161+
redisPassword
162+
networkSubnet
163+
defaultUserPassword
164+
defaultAdminPassword
165+
defaultManagerToken
166+
defaultRegistrationToken
167+
defaultGuacToken
168+
;
169+
};
168170
};
169171
};
170172
};

nixos/modules/system/boot/loader/generations-dir/generations-dir-builder.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
shopt -s nullglob
44

5-
export PATH=/empty
6-
for i in @path@; do PATH=$PATH:$i/bin; done
5+
export PATH=/empty:@path@
76

87
default=$1
98
if test -z "$1"; then

nixos/modules/system/boot/loader/generations-dir/generations-dir.nix

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ with lib;
44

55
let
66

7-
generationsDirBuilder = pkgs.substituteAll {
7+
generationsDirBuilder = pkgs.replaceVarsWith {
88
src = ./generations-dir-builder.sh;
99
isExecutable = true;
10-
inherit (pkgs) bash;
11-
path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep];
12-
inherit (config.boot.loader.generationsDir) copyKernels;
10+
replacements = {
11+
inherit (pkgs) bash;
12+
path = lib.makeBinPath [pkgs.coreutils pkgs.gnused pkgs.gnugrep];
13+
inherit (config.boot.loader.generationsDir) copyKernels;
14+
};
1315
};
1416

1517
in
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
{ pkgs }:
1+
{ lib, pkgs }:
22

3-
pkgs.substituteAll {
3+
pkgs.replaceVarsWith {
44
src = ./extlinux-conf-builder.sh;
55
isExecutable = true;
6-
path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep];
7-
inherit (pkgs) bash;
6+
replacements = {
7+
path = lib.makeBinPath [pkgs.coreutils pkgs.gnused pkgs.gnugrep];
8+
inherit (pkgs) bash;
9+
};
810
}

nixos/modules/system/boot/loader/generic-extlinux-compatible/extlinux-conf-builder.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
shopt -s nullglob
44

5-
export PATH=/empty
6-
for i in @path@; do PATH=$PATH:$i/bin; done
5+
export PATH=/empty:@path@
76

87
usage() {
98
echo "usage: $0 -t <timeout> -c <path-to-default-configuration> [-d <boot-dir>] [-g <num-generations>] [-n <dtbName>] [-r]" >&2

nixos/modules/system/boot/loader/init-script/init-script-builder.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
shopt -s nullglob
44

5-
export PATH=/empty
6-
for i in @path@; do PATH=$PATH:$i/bin; done
5+
export PATH=/empty:@path@
76

87
if test $# -ne 1; then
98
echo "Usage: init-script-builder.sh DEFAULT-CONFIG"

nixos/modules/system/boot/loader/init-script/init-script.nix

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@ with lib;
99

1010
let
1111

12-
initScriptBuilder = pkgs.substituteAll {
12+
initScriptBuilder = pkgs.replaceVarsWith {
1313
src = ./init-script-builder.sh;
1414
isExecutable = true;
15-
inherit (pkgs) bash;
16-
inherit (config.system.nixos) distroName;
17-
path = [
18-
pkgs.coreutils
19-
pkgs.gnused
20-
pkgs.gnugrep
21-
];
15+
replacements = {
16+
inherit (pkgs) bash;
17+
inherit (config.system.nixos) distroName;
18+
path = lib.makeBinPath [
19+
pkgs.coreutils
20+
pkgs.gnused
21+
pkgs.gnugrep
22+
];
23+
};
2224
};
2325

2426
in

nixos/modules/system/boot/stage-1.nix

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,8 @@ let
289289

290290
# The init script of boot stage 1 (loading kernel modules for
291291
# mounting the root FS).
292-
bootStage1 = pkgs.substituteAll {
292+
bootStage1 = pkgs.replaceVarsWith {
293293
src = ./stage-1-init.sh;
294-
295-
shell = "${extraUtils}/bin/ash";
296-
297294
isExecutable = true;
298295

299296
postInstall = ''
@@ -304,35 +301,39 @@ let
304301
${pkgs.buildPackages.busybox}/bin/ash -n $target
305302
'';
306303

307-
inherit linkUnits udevRules extraUtils;
304+
replacements = {
305+
shell = "${extraUtils}/bin/ash";
308306

309-
inherit (config.boot) resumeDevice;
307+
inherit linkUnits udevRules extraUtils;
310308

311-
inherit (config.system.nixos) distroName;
309+
inherit (config.boot) resumeDevice;
312310

313-
inherit (config.system.build) earlyMountScript;
311+
inherit (config.system.nixos) distroName;
314312

315-
inherit (config.boot.initrd) checkJournalingFS verbose
316-
preLVMCommands preDeviceCommands postDeviceCommands postResumeCommands postMountCommands preFailCommands kernelModules;
313+
inherit (config.system.build) earlyMountScript;
317314

318-
resumeDevices = map (sd: if sd ? device then sd.device else "/dev/disk/by-label/${sd.label}")
319-
(filter (sd: hasPrefix "/dev/" sd.device && !sd.randomEncryption.enable
320-
# Don't include zram devices
321-
&& !(hasPrefix "/dev/zram" sd.device)
322-
) config.swapDevices);
315+
inherit (config.boot.initrd) checkJournalingFS verbose
316+
preLVMCommands preDeviceCommands postDeviceCommands postResumeCommands postMountCommands preFailCommands kernelModules;
323317

324-
fsInfo =
325-
let f = fs: [ fs.mountPoint (if fs.device != null then fs.device else "/dev/disk/by-label/${fs.label}") fs.fsType (builtins.concatStringsSep "," fs.options) ];
326-
in pkgs.writeText "initrd-fsinfo" (concatStringsSep "\n" (concatMap f fileSystems));
318+
resumeDevices = map (sd: if sd ? device then sd.device else "/dev/disk/by-label/${sd.label}")
319+
(filter (sd: hasPrefix "/dev/" sd.device && !sd.randomEncryption.enable
320+
# Don't include zram devices
321+
&& !(hasPrefix "/dev/zram" sd.device)
322+
) config.swapDevices);
327323

328-
setHostId = optionalString (config.networking.hostId != null) ''
329-
hi="${config.networking.hostId}"
330-
${if pkgs.stdenv.hostPlatform.isBigEndian then ''
331-
echo -ne "\x''${hi:0:2}\x''${hi:2:2}\x''${hi:4:2}\x''${hi:6:2}" > /etc/hostid
332-
'' else ''
333-
echo -ne "\x''${hi:6:2}\x''${hi:4:2}\x''${hi:2:2}\x''${hi:0:2}" > /etc/hostid
334-
''}
335-
'';
324+
fsInfo =
325+
let f = fs: [ fs.mountPoint (if fs.device != null then fs.device else "/dev/disk/by-label/${fs.label}") fs.fsType (builtins.concatStringsSep "," fs.options) ];
326+
in pkgs.writeText "initrd-fsinfo" (concatStringsSep "\n" (concatMap f fileSystems));
327+
328+
setHostId = optionalString (config.networking.hostId != null) ''
329+
hi="${config.networking.hostId}"
330+
${if pkgs.stdenv.hostPlatform.isBigEndian then ''
331+
echo -ne "\x''${hi:0:2}\x''${hi:2:2}\x''${hi:4:2}\x''${hi:6:2}" > /etc/hostid
332+
'' else ''
333+
echo -ne "\x''${hi:6:2}\x''${hi:4:2}\x''${hi:2:2}\x''${hi:0:2}" > /etc/hostid
334+
''}
335+
'';
336+
};
336337
};
337338

338339

0 commit comments

Comments
 (0)