diff options
author | Pavol Rusnak <pavol@rusnak.io> | 2021-01-24 01:40:18 +0100 |
---|---|---|
committer | Pavol Rusnak <pavol@rusnak.io> | 2021-01-24 01:49:49 +0100 |
commit | 90f73381120f7ae9e0d5f0f6dc16cb141c658494 (patch) | |
tree | 5683ff0c39f9ac901e181fc0591cf03c2b95b07a /pkgs/build-support/rust | |
parent | 2f34b4b883932f0ee2c1787e704f3915786e8cca (diff) |
treewide: stdenv.lib -> lib
Diffstat (limited to 'pkgs/build-support/rust')
-rw-r--r-- | pkgs/build-support/rust/default-crate-overrides.nix | 6 | ||||
-rw-r--r-- | pkgs/build-support/rust/default.nix | 27 | ||||
-rw-r--r-- | pkgs/build-support/rust/fetchCargoTarball.nix | 4 |
3 files changed, 19 insertions, 18 deletions
diff --git a/pkgs/build-support/rust/default-crate-overrides.nix b/pkgs/build-support/rust/default-crate-overrides.nix index 4ff8640c2ff56..3d2dc3733c227 100644 --- a/pkgs/build-support/rust/default-crate-overrides.nix +++ b/pkgs/build-support/rust/default-crate-overrides.nix @@ -1,4 +1,4 @@ -{ stdenv, pkg-config, curl, darwin, libiconv, libgit2, libssh2, +{ lib, stdenv, pkg-config, curl, darwin, libiconv, libgit2, libssh2, openssl, sqlite, zlib, dbus, dbus-glib, gdk-pixbuf, cairo, python3, libsodium, postgresql, gmp, foundationdb, capnproto, nettle, clang, llvmPackages, ... }: @@ -17,7 +17,7 @@ in cargo = attrs: { buildInputs = [ openssl zlib curl ] - ++ stdenv.lib.optionals stdenv.isDarwin [ CoreFoundation Security libiconv ]; + ++ lib.optionals stdenv.isDarwin [ CoreFoundation Security libiconv ]; }; libz-sys = attrs: { @@ -149,7 +149,7 @@ in }; serde_derive = attrs: { - buildInputs = stdenv.lib.optional stdenv.isDarwin Security; + buildInputs = lib.optional stdenv.isDarwin Security; }; thrussh-libsodium = attrs: { diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix index 9e8e32035d0dd..dc86a7dc581fe 100644 --- a/pkgs/build-support/rust/default.nix +++ b/pkgs/build-support/rust/default.nix @@ -1,4 +1,5 @@ { stdenv +, lib , buildPackages , cacert , cargo @@ -83,13 +84,13 @@ let cargoDepsCopy="$sourceRoot/${cargoVendorDir}" ''; - targetIsJSON = stdenv.lib.hasSuffix ".json" target; + targetIsJSON = lib.hasSuffix ".json" target; useSysroot = targetIsJSON && !__internal_dontAddSysroot; # see https://github.com/rust-lang/cargo/blob/964a16a28e234a3d397b2a7031d4ab4a428b1391/src/cargo/core/compiler/compile_kind.rs#L151-L168 # the "${}" is needed to transform the path into a /nix/store path before baseNameOf shortTarget = if targetIsJSON then - (stdenv.lib.removeSuffix ".json" (builtins.baseNameOf "${target}")) + (lib.removeSuffix ".json" (builtins.baseNameOf "${target}")) else target; sysroot = (callPackage ./sysroot {}) { @@ -116,7 +117,7 @@ in # See https://os.phil-opp.com/testing/ for more information. assert useSysroot -> !(args.doCheck or true); -stdenv.mkDerivation ((removeAttrs args ["depsExtraArgs"]) // stdenv.lib.optionalAttrs useSysroot { +stdenv.mkDerivation ((removeAttrs args ["depsExtraArgs"]) // lib.optionalAttrs useSysroot { RUSTFLAGS = "--sysroot ${sysroot} " + (args.RUSTFLAGS or ""); } // { inherit cargoDeps; @@ -124,7 +125,7 @@ stdenv.mkDerivation ((removeAttrs args ["depsExtraArgs"]) // stdenv.lib.optional patchRegistryDeps = ./patch-registry-deps; nativeBuildInputs = nativeBuildInputs ++ [ cacert git cargo rustc ]; - buildInputs = buildInputs ++ stdenv.lib.optional stdenv.hostPlatform.isMinGW windows.pthreads; + buildInputs = buildInputs ++ lib.optional stdenv.hostPlatform.isMinGW windows.pthreads; patches = cargoPatches ++ patches; @@ -147,11 +148,11 @@ stdenv.mkDerivation ((removeAttrs args ["depsExtraArgs"]) // stdenv.lib.optional cat >> .cargo/config <<'EOF' [target."${rust.toRustTarget stdenv.buildPlatform}"] "linker" = "${ccForBuild}" - ${stdenv.lib.optionalString (stdenv.buildPlatform.config != stdenv.hostPlatform.config) '' + ${lib.optionalString (stdenv.buildPlatform.config != stdenv.hostPlatform.config) '' [target."${shortTarget}"] "linker" = "${ccForHost}" ${# https://github.com/rust-lang/rust/issues/46651#issuecomment-433611633 - stdenv.lib.optionalString (stdenv.hostPlatform.isMusl && stdenv.hostPlatform.isAarch64) '' + lib.optionalString (stdenv.hostPlatform.isMusl && stdenv.hostPlatform.isAarch64) '' "rustflags" = [ "-C", "target-feature=+crt-static", "-C", "link-arg=-lgcc" ] ''} ''} @@ -163,7 +164,7 @@ stdenv.mkDerivation ((removeAttrs args ["depsExtraArgs"]) // stdenv.lib.optional # After unpacking and applying patches, check that the Cargo.lock matches our # src package. Note that we do this after the patchPhase, because the # patchPhase may create the Cargo.lock if upstream has not shipped one. - postPatch = (args.postPatch or "") + stdenv.lib.optionalString validateCargoDeps '' + postPatch = (args.postPatch or "") + lib.optionalString validateCargoDeps '' cargoDepsLockfile=$NIX_BUILD_TOP/$cargoDepsCopy/Cargo.lock srcLockfile=$NIX_BUILD_TOP/$sourceRoot/Cargo.lock @@ -206,7 +207,7 @@ stdenv.mkDerivation ((removeAttrs args ["depsExtraArgs"]) // stdenv.lib.optional ''; buildPhase = with builtins; args.buildPhase or '' - ${stdenv.lib.optionalString (buildAndTestSubdir != null) "pushd ${buildAndTestSubdir}"} + ${lib.optionalString (buildAndTestSubdir != null) "pushd ${buildAndTestSubdir}"} runHook preBuild ( @@ -217,14 +218,14 @@ stdenv.mkDerivation ((removeAttrs args ["depsExtraArgs"]) // stdenv.lib.optional "CC_${rust.toRustTarget stdenv.hostPlatform}"="${ccForHost}" \ "CXX_${rust.toRustTarget stdenv.hostPlatform}"="${cxxForHost}" \ cargo build -j $NIX_BUILD_CORES \ - ${stdenv.lib.optionalString (buildType == "release") "--release"} \ + ${lib.optionalString (buildType == "release") "--release"} \ --target ${target} \ --frozen ${concatStringsSep " " cargoBuildFlags} ) runHook postBuild - ${stdenv.lib.optionalString (buildAndTestSubdir != null) "popd"} + ${lib.optionalString (buildAndTestSubdir != null) "popd"} # 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 @@ -238,15 +239,15 @@ stdenv.mkDerivation ((removeAttrs args ["depsExtraArgs"]) // stdenv.lib.optional ''; checkPhase = args.checkPhase or (let - argstr = "${stdenv.lib.optionalString (checkType == "release") "--release"} --target ${target} --frozen"; + argstr = "${lib.optionalString (checkType == "release") "--release"} --target ${target} --frozen"; threads = if cargoParallelTestThreads then "$NIX_BUILD_CORES" else "1"; in '' - ${stdenv.lib.optionalString (buildAndTestSubdir != null) "pushd ${buildAndTestSubdir}"} + ${lib.optionalString (buildAndTestSubdir != null) "pushd ${buildAndTestSubdir}"} runHook preCheck echo "Running cargo test ${argstr} -- ''${checkFlags} ''${checkFlagsArray+''${checkFlagsArray[@]}}" cargo test -j $NIX_BUILD_CORES ${argstr} -- --test-threads=${threads} ''${checkFlags} ''${checkFlagsArray+"''${checkFlagsArray[@]}"} runHook postCheck - ${stdenv.lib.optionalString (buildAndTestSubdir != null) "popd"} + ${lib.optionalString (buildAndTestSubdir != null) "popd"} ''); doCheck = args.doCheck or true; diff --git a/pkgs/build-support/rust/fetchCargoTarball.nix b/pkgs/build-support/rust/fetchCargoTarball.nix index 0726e5cfa5a18..c30e88d99b833 100644 --- a/pkgs/build-support/rust/fetchCargoTarball.nix +++ b/pkgs/build-support/rust/fetchCargoTarball.nix @@ -1,4 +1,4 @@ -{ stdenv, cacert, git, cargo, python3 }: +{ lib, stdenv, cacert, git, cargo, python3 }: let cargo-vendor-normalise = stdenv.mkDerivation { name = "cargo-vendor-normalise"; src = ./cargo-vendor-normalise.py; @@ -80,7 +80,7 @@ in stdenv.mkDerivation ({ inherit (hash_) outputHashAlgo outputHash; - impureEnvVars = stdenv.lib.fetchers.proxyImpureEnvVars; + impureEnvVars = lib.fetchers.proxyImpureEnvVars; } // (builtins.removeAttrs args [ "name" "sha256" "cargoUpdateHook" ])) |