Make sure patched dependencies are left intact

Fixes #170
This commit is contained in:
Nicolas Mattia 2021-05-06 17:36:59 +02:00
parent 32e3ba39d9
commit a3f40fe42c
3 changed files with 38 additions and 8 deletions

22
lib.nix
View file

@ -196,14 +196,6 @@ rec
${lib.optionalString (! isNull cargoconfig) "cp ${config} $out/.cargo/config"} ${lib.optionalString (! isNull cargoconfig) "cp ${config} $out/.cargo/config"}
cp ${cargolock'} $out/Cargo.lock cp ${cargolock'} $out/Cargo.lock
for p in $copySources; do
echo "Copying patched source $p to $out..."
# Create all the directories but $p itself, so `cp -R` does the
# right thing below
mkdir -p "$out/$(dirname "$p")"
cp --no-preserve=mode -R "$copySourcesFrom/$p" "$out/$p"
done
for tuple in $cargotomlss; do for tuple in $cargotomlss; do
member="''${tuple%%:*}" member="''${tuple%%:*}"
cargotoml="''${tuple##*:}" cargotoml="''${tuple##*:}"
@ -226,6 +218,20 @@ rec
echo 'fn main(){}' > build.rs echo 'fn main(){}' > build.rs
popd > /dev/null popd > /dev/null
done done
# Copy all the "patched" sources which are used by dependencies.
# This needs to be done after the creation of the dummy to make
# sure the dummy source files do not tramp on the patch
# dependencies.
for p in $copySources; do
echo "Copying patched source $p to $out..."
mkdir -p "$out/$p"
chmod -R +w "$out/$p"
echo copying "$copySourcesFrom/$p"/ to "$out/$p"
cp --no-preserve=mode -R "$copySourcesFrom/$p"/* "$out/$p"
done
''; '';
mkPackages = cargolock: mkPackages = cargolock:

View file

@ -1,4 +1,16 @@
{ {
"agent-rs": {
"branch": "paulliu/add-cargo-lock",
"description": "A collection of libraries and tools for building software around the Internet Computer, in Rust.",
"homepage": "https://sdk.dfinity.org/",
"owner": "ninegua",
"repo": "agent-rs",
"rev": "4a22e590516bc79ec3c75a320f7941e7762ea098",
"sha256": "0sacddc34nlfgldqghlwchgzjki177h5dsgpmdv70cm8hfy0sg7l",
"type": "tarball",
"url": "https://github.com/ninegua/agent-rs/archive/4a22e590516bc79ec3c75a320f7941e7762ea098.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
},
"cargo": { "cargo": {
"branch": "nm/canonicalize-path-args", "branch": "nm/canonicalize-path-args",
"description": "The Rust package manager", "description": "The Rust package manager",

View file

@ -210,6 +210,18 @@ let
talent-plan-3 = naersk.buildPackage "${sources.talent-plan}/rust/projects/project-3"; talent-plan-3 = naersk.buildPackage "${sources.talent-plan}/rust/projects/project-3";
rustlings = naersk.buildPackage sources.rustlings; rustlings = naersk.buildPackage sources.rustlings;
agent-rs = naersk.buildPackage {
doCheck = true;
src = sources.agent-rs;
buildInputs =
[
pkgs.openssl
pkgs.pkg-config
pkgs.perl
] ++ pkgs.lib.optional pkgs.stdenv.isDarwin pkgs.libiconv;
};
}; };
in in
fastTests fastTests