Skip to content

Commit

Permalink
writeTextFile,writeShellApplication: Allow setting extra arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
9999years committed Feb 2, 2024
1 parent a647669 commit 863786b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkgs/build-support/trivial-builders/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,21 @@ rec {
, meta ? { }
, allowSubstitutes ? false
, preferLocalBuild ? true
, derivationArgs ? { } # Extra arguments to pass to `stdenv.mkDerivation`
}:
let
matches = builtins.match "/bin/([^/]+)" destination;
in
runCommand name
{
({
inherit text executable checkPhase allowSubstitutes preferLocalBuild;
passAsFile = [ "text" ];
passAsFile = [ "text" ]
++ derivationArgs.passAsFile or [ ];
meta = lib.optionalAttrs (executable && matches != null)
{
mainProgram = lib.head matches;
} // meta;
}
} // meta // derivationArgs.meta or {};
} // removeAttrs derivationArgs [ "passAsFile" "meta" ])
''
target=$out${lib.escapeShellArg destination}
mkdir -p "$(dirname "$target")"
Expand Down Expand Up @@ -274,9 +276,10 @@ rec {
, checkPhase ? null
, excludeShellChecks ? [ ]
, bashOptions ? [ "errexit" "nounset" "pipefail" ]
, derivationArgs ? { } # Extra arguments to pass to `stdenv.mkDerivation`
}:
writeTextFile {
inherit name meta;
inherit name meta derivationArgs;
executable = true;
destination = "/bin/${name}";
allowSubstitutes = true;
Expand Down

0 comments on commit 863786b

Please sign in to comment.