diff options
author | Frederik Rietdijk <fridh@fridh.nl> | 2019-05-12 19:59:09 +0200 |
---|---|---|
committer | Frederik Rietdijk <fridh@fridh.nl> | 2019-05-12 19:59:09 +0200 |
commit | ef0dbef7f15f962f9fedfd86563664bc95e6e2f9 (patch) | |
tree | 87b6e6e0dbe7e39cb5b9ca473afbc7fd9147718a /pkgs/build-support | |
parent | e8f4ad0169e30d18a80a58ab714757d15173ee1a (diff) | |
parent | e9b7e01828049d9998e2e4fde3600dd51985dbfc (diff) | |
download | nixlib-ef0dbef7f15f962f9fedfd86563664bc95e6e2f9.tar nixlib-ef0dbef7f15f962f9fedfd86563664bc95e6e2f9.tar.gz nixlib-ef0dbef7f15f962f9fedfd86563664bc95e6e2f9.tar.bz2 nixlib-ef0dbef7f15f962f9fedfd86563664bc95e6e2f9.tar.lz nixlib-ef0dbef7f15f962f9fedfd86563664bc95e6e2f9.tar.xz nixlib-ef0dbef7f15f962f9fedfd86563664bc95e6e2f9.tar.zst nixlib-ef0dbef7f15f962f9fedfd86563664bc95e6e2f9.zip |
Merge master into staging-next
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/fetchpatch/default.nix | 12 | ||||
-rw-r--r-- | pkgs/build-support/trivial-builders.nix | 38 |
2 files changed, 41 insertions, 9 deletions
diff --git a/pkgs/build-support/fetchpatch/default.nix b/pkgs/build-support/fetchpatch/default.nix index 89d72f512f7f..2fb32b2324f2 100644 --- a/pkgs/build-support/fetchpatch/default.nix +++ b/pkgs/build-support/fetchpatch/default.nix @@ -5,6 +5,10 @@ # stripLen acts as the -p parameter when applying a patch. { lib, fetchurl, buildPackages }: +let + # 0.3.4 would change hashes: https://github.com/NixOS/nixpkgs/issues/25154 + patchutils = buildPackages.patchutils_0_3_3; +in { stripLen ? 0, extraPrefix ? null, excludes ? [], includes ? [], revert ? false, ... }@args: fetchurl ({ @@ -14,10 +18,10 @@ fetchurl ({ echo "error: Fetched patch file '$out' is empty!" 1>&2 exit 1 fi - "${buildPackages.patchutils}/bin/lsdiff" "$out" \ + "${patchutils}/bin/lsdiff" "$out" \ | sort -u | sed -e 's/[*?]/\\&/g' \ | xargs -I{} \ - "${buildPackages.patchutils}/bin/filterdiff" \ + "${patchutils}/bin/filterdiff" \ --include={} \ --strip=${toString stripLen} \ ${lib.optionalString (extraPrefix != null) '' @@ -32,7 +36,7 @@ fetchurl ({ cat "$out" 1>&2 exit 1 fi - ${buildPackages.patchutils}/bin/filterdiff \ + ${patchutils}/bin/filterdiff \ -p1 \ ${builtins.toString (builtins.map (x: "-x ${lib.escapeShellArg x}") excludes)} \ ${builtins.toString (builtins.map (x: "-i ${lib.escapeShellArg x}") includes)} \ @@ -46,7 +50,7 @@ fetchurl ({ exit 1 fi '' + lib.optionalString revert '' - ${buildPackages.patchutils}/bin/interdiff "$out" /dev/null > "$tmpfile" + ${patchutils}/bin/interdiff "$out" /dev/null > "$tmpfile" mv "$tmpfile" "$out" '' + (args.postFetch or ""); meta.broken = excludes != [] && includes != []; diff --git a/pkgs/build-support/trivial-builders.nix b/pkgs/build-support/trivial-builders.nix index e498417adf01..f56ce7bb87d0 100644 --- a/pkgs/build-support/trivial-builders.nix +++ b/pkgs/build-support/trivial-builders.nix @@ -79,7 +79,6 @@ rec { (test -n "$executable" && chmod +x "$n") || true ''; - /* * Writes a text file to nix store with no optional parameters available. * @@ -92,6 +91,7 @@ rec { * */ writeText = name: text: writeTextFile {inherit name text;}; + /* * Writes a text file to nix store in a specific directory with no * optional parameters available. Name passed is the destination. @@ -105,6 +105,7 @@ rec { * */ writeTextDir = name: text: writeTextFile {inherit name text; destination = "/${name}";}; + /* * Writes a text file to /nix/store/<store path> and marks the file as executable. * @@ -117,13 +118,14 @@ rec { * */ writeScript = name: text: writeTextFile {inherit name text; executable = true;}; + /* * Writes a text file to /nix/store/<store path>/bin/<name> and * marks the file as executable. * * Example: * # Writes my-file to /nix/store/<store path>/bin/my-file and makes executable. - * writeScript "my-file" + * writeScriptBin "my-file" * '' * Contents of File * ''; @@ -132,12 +134,38 @@ rec { writeScriptBin = name: text: writeTextFile {inherit name text; executable = true; destination = "/bin/${name}";}; /* - * Writes a Shell script and check its syntax. Automatically includes interpreter - * above the contents passed. + * Similar to writeScript. Writes a Shell script and checks its syntax. + * Automatically includes interpreter above the contents passed. + * + * Example: + * # Writes my-file to /nix/store/<store path>/my-file and makes executable. + * writeShellScript "my-file" + * '' + * Contents of File + * ''; + * + */ + writeShellScript = name: text: + writeTextFile { + inherit name; + executable = true; + text = '' + #!${runtimeShell} + ${text} + ''; + checkPhase = '' + ${stdenv.shell} -n $out + ''; + }; + + /* + * Similar to writeShellScript and writeScriptBin. + * Writes an executable Shell script to /nix/store/<store path>/bin/<name> and checks its syntax. + * Automatically includes interpreter above the contents passed. * * Example: * # Writes my-file to /nix/store/<store path>/bin/my-file and makes executable. - * writeScript "my-file" + * writeShellScriptBin "my-file" * '' * Contents of File * ''; |