Browse Source

Merge pull request #145007 from Ericson2314/backport-144193-to-release-21.05

[backport release-21.05] build-support/rust: Organize
nsd-state-dir
John Ericson 11 months ago
committed by GitHub
parent
commit
b865967452
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 0
      pkgs/build-support/rust/build-rust-package/default.nix
  2. 0
      pkgs/build-support/rust/build-rust-package/patch-registry-deps/pkg-config
  3. 0
      pkgs/build-support/rust/build-rust-package/sysroot/Cargo.lock
  4. 0
      pkgs/build-support/rust/build-rust-package/sysroot/cargo.py
  5. 0
      pkgs/build-support/rust/build-rust-package/sysroot/default.nix
  6. 0
      pkgs/build-support/rust/build-rust-package/sysroot/update-lockfile.sh
  7. 0
      pkgs/build-support/rust/fetch-cargo-tarball/cargo-vendor-normalise.py
  8. 4
      pkgs/build-support/rust/fetch-cargo-tarball/default.nix
  9. 37
      pkgs/build-support/rust/lib/default.nix
  10. 39
      pkgs/development/compilers/rust/default.nix
  11. 4
      pkgs/development/compilers/rust/make-rust-platform.nix

0
pkgs/build-support/rust/default.nix → pkgs/build-support/rust/build-rust-package/default.nix

0
pkgs/build-support/rust/patch-registry-deps/pkg-config → pkgs/build-support/rust/build-rust-package/patch-registry-deps/pkg-config

0
pkgs/build-support/rust/sysroot/Cargo.lock → pkgs/build-support/rust/build-rust-package/sysroot/Cargo.lock

0
pkgs/build-support/rust/sysroot/cargo.py → pkgs/build-support/rust/build-rust-package/sysroot/cargo.py

0
pkgs/build-support/rust/sysroot/default.nix → pkgs/build-support/rust/build-rust-package/sysroot/default.nix

0
pkgs/build-support/rust/sysroot/update-lockfile.sh → pkgs/build-support/rust/build-rust-package/sysroot/update-lockfile.sh

0
pkgs/build-support/rust/cargo-vendor-normalise.py → pkgs/build-support/rust/fetch-cargo-tarball/cargo-vendor-normalise.py

4
pkgs/build-support/rust/fetchCargoTarball.nix → pkgs/build-support/rust/fetch-cargo-tarball/default.nix

@ -9,8 +9,8 @@ let cargo-vendor-normalise = stdenv.mkDerivation {
postFixup = "wrapPythonPrograms";
doInstallCheck = true;
installCheckPhase = ''
# check that ./fetchcargo-default-config.toml is a fix point
reference=${./fetchcargo-default-config.toml}
# check that ../fetchcargo-default-config.toml is a fix point
reference=${../fetchcargo-default-config.toml}
< $reference $out/bin/cargo-vendor-normalise > test;
cmp test $reference
'';

37
pkgs/build-support/rust/lib/default.nix

@ -0,0 +1,37 @@
{ lib }:
rec {
# https://doc.rust-lang.org/reference/conditional-compilation.html#target_arch
toTargetArch = platform:
if platform.isAarch32 then "arm"
else platform.parsed.cpu.name;
# https://doc.rust-lang.org/reference/conditional-compilation.html#target_os
toTargetOs = platform:
if platform.isDarwin then "macos"
else platform.parsed.kernel.name;
# Returns the name of the rust target, even if it is custom. Adjustments are
# because rust has slightly different naming conventions than we do.
toRustTarget = platform: let
inherit (platform.parsed) cpu vendor kernel abi;
cpu_ = platform.rustc.platform.arch or {
"armv7a" = "armv7";
"armv7l" = "armv7";
"armv6l" = "arm";
"armv5tel" = "armv5te";
"riscv64" = "riscv64gc";
}.${cpu.name} or cpu.name;
vendor_ = platform.rustc.platform.vendor or {
"w64" = "pc";
}.${vendor.name} or vendor.name;
in platform.rustc.config
or "${cpu_}-${vendor_}-${kernel.name}${lib.optionalString (abi.name != "unknown") "-${abi.name}"}";
# Returns the name of the rust target if it is standard, or the json file
# containing the custom target spec.
toRustTargetSpec = platform:
if (platform.rustc or {}) ? platform
then builtins.toFile (toRustTarget platform + ".json") (builtins.toJSON platform.rustc.platform)
else toRustTarget platform;
}

39
pkgs/development/compilers/rust/default.nix

@ -17,38 +17,17 @@
, CoreFoundation, Security
, pkgsBuildTarget, pkgsBuildBuild
, makeRustPlatform
}: rec {
# https://doc.rust-lang.org/reference/conditional-compilation.html#target_arch
toTargetArch = platform:
if platform.isAarch32 then "arm"
else platform.parsed.cpu.name;
# https://doc.rust-lang.org/reference/conditional-compilation.html#target_os
toTargetOs = platform:
if platform.isDarwin then "macos"
else platform.parsed.kernel.name;
}:
# Returns the name of the rust target, even if it is custom. Adjustments are
# because rust has slightly different naming conventions than we do.
toRustTarget = platform: with platform.parsed; let
cpu_ = platform.rustc.platform.arch or {
"armv7a" = "armv7";
"armv7l" = "armv7";
"armv6l" = "arm";
"armv5tel" = "armv5te";
}.${cpu.name} or cpu.name;
vendor_ = platform.rustc.platform.vendor or {
"w64" = "pc";
}.${vendor.name} or vendor.name;
in platform.rustc.config
or "${cpu_}-${vendor_}-${kernel.name}${lib.optionalString (abi.name != "unknown") "-${abi.name}"}";
let
# Use `import` to make sure no packages sneak in here.
lib' = import ../../../build-support/rust/lib { inherit lib; };
in
{
lib = lib';
# Returns the name of the rust target if it is standard, or the json file
# containing the custom target spec.
toRustTargetSpec = platform:
if (platform.rustc or {}) ? platform
then builtins.toFile (toRustTarget platform + ".json") (builtins.toJSON platform.rustc.platform)
else toRustTarget platform;
# Backwards compat before `lib` was factored out.
inherit (lib') toTargetArch toTargetOs toRustTarget toRustTargetSpec;
# This just contains tools for now. But it would conceivably contain
# libraries too, say if we picked some default/recommended versions from

4
pkgs/development/compilers/rust/make-rust-platform.nix

@ -7,11 +7,11 @@ rec {
inherit rustc cargo;
};
fetchCargoTarball = buildPackages.callPackage ../../../build-support/rust/fetchCargoTarball.nix {
fetchCargoTarball = buildPackages.callPackage ../../../build-support/rust/fetch-cargo-tarball {
inherit cargo;
};
buildRustPackage = callPackage ../../../build-support/rust {
buildRustPackage = callPackage ../../../build-support/rust/build-rust-package {
inherit cargoBuildHook cargoCheckHook cargoInstallHook cargoSetupHook
fetchCargoTarball rustc;
};

Loading…
Cancel
Save