From 952f4fda864b61314f21a07766b74c344d124843 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Wed, 21 Nov 2018 12:38:49 +0000 Subject: [PATCH] makeRustPlatform: refactor to make it easier to understand It is now clearer what is supposed to be in the rust attribute set without having studied type theory. The amount of code is identically. --- pkgs/build-support/rust/default.nix | 10 +++------- pkgs/build-support/rust/fetchcargo.nix | 4 ++-- pkgs/build-support/rust/make-rust-platform.nix | 18 ++++++++++++++++++ pkgs/top-level/all-packages.nix | 16 +--------------- 4 files changed, 24 insertions(+), 24 deletions(-) create mode 100644 pkgs/build-support/rust/make-rust-platform.nix diff --git a/pkgs/build-support/rust/default.nix b/pkgs/build-support/rust/default.nix index 5fdcf520440..43aecdef5f2 100644 --- a/pkgs/build-support/rust/default.nix +++ b/pkgs/build-support/rust/default.nix @@ -1,9 +1,5 @@ -{ stdenv, cacert, git, rust, cargo-vendor, python3 }: -let - fetchcargo = import ./fetchcargo.nix { - inherit stdenv cacert git rust cargo-vendor python3; - }; -in +{ stdenv, cacert, git, cargo, rustc, cargo-vendor, fetchcargo, python3 }: + { name, cargoSha256 ? "unset" , src ? null , srcs ? null @@ -45,7 +41,7 @@ in stdenv.mkDerivation (args // { patchRegistryDeps = ./patch-registry-deps; - buildInputs = [ cacert git rust.cargo rust.rustc ] ++ buildInputs; + buildInputs = [ cacert git cargo rustc ] ++ buildInputs; patches = cargoPatches ++ patches; diff --git a/pkgs/build-support/rust/fetchcargo.nix b/pkgs/build-support/rust/fetchcargo.nix index 9e77f8817b2..c23fa66ef9f 100644 --- a/pkgs/build-support/rust/fetchcargo.nix +++ b/pkgs/build-support/rust/fetchcargo.nix @@ -1,4 +1,4 @@ -{ stdenv, cacert, git, rust, cargo-vendor, python3 }: +{ stdenv, cacert, git, cargo, cargo-vendor, python3 }: let cargo-vendor-normalise = stdenv.mkDerivation { name = "cargo-vendor-normalise"; src = ./cargo-vendor-normalise.py; @@ -20,7 +20,7 @@ in { name ? "cargo-deps", src, srcs, patches, sourceRoot, sha256, cargoUpdateHook ? "" }: stdenv.mkDerivation { name = "${name}-vendor"; - nativeBuildInputs = [ cacert cargo-vendor git cargo-vendor-normalise rust.cargo ]; + nativeBuildInputs = [ cacert cargo-vendor git cargo-vendor-normalise cargo ]; inherit src srcs patches sourceRoot; phases = "unpackPhase patchPhase installPhase"; diff --git a/pkgs/build-support/rust/make-rust-platform.nix b/pkgs/build-support/rust/make-rust-platform.nix new file mode 100644 index 00000000000..afbc56865ff --- /dev/null +++ b/pkgs/build-support/rust/make-rust-platform.nix @@ -0,0 +1,18 @@ +{ callPackage }: +{ rustc, cargo, ... }: { + rust = { + inherit rustc cargo; + }; + + buildRustPackage = callPackage ./default.nix { + inherit rustc cargo; + + fetchcargo = callPackage ./fetchcargo.nix { + inherit cargo; + }; + }; + + rustcSrc = callPackage ../../development/compilers/rust/rust-src.nix { + inherit rustc; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 98101ec847c..688b2f9a616 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -7384,23 +7384,9 @@ with pkgs; defaultCrateOverrides = callPackage ../build-support/rust/default-crate-overrides.nix { }; + makeRustPlatform = callPackage ../build-support/rust/make-rust-platform.nix {}; rustPlatform = recurseIntoAttrs (makeRustPlatform rust); - makeRustPlatform = rust: lib.fix (self: - let - callPackage = newScope self; - in { - inherit rust; - - buildRustPackage = callPackage ../build-support/rust { - inherit rust; - }; - - rustcSrc = callPackage ../development/compilers/rust/rust-src.nix { - inherit (rust) rustc; - }; - }); - cargo-download = callPackage ../tools/package-management/cargo-download { }; cargo-edit = callPackage ../tools/package-management/cargo-edit { }; cargo-release = callPackage ../tools/package-management/cargo-release { };