From aa5dcd0518a422dfd545d565f0d5a25971fea52a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20=C5=BDlender?= Date: Sat, 29 Jun 2024 20:29:52 +0200 Subject: [PATCH] Splice overrideToolchain (#652) --------- Co-authored-by: Ivan Petkov --- CHANGELOG.md | 7 + checks/default.nix | 6 +- checks/trunk.nix | 4 +- default.nix | 12 +- docs/API.md | 9 +- docs/faq/custom-nixpkgs.md | 8 +- docs/faq/invalid-metadata-files-for-crate.md | 5 +- docs/overriding_derivations.md | 2 +- examples/build-std/flake.nix | 6 +- examples/cross-musl/flake.nix | 6 +- examples/cross-rust-overlay/flake.nix | 6 +- examples/custom-toolchain/flake.nix | 9 +- examples/end-to-end-testing/flake.nix | 3 +- examples/trunk-workspace/flake.nix | 4 +- examples/trunk/flake.nix | 4 +- lib/default.nix | 213 ++++++++++++------- lib/downloadCargoPackageFromGit.nix | 3 +- 17 files changed, 174 insertions(+), 133 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6cc7d55..195cff9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. `craneLib.cleanCargoSource (craneLib.path ./.)`): it is recommended to either use `craneLib.cleanCargoSource ./.` directly (if the default source cleaning is desired) or `craneLib.path ./.` (if not). +* `overrideToolchain` has been updated to better handle cross-compilation + splicing for a customized toolchain. This means that `overrideToolchain` + should now be called with a function which constructs said toolchain for any + given `pkgs` instantiation. For example: `craneLib.overrideToolchain (p: + p.rust-bin.stable.latest.default)` ### Fixed * The cross compilation example also hows how to set the `TARGET_CC` environment @@ -23,6 +28,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. `cleanCargoSource`) * `removeReferencesToVendoredSources` handles the edge case where `cargoVendorDir` does not point to a path within the Nix store +* It is now possible to use `.overrideScope` to change what instance of + `craneUtils` will be used during vendoring. ## [0.17.3] - 2024-06-02 diff --git a/checks/default.nix b/checks/default.nix index 532b64d..ecd933c 100644 --- a/checks/default.nix +++ b/checks/default.nix @@ -8,7 +8,7 @@ in onlyDrvs (lib.makeScope myLib.newScope (self: let callPackage = self.newScope { }; - myLibLlvmTools = myLib.overrideToolchain (pkgs.rust-bin.stable.latest.minimal.override { + myLibLlvmTools = myLib.overrideToolchain (p: p.rust-bin.stable.latest.minimal.override { extensions = [ "llvm-tools" ]; }); x64Linux = pkgs.hostPlatform.system == "x86_64-linux"; @@ -407,7 +407,7 @@ in noStd = let - noStdLib = myLib.overrideToolchain (pkgs.rust-bin.stable.latest.minimal.override { + noStdLib = myLib.overrideToolchain (p: p.rust-bin.stable.latest.minimal.override { targets = [ "thumbv6m-none-eabi" "x86_64-unknown-none" @@ -423,7 +423,7 @@ in bindeps = let - bindepsLib = myLib.overrideToolchain (pkgs.rust-bin.nightly.latest.minimal.override { + bindepsLib = myLib.overrideToolchain (p: p.rust-bin.nightly.latest.minimal.override { targets = [ "wasm32-unknown-unknown" "x86_64-unknown-none" diff --git a/checks/trunk.nix b/checks/trunk.nix index 7ce6ae2..b156888 100644 --- a/checks/trunk.nix +++ b/checks/trunk.nix @@ -5,7 +5,7 @@ }: let - wasmToolchain = pkgs.rust-bin.stable.latest.minimal.override { + wasmToolchainFor = p: p.rust-bin.stable.latest.minimal.override { targets = [ "wasm32-unknown-unknown" ]; }; @@ -13,7 +13,7 @@ let url = "https://github.com/NixOS/nixpkgs/archive/4e6868b1aa3766ab1de169922bb3826143941973.tar.gz"; sha256 = "sha256:1q6bj2jjlwb10sfrhqmjpzsc3yc4x76cvky16wh0z52p7d2lhdpv"; }; - myLibWasm = (myLib.overrideToolchain wasmToolchain).overrideScope (_final: _prev: { + myLibWasm = (myLib.overrideToolchain wasmToolchainFor).overrideScope (_final: _prev: { inherit (import tarball { inherit (stdenv) system; }) wasm-bindgen-cli; }); diff --git a/default.nix b/default.nix index e7c4488..1c353d6 100644 --- a/default.nix +++ b/default.nix @@ -1,13 +1,3 @@ { pkgs ? import { } }: -import ./lib { - inherit (pkgs) lib makeScopeWithSplicing'; - otherSplices = { - selfBuildBuild = pkgs.pkgsBuildBuild; - selfBuildHost = pkgs.pkgsBuildHost; - selfBuildTarget = pkgs.pkgsBuildTarget; - selfHostHost = pkgs.pkgsHostHost; - selfHostTarget = pkgs.pkgsHostTarget; - selfTargetTarget = pkgs.pkgsTargetTarget; - }; -} +pkgs.callPackage ./lib { } diff --git a/docs/API.md b/docs/API.md index 69da3de..26bccc4 100644 --- a/docs/API.md +++ b/docs/API.md @@ -1193,15 +1193,20 @@ build caches. More specifically: ### `craneLib.overrideToolchain` -`overrideToolchain :: drv -> set` +`overrideToolchain :: (set -> drv) -> set` +`overrideToolchain :: drv -> set` (legacy) A convenience method to override and use tools (like `cargo`, `clippy`, `rustfmt`, `rustc`, etc.) from one specific toolchain. The input should be a single derivation which contains all the tools as binaries. For example, this can be the output of `oxalica/rust-overlay`. +Note that in order to best support cross compilation, `overrideToolchain` should +be provided a function (whose argument is a cross-compilation aware version of +`pkgs`) which constructs the toolchain: + ```nix -craneLib.overrideToolchain myCustomToolchain +craneLib.overrideToolchain (p: myCustomToolchainForPkgs p) ``` ### `craneLib.path` diff --git a/docs/faq/custom-nixpkgs.md b/docs/faq/custom-nixpkgs.md index 60234c4..07757a5 100644 --- a/docs/faq/custom-nixpkgs.md +++ b/docs/faq/custom-nixpkgs.md @@ -26,12 +26,10 @@ let inherit system; overlays = [ (import rust-overlay) ]; }; - - rustToolchain = pkgs.rust-bin.stable.latest.default.override { - targets = [ "wasm32-wasi" ]; - }; in -(crane.mkLib pkgs).overrideToolchain rustToolchain +(crane.mkLib pkgs).overrideToolchain (p: p.rust-bin.stable.latest.default.override { + targets = [ "wasm32-wasi" ]; +}) ``` Finally, specific inputs can be overridden for the entire library via the diff --git a/docs/faq/invalid-metadata-files-for-crate.md b/docs/faq/invalid-metadata-files-for-crate.md index 5c5d296..00e0c98 100644 --- a/docs/faq/invalid-metadata-files-for-crate.md +++ b/docs/faq/invalid-metadata-files-for-crate.md @@ -7,7 +7,8 @@ used in the build: ```nix let - rustToolchain = ...; + rustToolchainForPkgs = p: ...; + rustToolchain = rustToolchainForPkgs pkgs; in # Incorrect usage, missing `clippy` override! #(crane.mkLib pkgs).overrideScope (final: prev: { @@ -17,5 +18,5 @@ in #}); # Correct usage (`overrideToolchain` handles the details for us) -(crane.mkLib pkgs).overrideToolchain rustToolchain +(crane.mkLib pkgs).overrideToolchain rustToolchainForPkgs ``` diff --git a/docs/overriding_derivations.md b/docs/overriding_derivations.md index 4677c2b..61b61bd 100644 --- a/docs/overriding_derivations.md +++ b/docs/overriding_derivations.md @@ -83,7 +83,7 @@ craneLib.buildPackage { # Use a different `craneLib` instantiation: one with a nightly compiler my-crate-nightly = my-crate.override { - craneLib = craneLib.overrideToolchain pkgs.rust-bin.nightly.latest.default; + craneLib = craneLib.overrideToolchain (p: p.rust-bin.nightly.latest.default); }; }; }); diff --git a/examples/build-std/flake.nix b/examples/build-std/flake.nix index c2f88c9..0553c69 100644 --- a/examples/build-std/flake.nix +++ b/examples/build-std/flake.nix @@ -28,16 +28,17 @@ overlays = [ (import rust-overlay) ]; }; - rustToolchain = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override { + rustToolchainFor = p: p.rust-bin.selectLatestNightlyWith (toolchain: toolchain.default.override { extensions = [ "rust-src" ]; targets = [ "x86_64-unknown-linux-gnu" ]; }); + rustToolchain = rustToolchainFor pkgs; # NB: we don't need to overlay our custom toolchain for the *entire* # pkgs (which would require rebuidling anything else which uses rust). # Instead, we just want to update the scope that crane will use by appending # our specific toolchain there. - craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; + craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchainFor; src = craneLib.cleanCargoSource ./.; @@ -83,7 +84,6 @@ # Extra inputs can be added here; cargo and rustc are provided by default # from the toolchain that was specified earlier. packages = [ - # rustToolchain ]; }; }); diff --git a/examples/cross-musl/flake.nix b/examples/cross-musl/flake.nix index f324474..245dbef 100644 --- a/examples/cross-musl/flake.nix +++ b/examples/cross-musl/flake.nix @@ -28,11 +28,9 @@ overlays = [ (import rust-overlay) ]; }; - rustToolchain = pkgs.rust-bin.stable.latest.default.override { + craneLib = (crane.mkLib pkgs).overrideToolchain (p: p.rust-bin.stable.latest.default.override { targets = [ "x86_64-unknown-linux-musl" ]; - }; - - craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; + }); my-crate = craneLib.buildPackage { src = craneLib.cleanCargoSource ./.; diff --git a/examples/cross-rust-overlay/flake.nix b/examples/cross-rust-overlay/flake.nix index 4689fde..610e6dd 100644 --- a/examples/cross-rust-overlay/flake.nix +++ b/examples/cross-rust-overlay/flake.nix @@ -31,11 +31,7 @@ overlays = [ (import rust-overlay) ]; }; - rustToolchain = pkgs.pkgsBuildHost.rust-bin.stable.latest.default.override { - targets = [ "aarch64-unknown-linux-gnu" ]; - }; - - craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; + craneLib = (crane.mkLib pkgs).overrideToolchain (p: p.rust-bin.stable.latest.default); # Note: we have to use the `callPackage` approach here so that Nix # can "splice" the packages in such a way that dependencies are diff --git a/examples/custom-toolchain/flake.nix b/examples/custom-toolchain/flake.nix index 7783342..fe7b90c 100644 --- a/examples/custom-toolchain/flake.nix +++ b/examples/custom-toolchain/flake.nix @@ -28,15 +28,13 @@ overlays = [ (import rust-overlay) ]; }; - rustWithWasiTarget = pkgs.rust-bin.stable.latest.default.override { - targets = [ "wasm32-wasi" ]; - }; - # NB: we don't need to overlay our custom toolchain for the *entire* # pkgs (which would require rebuidling anything else which uses rust). # Instead, we just want to update the scope that crane will use by appending # our specific toolchain there. - craneLib = (crane.mkLib pkgs).overrideToolchain rustWithWasiTarget; + craneLib = (crane.mkLib pkgs).overrideToolchain (p: p.rust-bin.stable.latest.default.override { + targets = [ "wasm32-wasi" ]; + }); my-crate = craneLib.buildPackage { src = craneLib.cleanCargoSource ./.; @@ -76,7 +74,6 @@ # Extra inputs can be added here; cargo and rustc are provided by default # from the toolchain that was specified earlier. packages = [ - # rustWithWasiTarget ]; }; }); diff --git a/examples/end-to-end-testing/flake.nix b/examples/end-to-end-testing/flake.nix index 0ceeadc..7640912 100644 --- a/examples/end-to-end-testing/flake.nix +++ b/examples/end-to-end-testing/flake.nix @@ -27,8 +27,7 @@ }; inherit (pkgs) lib; - rustToolchain = pkgs.rust-bin.stable.latest.default; - craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; + craneLib = (crane.mkLib pkgs).overrideToolchain (p: p.rust-bin.stable.latest.default); src = craneLib.cleanCargoSource ./.; workspace = craneLib.buildPackage { diff --git a/examples/trunk-workspace/flake.nix b/examples/trunk-workspace/flake.nix index c06853a..d7633c9 100644 --- a/examples/trunk-workspace/flake.nix +++ b/examples/trunk-workspace/flake.nix @@ -34,12 +34,12 @@ inherit (pkgs) lib; - rustToolchain = pkgs.rust-bin.stable.latest.default.override { + rustToolchainFor = p: p.rust-bin.stable.latest.default.override { # Set the build targets supported by the toolchain, # wasm32-unknown-unknown is required for trunk. targets = [ "wasm32-unknown-unknown" ]; }; - craneLib = ((crane.mkLib pkgs).overrideToolchain rustToolchain).overrideScope (_final: _prev: { + craneLib = ((crane.mkLib pkgs).overrideToolchain rustToolchainFor).overrideScope (_final: _prev: { # The version of wasm-bindgen-cli needs to match the version in Cargo.lock. You # can unpin this if your nixpkgs commit contains the appropriate wasm-bindgen-cli version inherit (import nixpkgs-for-wasm-bindgen { inherit system; }) wasm-bindgen-cli; diff --git a/examples/trunk/flake.nix b/examples/trunk/flake.nix index 101d596..dedc51b 100644 --- a/examples/trunk/flake.nix +++ b/examples/trunk/flake.nix @@ -34,12 +34,12 @@ inherit (pkgs) lib; - rustToolchain = pkgs.rust-bin.stable.latest.default.override { + rustToolchainFor = p: p.rust-bin.stable.latest.default.override { # Set the build targets supported by the toolchain, # wasm32-unknown-unknown is required for trunk targets = [ "wasm32-unknown-unknown" ]; }; - craneLib = ((crane.mkLib pkgs).overrideToolchain rustToolchain).overrideScope (_final: _prev: { + craneLib = ((crane.mkLib pkgs).overrideToolchain rustToolchainFor).overrideScope (_final: _prev: { # The version of wasm-bindgen-cli needs to match the version in Cargo.lock. You # can unpin this if your nixpkgs commit contains the appropriate wasm-bindgen-cli version inherit (import nixpkgs-for-wasm-bindgen { inherit system; }) wasm-bindgen-cli; diff --git a/lib/default.nix b/lib/default.nix index bdaa1c4..6f9aa6e 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -1,6 +1,13 @@ { lib +, stdenv , makeScopeWithSplicing' -, otherSplices +, splicePackages +, pkgsBuildBuild +, pkgsBuildHost +, pkgsBuildTarget +, pkgsHostHost +, pkgsHostTarget +, pkgsTargetTarget }: let @@ -9,85 +16,129 @@ let isUnsupported = lib.versionOlder current minSupported; msg = "crane requires at least nixpkgs-${minSupported}, supplied nixpkgs-${current}"; - mySplice = f: makeScopeWithSplicing' { - inherit otherSplices f; + # Helps keep things in sync between `overrideToolchain` and `keep` + attrsForToolchainOverride = [ + "cargo" + "clippy" + "rustc" + "rustfmt" + ]; + + spliceToolchain = toolchainFn: + let + splices = { + pkgsBuildBuild = { toolchain = toolchainFn pkgsBuildBuild; }; + pkgsBuildHost = { toolchain = toolchainFn pkgsBuildHost; }; + pkgsBuildTarget = { toolchain = toolchainFn pkgsBuildTarget; }; + pkgsHostHost = { toolchain = toolchainFn pkgsHostHost; }; + pkgsHostTarget = { toolchain = toolchainFn pkgsHostTarget; }; + pkgsTargetTarget = lib.optionalAttrs (pkgsTargetTarget?newScope) { toolchain = toolchainFn pkgsTargetTarget; }; + }; + in + (splicePackages splices).toolchain; + + scopeFn = self: + let + inherit (self) callPackage; + + internalCrateNameFromCargoToml = callPackage ./internalCrateNameFromCargoToml.nix { }; + internalCrateNameForCleanSource = callPackage ./internalCrateNameForCleanSource.nix { + inherit internalCrateNameFromCargoToml; + }; + in + { + appendCrateRegistries = input: self.overrideScope (_final: prev: { + crateRegistries = prev.crateRegistries // (lib.foldl (a: b: a // b) { } input); + }); + + buildDepsOnly = callPackage ./buildDepsOnly.nix { }; + buildPackage = callPackage ./buildPackage.nix { }; + buildTrunkPackage = callPackage ./buildTrunkPackage.nix { }; + cargoAudit = callPackage ./cargoAudit.nix { }; + cargoBuild = callPackage ./cargoBuild.nix { }; + cargoClippy = callPackage ./cargoClippy.nix { }; + cargoDeny = callPackage ./cargoDeny.nix { }; + cargoDoc = callPackage ./cargoDoc.nix { }; + cargoFmt = callPackage ./cargoFmt.nix { }; + cargoHelperFunctionsHook = callPackage ./setupHooks/cargoHelperFunctions.nix { }; + cargoLlvmCov = callPackage ./cargoLlvmCov.nix { }; + cargoNextest = callPackage ./cargoNextest.nix { }; + cargoTarpaulin = callPackage ./cargoTarpaulin.nix { }; + cargoTest = callPackage ./cargoTest.nix { }; + cleanCargoSource = callPackage ./cleanCargoSource.nix { + inherit internalCrateNameForCleanSource; + }; + cleanCargoToml = callPackage ./cleanCargoToml.nix { }; + configureCargoCommonVarsHook = callPackage ./setupHooks/configureCargoCommonVars.nix { }; + configureCargoVendoredDepsHook = callPackage ./setupHooks/configureCargoVendoredDeps.nix { }; + craneUtils = callPackage ../pkgs/crane-utils { }; + + crateNameFromCargoToml = callPackage ./crateNameFromCargoToml.nix { + inherit internalCrateNameFromCargoToml; + }; + + crateRegistries = self.registryFromDownloadUrl { + dl = "https://static.crates.io/crates"; + indexUrl = "https://github.com/rust-lang/crates.io-index"; + }; + + devShell = callPackage ./devShell.nix { }; + downloadCargoPackage = callPackage ./downloadCargoPackage.nix { }; + downloadCargoPackageFromGit = callPackage ./downloadCargoPackageFromGit.nix { }; + filterCargoSources = callPackage ./filterCargoSources.nix { }; + findCargoFiles = callPackage ./findCargoFiles.nix { }; + inheritCargoArtifactsHook = callPackage ./setupHooks/inheritCargoArtifacts.nix { }; + installCargoArtifactsHook = callPackage ./setupHooks/installCargoArtifacts.nix { }; + installFromCargoBuildLogHook = callPackage ./setupHooks/installFromCargoBuildLog.nix { }; + mkCargoDerivation = callPackage ./mkCargoDerivation.nix { }; + mkDummySrc = callPackage ./mkDummySrc.nix { }; + + overrideToolchain = toolchainArg: self.overrideScope (_final: _prev: + let + toolchain = + if lib.isFunction toolchainArg + then spliceToolchain toolchainArg + else toolchainArg; + needsSplicing = stdenv.buildPlatform != stdenv.hostPlatform && toolchain?__spliced == false; + warningMsg = '' + craneLib.overrideToolchain requires a spliced toolchain when cross-compiling. Consider specifying + a function which constructs a toolchain for any given `pkgs` instantiation: + + (crane.mkLib pkgs).overrideToolchain (p: ...) + ''; + in + lib.warnIf needsSplicing warningMsg (lib.genAttrs attrsForToolchainOverride (_: toolchain)) + ); + + path = callPackage ./path.nix { + inherit internalCrateNameForCleanSource; + }; + + registryFromDownloadUrl = callPackage ./registryFromDownloadUrl.nix { }; + registryFromGitIndex = callPackage ./registryFromGitIndex.nix { }; + registryFromSparse = callPackage ./registryFromSparse.nix { }; + removeReferencesToVendoredSourcesHook = callPackage ./setupHooks/removeReferencesToVendoredSources.nix { }; + replaceCargoLockHook = callPackage ./setupHooks/replaceCargoLockHook.nix { }; + urlForCargoPackage = callPackage ./urlForCargoPackage.nix { }; + vendorCargoDeps = callPackage ./vendorCargoDeps.nix { }; + vendorMultipleCargoDeps = callPackage ./vendorMultipleCargoDeps.nix { }; + vendorCargoRegistries = callPackage ./vendorCargoRegistries.nix { }; + vendorGitDeps = callPackage ./vendorGitDeps.nix { }; + writeTOML = callPackage ./writeTOML.nix { }; + }; + + craneSpliced = makeScopeWithSplicing' { + f = scopeFn; + otherSplices = { + selfBuildBuild = lib.makeScope pkgsBuildBuild.newScope scopeFn; + selfBuildHost = lib.makeScope pkgsBuildHost.newScope scopeFn; + selfBuildTarget = lib.makeScope pkgsBuildTarget.newScope scopeFn; + selfHostHost = lib.makeScope pkgsHostHost.newScope scopeFn; + selfHostTarget = lib.makeScope pkgsHostTarget.newScope scopeFn; + selfTargetTarget = lib.optionalAttrs (pkgsTargetTarget?newScope) (lib.makeScope pkgsTargetTarget.newScope scopeFn); + }; + keep = self: lib.optionalAttrs (self?cargo) + (lib.genAttrs attrsForToolchainOverride (n: self.${n})); }; in -lib.warnIf isUnsupported msg (mySplice (self: -let - inherit (self) callPackage; - - internalCrateNameFromCargoToml = callPackage ./internalCrateNameFromCargoToml.nix { }; - internalCrateNameForCleanSource = callPackage ./internalCrateNameForCleanSource.nix { - inherit internalCrateNameFromCargoToml; - }; -in -{ - appendCrateRegistries = input: self.overrideScope (_final: prev: { - crateRegistries = prev.crateRegistries // (lib.foldl (a: b: a // b) { } input); - }); - - buildDepsOnly = callPackage ./buildDepsOnly.nix { }; - buildPackage = callPackage ./buildPackage.nix { }; - buildTrunkPackage = callPackage ./buildTrunkPackage.nix { }; - cargoAudit = callPackage ./cargoAudit.nix { }; - cargoBuild = callPackage ./cargoBuild.nix { }; - cargoClippy = callPackage ./cargoClippy.nix { }; - cargoDeny = callPackage ./cargoDeny.nix { }; - cargoDoc = callPackage ./cargoDoc.nix { }; - cargoFmt = callPackage ./cargoFmt.nix { }; - cargoHelperFunctionsHook = callPackage ./setupHooks/cargoHelperFunctions.nix { }; - cargoLlvmCov = callPackage ./cargoLlvmCov.nix { }; - cargoNextest = callPackage ./cargoNextest.nix { }; - cargoTarpaulin = callPackage ./cargoTarpaulin.nix { }; - cargoTest = callPackage ./cargoTest.nix { }; - cleanCargoSource = callPackage ./cleanCargoSource.nix { - inherit internalCrateNameForCleanSource; - }; - cleanCargoToml = callPackage ./cleanCargoToml.nix { }; - configureCargoCommonVarsHook = callPackage ./setupHooks/configureCargoCommonVars.nix { }; - configureCargoVendoredDepsHook = callPackage ./setupHooks/configureCargoVendoredDeps.nix { }; - devShell = callPackage ./devShell.nix { }; - - crateNameFromCargoToml = callPackage ./crateNameFromCargoToml.nix { - inherit internalCrateNameFromCargoToml; - }; - - crateRegistries = self.registryFromDownloadUrl { - dl = "https://static.crates.io/crates"; - indexUrl = "https://github.com/rust-lang/crates.io-index"; - }; - - downloadCargoPackage = callPackage ./downloadCargoPackage.nix { }; - downloadCargoPackageFromGit = callPackage ./downloadCargoPackageFromGit.nix { }; - filterCargoSources = callPackage ./filterCargoSources.nix { }; - findCargoFiles = callPackage ./findCargoFiles.nix { }; - inheritCargoArtifactsHook = callPackage ./setupHooks/inheritCargoArtifacts.nix { }; - installCargoArtifactsHook = callPackage ./setupHooks/installCargoArtifacts.nix { }; - installFromCargoBuildLogHook = callPackage ./setupHooks/installFromCargoBuildLog.nix { }; - mkCargoDerivation = callPackage ./mkCargoDerivation.nix { }; - mkDummySrc = callPackage ./mkDummySrc.nix { }; - - overrideToolchain = toolchain: self.overrideScope (_final: _prev: { - cargo = toolchain; - clippy = toolchain; - rustc = toolchain; - rustfmt = toolchain; - }); - - path = callPackage ./path.nix { - inherit internalCrateNameForCleanSource; - }; - - registryFromDownloadUrl = callPackage ./registryFromDownloadUrl.nix { }; - registryFromGitIndex = callPackage ./registryFromGitIndex.nix { }; - registryFromSparse = callPackage ./registryFromSparse.nix { }; - removeReferencesToVendoredSourcesHook = callPackage ./setupHooks/removeReferencesToVendoredSources.nix { }; - replaceCargoLockHook = callPackage ./setupHooks/replaceCargoLockHook.nix { }; - urlForCargoPackage = callPackage ./urlForCargoPackage.nix { }; - vendorCargoDeps = callPackage ./vendorCargoDeps.nix { }; - vendorMultipleCargoDeps = callPackage ./vendorMultipleCargoDeps.nix { }; - vendorCargoRegistries = callPackage ./vendorCargoRegistries.nix { }; - vendorGitDeps = callPackage ./vendorGitDeps.nix { }; - writeTOML = callPackage ./writeTOML.nix { }; -})) +lib.warnIf isUnsupported msg (craneSpliced) diff --git a/lib/downloadCargoPackageFromGit.nix b/lib/downloadCargoPackageFromGit.nix index e8c0c39..e5c276c 100644 --- a/lib/downloadCargoPackageFromGit.nix +++ b/lib/downloadCargoPackageFromGit.nix @@ -1,5 +1,6 @@ { lib , cargo +, craneUtils , jq , pkgsBuildBuild }: @@ -8,8 +9,6 @@ let inherit (pkgsBuildBuild) fetchgit stdenv; - - craneUtils = pkgsBuildBuild.callPackage ../pkgs/crane-utils { }; in { git , rev