diff options
author | Daniël de Kok <me@danieldk.eu> | 2021-02-15 06:54:18 +0100 |
---|---|---|
committer | Daniël de Kok <me@danieldk.eu> | 2021-02-15 12:17:18 +0100 |
commit | 9757c7101a0527c001fa9e9832764d5dc106ff25 (patch) | |
tree | 84e0fae7e564134fe879e732b0444f03adcc3ddf /pkgs/build-support/rust/default.nix | |
parent | 056f697397f0971aac7f3e022f9b90dc80d194e9 (diff) | |
download | nixpkgs-9757c7101a0527c001fa9e9832764d5dc106ff25.tar nixpkgs-9757c7101a0527c001fa9e9832764d5dc106ff25.tar.gz nixpkgs-9757c7101a0527c001fa9e9832764d5dc106ff25.tar.bz2 nixpkgs-9757c7101a0527c001fa9e9832764d5dc106ff25.tar.lz nixpkgs-9757c7101a0527c001fa9e9832764d5dc106ff25.tar.xz nixpkgs-9757c7101a0527c001fa9e9832764d5dc106ff25.tar.zst nixpkgs-9757c7101a0527c001fa9e9832764d5dc106ff25.zip |
buildRustPackage: factor out install phase to cargoInstallHook
Diffstat (limited to 'pkgs/build-support/rust/default.nix')
-rw-r--r-- | pkgs/build-support/rust/default.nix | 40 |
1 files changed, 4 insertions, 36 deletions
diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix index 19ec71261be..b7d6cb522bc 100644 --- a/pkgs/build-support/rust/default.nix +++ b/pkgs/build-support/rust/default.nix @@ -4,6 +4,7 @@ , cacert , cargo , cargoBuildHook +, cargoInstallHook , cargoSetupHook , fetchCargoTarball , runCommandNoCC @@ -87,9 +88,6 @@ let originalCargoToml = src + /Cargo.toml; # profile info is later extracted }; - releaseDir = "target/${shortTarget}/${buildType}"; - tmpDir = "${releaseDir}-tmp"; - in # Tests don't currently work for `no_std`, and all custom sysroots are currently built without `std`. @@ -99,16 +97,16 @@ assert useSysroot -> !(args.doCheck or true); stdenv.mkDerivation ((removeAttrs args ["depsExtraArgs"]) // lib.optionalAttrs useSysroot { RUSTFLAGS = "--sysroot ${sysroot} " + (args.RUSTFLAGS or ""); } // { - inherit buildAndTestSubdir cargoDeps releaseDir tmpDir; + inherit buildAndTestSubdir cargoDeps; cargoBuildFlags = lib.concatStringsSep " " cargoBuildFlags; - cargoBuildType = "--${buildType}"; + cargoBuildType = buildType; patchRegistryDeps = ./patch-registry-deps; nativeBuildInputs = nativeBuildInputs ++ - [ cacert git cargo cargoBuildHook cargoSetupHook rustc ]; + [ cacert git cargo cargoBuildHook cargoInstallHook cargoSetupHook rustc ]; buildInputs = buildInputs ++ lib.optional stdenv.hostPlatform.isMinGW windows.pthreads; @@ -144,36 +142,6 @@ stdenv.mkDerivation ((removeAttrs args ["depsExtraArgs"]) // lib.optionalAttrs u strictDeps = true; - installPhase = args.installPhase or '' - runHook preInstall - - # This needs to be done after postBuild: packages like `cargo` do a pushd/popd in - # the pre/postBuild-hooks that need to be taken into account before gathering - # all binaries to install. - mkdir -p $tmpDir - cp -r $releaseDir/* $tmpDir/ - bins=$(find $tmpDir \ - -maxdepth 1 \ - -type f \ - -executable ! \( -regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" \)) - - # rename the output dir to a architecture independent one - mapfile -t targets < <(find "$NIX_BUILD_TOP" -type d | grep '${tmpDir}$') - for target in "''${targets[@]}"; do - rm -rf "$target/../../${buildType}" - ln -srf "$target" "$target/../../" - done - mkdir -p $out/bin $out/lib - - xargs -r cp -t $out/bin <<< $bins - find $tmpDir \ - -maxdepth 1 \ - -regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" \ - -print0 | xargs -r -0 cp -t $out/lib - rmdir --ignore-fail-on-non-empty $out/lib $out/bin - runHook postInstall - ''; - passthru = { inherit cargoDeps; } // (args.passthru or {}); meta = { |