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

Replace overridePythonAttrs with overrideArgs, add for Rust and Go as well #46842

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

alyssais
Copy link
Member

@alyssais alyssais commented Sep 18, 2018

Motivation for this change

This allows, eg, specifying a custom src to use a different version of a package, like overrideAttrs does for normal packages, or overridePythonAttrs for Python packages.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

alyssais added a commit to alyssais/nixpkgs that referenced this pull request Sep 27, 2018
This allows, eg, patches that require extraSrcs to be applied to Go
packages. It's similar to `overridePythonAttrs`, and to the
`overrideRustAttrs` function I propose in
NixOS#46842.
alyssais added a commit to alyssais/nixpkgs that referenced this pull request Sep 28, 2018
This allows, eg, patches that require extraSrcs to be applied to Go
packages. It's similar to `overridePythonAttrs`, and to the
`overrideRustAttrs` function I propose in
NixOS#46842.
@matthewbauer
Copy link
Member

Maybe we should normalize this name to something like overrideArgs or something... This kind of thing could become common across different packages.

@alyssais
Copy link
Member Author

I think that would be a good idea, especially since I've already needed overrideGoAttrs (#47425). overrideArgs isn't a very clear name – I'd expect that to do what override does now, but maybe there isn't a better one. I'll have a go at implementing it anyway, converting what already exists, and we could change the name if we think of a better one.

This will allow consistency between override functions for various
language-specific build functions.
This allows, eg, specifying a custom src to use a different version
of a package, like overrideAttrs does for normal packages, or
overrideArgs for Python packages.
@alyssais alyssais requested a review from FRidh as a code owner October 21, 2018 15:52
@alyssais alyssais changed the title buildRustPackage: add overrideRustAttrs to output Replace overridePythonAttrs with overrideArgs, add for Rust and Go as well Oct 21, 2018
@alyssais
Copy link
Member Author

I’ve renamed overridePythonAttrs to overrideArgs, done the same for overrideRustAttrs, and added one for Go to replace #47425.

This allows, eg, patches that require extraSrcs to be applied to Go
packages. It's similar to `overrideArgs` in `buildPythonPackage` and
`buildRustPackage`.
@FRidh
Copy link
Member

FRidh commented Oct 22, 2018

I am against renaming the functions in this PR. overridePythonAttrs is used a lot outside of Nixpkgs already and I don't want to do any such ad-hoc standardization without going through an RFC where we identify and decide on parts to standardize.

@alyssais
Copy link
Member Author

Going through an RFC makes sense I suppose

@alyssais
Copy link
Member Author

@matthewbauer would you be willing to co-author an RFC?

@FRidh
Copy link
Member

FRidh commented Jan 4, 2019

  • overrideDerivation is used to override the call to derivation
  • overrideAttrs is used to override the call to stdenv.mkDerivation
  • override is used to override the last function call. Often this will be the callPackage call.
  • overridePythonAttrs is used to override the call to buildPython*.

@alyssais what you are interested in, overrideArgs, is having a standard call to build*Package functions.

The buildPython* function calls stdenv.mkDerivation with a modified set of arguments that were passed to itself. In the case of Python packages there is no valid reason for using overrideAttrs anymore. Seeing that, and assuming it's the same for other build*Package functions, we could say these build*Package functions should simply use overrideAttrs for overriding the call to them.

@alyssais
Copy link
Member Author

alyssais commented Jan 6, 2019 via email

@FRidh
Copy link
Member

FRidh commented Jan 6, 2019

In the case of buildPython*, everything that's given is passed along to stdenv.mkDerivation, it's just that along the way it modifies some attributes. At the time when I added this it was hard to say whether reusing overrideAttrs for this would be a problem, but in retrospect I think it could have been fine.

I agree with you that it could be confusing if a build*Package.overrideAttrs behaves somewhat differently from stdenv.mkDerivation.overrideAttrs. So that would be a good argument against reusing overrideAttrs.

@CMCDragonkai
Copy link
Member

Why stop at python, go and rust. I want this in Haskell too and everything else.

@FRidh
Copy link
Member

FRidh commented Mar 17, 2020

#82772 maps overrideAttrs to overridePythonAttrs. Maybe this can be done with the other builders as well?

@FRidh
Copy link
Member

FRidh commented Mar 17, 2020

RFC proposal https://github.com/NixOS/rfcs/compare/master...FRidh:overrideattrs?expand=1
Shall we go through with that?

@danbst
Copy link
Contributor

danbst commented Mar 17, 2020

@FRidh would it be hard to actually define full builder hierarchy for this RFC? Of top of my head, there are:

* derivation { }
** stdenv.mkDerivation {}
*** runCommand* {} and other trivial builders (writeFile, writeScript, writeScriptBin)
**** buildEnv
***** python.withPackages {}
*** python.pkgs.buildPythonPackage {}
*** python.pkgs.buildPythonApplication {}
*** mkDerivation {} # <-- Qt (!) TODO rename
*** androidenv.buildApp {}

there are many more, but at least it would good to know that python.withPackages is a different branch than buildPythonApplication, and it can also be overriden.

Maybe this hierarchy can be crowdsourced as part of RFC

@FRidh
Copy link
Member

FRidh commented Mar 18, 2020

@danbst I've opened a PR now, please post on NixOS/rfcs#67

@stale
Copy link

stale bot commented Aug 4, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 4, 2021
@nyabinary
Copy link
Contributor

This should be closed, right? Since it uh pretty stale

@wegank wegank marked this pull request as draft March 20, 2024 14:59
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 20, 2024
@wegank wegank added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants