I came across this issue as well and ended up with this solution before seeing this thread
The issue is overrideAttrrs
overrides the attribute set passed to stdenv.mkDerivation
, so you don’t have direct access to buildRustPackage
from my understanding
But you can just call override
instead. This has the advantage of also being able to override the rustc/cargo versions for when the latest version in nixpkgs isn’t up to date
My own flake is a bit complex because of my use of std/hive. So my snippet below is outside of the overlay context, and nixpkgs is an unaltered nixpkgs whereas pkgs is nixpkgs + overlays
And you do still need to have a local copy of the Cargo.toml like in the nixpkgs drv
et voila:
wezterm = nixpkgs.wezterm.override (
let
rustPlatform = nixpkgs.makeRustPlatform {
rustc = pkgs.rust-bin.stable.latest.minimal;
cargo = pkgs.rust-bin.stable.latest.minimal;
};
in
old: {
rustPlatform = old.rustPlatform // {
buildRustPackage =
args:
rustPlatform.buildRustPackage (
args
// rec {
pname = "wezterm";
version = "552bb1d66b6d0102961974c0da22dc7c69b0cd30";
src = nixpkgs.fetchFromGitHub {
owner = "wez";
repo = pname;
rev = version;
fetchSubmodules = true;
hash = "sha256-dr/f/zEqgzJ26s2KkiX6/68IU986jAYpeerRMSqejjM=";
};
cargoLock = {
lockFile = ./wezterm/Cargo.lock;
outputHashes = {
"sqlite-cache-0.1.3" = "sha256-sBAC8MsQZgH+dcWpoxzq9iw5078vwzCijgyQnMOWIkk=";
"xcb-imdkit-0.3.0" = "sha256-77KaJO+QJWy3tJ9AF1TXKaQHpoVOfGIRqteyqpQaSWo=";
};
};
}
);
};
}
);
references: