Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildRustPackage: add overrideRust attribute #288430

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

9999years
Copy link
Contributor

This lets you write code like this:

let
  pkgs = import <nixpkgs> {};
  version = "0.1.15";
in
pkgs.ruff.overrideRust {
  inherit version;

  src = pkgs.fetchFromGitHub {
    owner = "astral-sh";
    repo = "ruff";
    rev = "v${version}";
    hash = "sha256-DzdzMO9PEwf4HmpG8SxRJTmdrmkXuQ8RsIchvsKstH8=";
  };

  cargoHash = "sha256-MpiWdNUs66OGYfOJo1kJQTCqjrk/DAYecaLf6GUUKew=";

  patches = [];
}

Previously, it was essentially impossible to override cargoHash.

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Feb 13, 2024
@winterqt
Copy link
Member

winterqt commented Feb 13, 2024

Functionality-wise, this looks like a dupe of #194475.

@9999years
Copy link
Contributor Author

It doesn't look like #194475 is moving forward (it hasn't been reviewed in over a year). Can we get this merged as a stopgap measure and plan to replace it with a better solution when one becomes available?

The perfect is the enemy of the good, and this PR is small and addresses a very inconvenient missing feature in rustPlatform.

Copy link
Contributor

@r-vdp r-vdp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried it out and it worked well! This makes it so much easier to override rust packages.

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Jun 26, 2024
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/how-do-you-override-the-commit-rev-used-by-a-rust-package/47698/5

# Derivations built with `buildRustPackage` can already be overridden with
# `override`, `overrideAttrs`, and `overrideDerivation`.
# This function introduces `overrideRust` and it overrides the call to
# `buildRustPackage`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some motivation would be nice.

Suggested change
# `buildRustPackage`.
# `buildRustPackage`. This is useful for ...

@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: merge conflict This PR has merge conflicts with the target branch 6.topic: rust 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux 12.approvals: 1 This PR was reviewed and approved by one reputable person
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants