mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-10-30 14:11:21 +00:00
stdenv/generic: introduce shellDryRun
Add `shellDryRun` to the generic stdenv and substitute it for uses of `${stdenv.shell} -n`. The point of this layer of abstraction is to add the flag `-O extglob`, which resolves #126344 in a more direct way.
This commit is contained in:
parent
4aaf4c256b
commit
f2065d81ad
@ -55,8 +55,8 @@ let
|
||||
substituteInPlace $out/dry-activate --subst-var out
|
||||
chmod u+x $out/activate $out/dry-activate
|
||||
unset activationScript dryActivationScript
|
||||
${pkgs.stdenv.shell} -n $out/activate
|
||||
${pkgs.stdenv.shell} -n $out/dry-activate
|
||||
${pkgs.stdenv.shellDryRun} $out/activate
|
||||
${pkgs.stdenv.shellDryRun} $out/dry-activate
|
||||
|
||||
cp ${config.system.build.bootStage2} $out/init
|
||||
substituteInPlace $out/init --subst-var-by systemConfig $out
|
||||
|
@ -210,20 +210,14 @@ let
|
||||
makeJobScript = name: text:
|
||||
let
|
||||
scriptName = replaceChars [ "\\" "@" ] [ "-" "_" ] (shellEscape name);
|
||||
out = pkgs.writeTextFile {
|
||||
out = (pkgs.writeShellScriptBin scriptName ''
|
||||
set -e
|
||||
${text}
|
||||
'').overrideAttrs (_: {
|
||||
# The derivation name is different from the script file name
|
||||
# to keep the script file name short to avoid cluttering logs.
|
||||
name = "unit-script-${scriptName}";
|
||||
executable = true;
|
||||
destination = "/bin/${scriptName}";
|
||||
text = ''
|
||||
#!${pkgs.runtimeShell} -e
|
||||
${text}
|
||||
'';
|
||||
checkPhase = ''
|
||||
${pkgs.stdenv.shell} -n "$out/bin/${scriptName}"
|
||||
'';
|
||||
};
|
||||
});
|
||||
in "${out}/bin/${scriptName}";
|
||||
|
||||
unitConfig = { config, options, ... }: {
|
||||
|
@ -219,7 +219,7 @@ rec {
|
||||
${text}
|
||||
'';
|
||||
checkPhase = ''
|
||||
${stdenv.shell} -n $out
|
||||
${stdenv.shellDryRun} $out
|
||||
'';
|
||||
};
|
||||
|
||||
@ -246,7 +246,7 @@ rec {
|
||||
${text}
|
||||
'';
|
||||
checkPhase = ''
|
||||
${stdenv.shell} -n $out/bin/${name}
|
||||
${stdenv.shellDryRun} $out/bin/${name}
|
||||
'';
|
||||
};
|
||||
|
||||
@ -295,7 +295,7 @@ rec {
|
||||
checkPhase =
|
||||
if checkPhase == null then ''
|
||||
runHook preCheck
|
||||
${stdenv.shell} -n $out/bin/${name}
|
||||
${stdenv.shellDryRun} $out/bin/${name}
|
||||
${shellcheck}/bin/shellcheck $out/bin/${name}
|
||||
runHook postCheck
|
||||
''
|
||||
|
@ -12,7 +12,7 @@
|
||||
, bullet
|
||||
, curl
|
||||
, gettext
|
||||
, writeTextFile
|
||||
, writeShellScriptBin
|
||||
|
||||
, data ? fetchsvn {
|
||||
url = "svn://svn.code.sf.net/p/vdrift/code/vdrift-data";
|
||||
@ -54,21 +54,15 @@ let
|
||||
};
|
||||
};
|
||||
wrappedName = "vdrift-${version}-with-data-${toString data.rev}";
|
||||
in writeTextFile {
|
||||
in
|
||||
(writeShellScriptBin "vdrift" ''
|
||||
export VDRIFT_DATA_DIRECTORY="${data}"
|
||||
exec ${bin}/bin/vdrift "$@"
|
||||
'').overrideAttrs (_: {
|
||||
name = wrappedName;
|
||||
text = ''
|
||||
export VDRIFT_DATA_DIRECTORY="${data}"
|
||||
exec ${bin}/bin/vdrift "$@"
|
||||
'';
|
||||
destination = "/bin/vdrift";
|
||||
executable = true;
|
||||
checkPhase = ''
|
||||
${stdenv.shell} -n $out/bin/vdrift
|
||||
'';
|
||||
} // {
|
||||
meta = bin.meta // {
|
||||
hydraPlatforms = [ ];
|
||||
};
|
||||
unwrapped = bin;
|
||||
inherit bin data;
|
||||
}
|
||||
})
|
||||
|
@ -112,7 +112,7 @@ let
|
||||
# are absolute unless we go out of our way to make them relative (like with CF)
|
||||
# TODO: This really wants to be in stdenv/darwin but we don't have hostPlatform
|
||||
# there (yet?) so it goes here until then.
|
||||
preHook = preHook+ lib.optionalString buildPlatform.isDarwin ''
|
||||
preHook = preHook + lib.optionalString buildPlatform.isDarwin ''
|
||||
export NIX_DONT_SET_RPATH_FOR_BUILD=1
|
||||
'' + lib.optionalString (hostPlatform.isDarwin || (hostPlatform.parsed.kernel.execFormat != lib.systems.parse.execFormats.elf && hostPlatform.parsed.kernel.execFormat != lib.systems.parse.execFormats.macho)) ''
|
||||
export NIX_DONT_SET_RPATH=1
|
||||
@ -168,6 +168,11 @@ let
|
||||
inherit overrides;
|
||||
|
||||
inherit cc hasCC;
|
||||
|
||||
# Convenience for doing some very basic shell syntax checking by parsing a script
|
||||
# without running any commands. Because this will also skip `shopt -s extglob`
|
||||
# commands and extglob affects the Bash parser, we enable extglob always.
|
||||
shellDryRun = "${stdenv.shell} -n -O extglob";
|
||||
}
|
||||
|
||||
# Propagate any extra attributes. For instance, we use this to
|
||||
|
Loading…
Reference in New Issue
Block a user