writeTextFile,writeShellApplication: Allow setting extra arguments
This commit is contained in:
parent
a64766913f
commit
863786b98b
1 changed files with 8 additions and 5 deletions
|
@ -152,19 +152,21 @@ rec {
|
||||||
, meta ? { }
|
, meta ? { }
|
||||||
, allowSubstitutes ? false
|
, allowSubstitutes ? false
|
||||||
, preferLocalBuild ? true
|
, preferLocalBuild ? true
|
||||||
|
, derivationArgs ? { } # Extra arguments to pass to `stdenv.mkDerivation`
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
matches = builtins.match "/bin/([^/]+)" destination;
|
matches = builtins.match "/bin/([^/]+)" destination;
|
||||||
in
|
in
|
||||||
runCommand name
|
runCommand name
|
||||||
{
|
({
|
||||||
inherit text executable checkPhase allowSubstitutes preferLocalBuild;
|
inherit text executable checkPhase allowSubstitutes preferLocalBuild;
|
||||||
passAsFile = [ "text" ];
|
passAsFile = [ "text" ]
|
||||||
|
++ derivationArgs.passAsFile or [ ];
|
||||||
meta = lib.optionalAttrs (executable && matches != null)
|
meta = lib.optionalAttrs (executable && matches != null)
|
||||||
{
|
{
|
||||||
mainProgram = lib.head matches;
|
mainProgram = lib.head matches;
|
||||||
} // meta;
|
} // meta // derivationArgs.meta or {};
|
||||||
}
|
} // removeAttrs derivationArgs [ "passAsFile" "meta" ])
|
||||||
''
|
''
|
||||||
target=$out${lib.escapeShellArg destination}
|
target=$out${lib.escapeShellArg destination}
|
||||||
mkdir -p "$(dirname "$target")"
|
mkdir -p "$(dirname "$target")"
|
||||||
|
@ -274,9 +276,10 @@ rec {
|
||||||
, checkPhase ? null
|
, checkPhase ? null
|
||||||
, excludeShellChecks ? [ ]
|
, excludeShellChecks ? [ ]
|
||||||
, bashOptions ? [ "errexit" "nounset" "pipefail" ]
|
, bashOptions ? [ "errexit" "nounset" "pipefail" ]
|
||||||
|
, derivationArgs ? { } # Extra arguments to pass to `stdenv.mkDerivation`
|
||||||
}:
|
}:
|
||||||
writeTextFile {
|
writeTextFile {
|
||||||
inherit name meta;
|
inherit name meta derivationArgs;
|
||||||
executable = true;
|
executable = true;
|
||||||
destination = "/bin/${name}";
|
destination = "/bin/${name}";
|
||||||
allowSubstitutes = true;
|
allowSubstitutes = true;
|
||||||
|
|
Loading…
Reference in a new issue