diff options
author | Ricardo M. Correia <rcorreia@wizy.org> | 2015-04-23 16:37:52 +0200 |
---|---|---|
committer | Ricardo M. Correia <rcorreia@wizy.org> | 2015-04-23 16:41:52 +0200 |
commit | b993c2113c8191ca9b454abfc79d02196b6a2bd0 (patch) | |
tree | 3ce4787ccdeac65ff30fd472bb0cb71250f9a459 /pkgs/build-support/rust | |
parent | 0cde1dc52425f12be6f7311737abe98813e43c29 (diff) | |
download | nixlib-b993c2113c8191ca9b454abfc79d02196b6a2bd0.tar nixlib-b993c2113c8191ca9b454abfc79d02196b6a2bd0.tar.gz nixlib-b993c2113c8191ca9b454abfc79d02196b6a2bd0.tar.bz2 nixlib-b993c2113c8191ca9b454abfc79d02196b6a2bd0.tar.lz nixlib-b993c2113c8191ca9b454abfc79d02196b6a2bd0.tar.xz nixlib-b993c2113c8191ca9b454abfc79d02196b6a2bd0.tar.zst nixlib-b993c2113c8191ca9b454abfc79d02196b6a2bd0.zip |
buildRustPackage: Add a mechanism to patch registry deps
... in a more generic way. With this commit, if you need to patch a registry package to make it work with Nix, you just need to add a script to patch-registry-deps in the same style as the `pkg-config` script.
Diffstat (limited to 'pkgs/build-support/rust')
-rw-r--r-- | pkgs/build-support/rust/default.nix | 20 | ||||
-rw-r--r-- | pkgs/build-support/rust/patch-registry-deps/pkg-config | 8 |
2 files changed, 22 insertions, 6 deletions
diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix index 37175114d81e..2a890a0d232b 100644 --- a/pkgs/build-support/rust/default.nix +++ b/pkgs/build-support/rust/default.nix @@ -14,6 +14,8 @@ let in stdenv.mkDerivation (args // { inherit cargoDeps rustRegistry cargoUpdateHook; + patchRegistryDeps = ./patch-registry-deps; + buildInputs = [ git cargo rustc ] ++ buildInputs; configurePhase = args.configurePhase or "true"; @@ -41,14 +43,20 @@ in stdenv.mkDerivation (args // { ) '' + (args.postUnpack or ""); - # TODO: Probably not the best way to do this, but it should work for now prePatch = '' - for dir in ../deps/registry/src/*/pkg-config-*; do - [ -d "$dir" ] || continue + # Patch registry dependencies, using the scripts in $patchRegistryDeps + ( + cd ../deps/registry/src/* + + set -euo pipefail - substituteInPlace "$dir/src/lib.rs" \ - --replace '"/usr"' '"/nix/store/"' - done + for script in $patchRegistryDeps/*; do + # Run in a subshell so that directory changes and shell options don't + # affect any following commands + + ( . $script) + done + ) '' + (args.prePatch or ""); buildPhase = args.buildPhase or '' diff --git a/pkgs/build-support/rust/patch-registry-deps/pkg-config b/pkgs/build-support/rust/patch-registry-deps/pkg-config new file mode 100644 index 000000000000..2acf489851e9 --- /dev/null +++ b/pkgs/build-support/rust/patch-registry-deps/pkg-config @@ -0,0 +1,8 @@ +for dir in pkg-config-*; do + [ -d "$dir" ] || continue + + echo "Patching pkg-config registry dep" + + substituteInPlace "$dir/src/lib.rs" \ + --replace '"/usr"' '"/nix/store/"' +done |