nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3}:
4{
5 # If there's a need to patch external dependencies managed by Bazel
6 # one option is to configure patches on Bazel level. Bazel doesn't
7 # allow patches to be in absolute paths so this helper will produce
8 # sources patch that adds given file to given location
9 addFilePatch =
10 {
11 path,
12 file,
13 }:
14 stdenv.mkDerivation {
15 name = "add_file.patch";
16 dontUnpack = true;
17 buildPhase = ''
18 mkdir -p $(dirname "${path}")
19 cp ${file} "${path}"
20 diff -u /dev/null "${path}" >result.patch || true # diff exit code is non-zero if there's a diff
21 '';
22 installPhase = "cp result.patch $out";
23 };
24}