Skip to content

Commit

Permalink
Merge pull request #97 from yusdacra/rust/crane-fixes
Browse files Browse the repository at this point in the history
fix(rust): dont use hardcoded CARGO_HOME to /build
  • Loading branch information
DavHau authored Mar 7, 2022
2 parents 68478d0 + 09552b2 commit 7641236
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 1 addition & 2 deletions src/builders/rust/build-rust-package/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,9 @@ let

cargoVendorDir = "../nix-vendor";

CARGO_HOME = "/build/.cargo-home";

postUnpack = ''
ln -s ${vendorDir} ./nix-vendor
export CARGO_HOME=$(pwd)/.cargo_home
'';

preConfigure = ''
Expand Down
7 changes: 4 additions & 3 deletions src/builders/rust/crane/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,16 @@ let
let
src = utils.getRootSource pname version;
cargoVendorDir = vendoring.vendorDependencies pname version;
postUnpack = ''
export CARGO_HOME=$(pwd)/.cargo_home
'';
preConfigure = ''
${vendoring.writeGitVendorEntries "nix-sources"}
'';
# The deps-only derivation will use this as a prefix to the `pname`
depsNameSuffix = "-deps";
# Set CARGO_HOME to /build because we write our .cargo/config there
CARGO_HOME = "/build/.cargo_home";

common = {inherit pname version src cargoVendorDir preConfigure CARGO_HOME;};
common = {inherit pname version src cargoVendorDir preConfigure postUnpack;};

depsArgs = common // { pnameSuffix = depsNameSuffix; };
deps = produceDerivation "${pname}${depsNameSuffix}" (crane.buildDepsOnly depsArgs);
Expand Down

0 comments on commit 7641236

Please sign in to comment.