Closed pseudoparenchymatous closed 1 month ago
nix build
/nix run
without problemFixed it by overlaying directly the rustc
and cargo
packages from nixpkgs
Nope. Overlaying rustc
and cargo
directly doesn't seem to be the correct way. It breaks other packages from nixpkgs that may rely on nixpkgs' derivation of rustc
/cargo
.
So what's the right way of telling crate2nix
to use/download/install rustc
/cargo
from another source other than nixpkgs?
Fixed it with
let
minimal-toolchain = fenix.packages.${system}.stable.minimalToolchain;
cargoNix = pkgs.callPackage ./Cargo.nix {
buildRustCrateForPkgs = pkgs: pkgs.buildRustCrate.override {
rustc = minimal-toolchain;
cargo = minimal-toolchain;
};
};
in packages.default = cargoNix.rootCrate.build;
I am using fenix as my rust overlay; installed it in my dev-shell using
nativeBuildInputs
. But when I runnix build
, it reinstalls the toolchain (i.e.rustc
) from nixpkgs.And if I remove nixpkgs from my inputs,
nix build
behaves as expected and builds the crate.