-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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: refactor to support finalAttrs pattern #354999
base: master
Are you sure you want to change the base?
Conversation
12b63e7
to
bba2752
Compare
a9bea81
to
639e245
Compare
cfe8797
to
7552eb6
Compare
4b14c19
to
dd7fb2e
Compare
16d8715
to
3b3a29b
Compare
aaf0a62
to
e8cb71b
Compare
4e98efb
to
27d0957
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For easier review, could you format the file with nixfmt-rfc-style first and then make the appropriate changes for finalAttrs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And do make the changes atomically in seperate commits.
Like:
- Support finalAttrs pattern
- Improve overridebility
It was originally like that, however I had to rebase and merged them together temporarily. Will separate them again.
The reverse order would be better for me better: the support finalAttrs pattern was just 2 lines of change after having done the refactoring for overridability. |
Ah. I wonder if it would be better to split the override fix commit into a seperate PR. finalAttrs pattern with 0 rebuilds can target master while the overridability commit can't. Guess that won't be happening. |
55e78c0
to
3a08c15
Compare
3a08c15
to
975a1c1
Compare
I'll rebase onto staging once this PR is reviewed.
Note: the first commit is a cherry-pick from staging
Supersedes #194475
Supersedes #288430
Supersedes #340798
Similar PR that also does this for
buildGoPackage
: #353526TODO: check eval performance impact
This PR refactors the
buildRustPackage
wrapper aroundmkDerivation
to support thefinalAttrs
pattern better.A non-goal was having 0 rebuilds.
The rebuilds are because of more attrs actually being passed to
mkDerivation
, which improves overridability.Other than just being able to do something like
you'll also be able to override derivations much easier:
cargoLock
is something that can only be insidepassthru
, since it can't be converted to a string. This means that overriding needs to be done throughpassthru
. This is a bit painful, but at least it's possible.This means that to override a package that uses
cargoLock
to usecargoHash
, you will need to setpassthru.cargoLock
to null:You may also just override
cargoDeps
directly, like you would have done before this PR(
cargoDeps
can also be set directly frombuildCargoPackage
if, for some reason, you needed that)Note:
Having
@args
anda ? "default"
together can be error-prone and may lead to unexpected behaviour.Because of this, I opted to set default values by just setting them to the default and then expecting them to be overridden with
//
{ a = "default"; } // lib.removeAttrs args namesToRemove
I changed the wrapper to use
{ ~~~ } // args'
instead ofargs' // { ~~~ }
. This will makeargs'
shadow the values being set without us having to doa = args.a or "default"
everywhere. Though, when we don't want this (e.g. lists, where we'd rather combine with the original), we still door "default"
Above I used
args'
to denotelib.removeAttrs args namesToRemove
wherenamesToRemove
is a list of values that should not be blindly shadowing anything. Usually, these have some extra logic associated with them.Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.