3
0
Fork 0
forked from mirrors/nixpkgs

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.
This commit is contained in:
Ricardo M. Correia 2015-04-23 16:37:52 +02:00
parent 0cde1dc524
commit b993c2113c
2 changed files with 22 additions and 6 deletions

View file

@ -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/*
substituteInPlace "$dir/src/lib.rs" \
--replace '"/usr"' '"/nix/store/"'
done
set -euo pipefail
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 ''

View file

@ -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