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:
parent
0cde1dc524
commit
b993c2113c
@ -14,6 +14,8 @@ let
|
|||||||
in stdenv.mkDerivation (args // {
|
in stdenv.mkDerivation (args // {
|
||||||
inherit cargoDeps rustRegistry cargoUpdateHook;
|
inherit cargoDeps rustRegistry cargoUpdateHook;
|
||||||
|
|
||||||
|
patchRegistryDeps = ./patch-registry-deps;
|
||||||
|
|
||||||
buildInputs = [ git cargo rustc ] ++ buildInputs;
|
buildInputs = [ git cargo rustc ] ++ buildInputs;
|
||||||
|
|
||||||
configurePhase = args.configurePhase or "true";
|
configurePhase = args.configurePhase or "true";
|
||||||
@ -41,14 +43,20 @@ in stdenv.mkDerivation (args // {
|
|||||||
)
|
)
|
||||||
'' + (args.postUnpack or "");
|
'' + (args.postUnpack or "");
|
||||||
|
|
||||||
# TODO: Probably not the best way to do this, but it should work for now
|
|
||||||
prePatch = ''
|
prePatch = ''
|
||||||
for dir in ../deps/registry/src/*/pkg-config-*; do
|
# Patch registry dependencies, using the scripts in $patchRegistryDeps
|
||||||
[ -d "$dir" ] || continue
|
(
|
||||||
|
cd ../deps/registry/src/*
|
||||||
|
|
||||||
substituteInPlace "$dir/src/lib.rs" \
|
set -euo pipefail
|
||||||
--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 "");
|
'' + (args.prePatch or "");
|
||||||
|
|
||||||
buildPhase = args.buildPhase or ''
|
buildPhase = args.buildPhase or ''
|
||||||
|
8
pkgs/build-support/rust/patch-registry-deps/pkg-config
Normal file
8
pkgs/build-support/rust/patch-registry-deps/pkg-config
Normal 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
|
Loading…
Reference in New Issue
Block a user