-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
Defining variables with default values in package arguments can lead to problems #309892
Comments
Prefixing those variables with pname could also be an option. For example, in package zblarg, one could probably use zblargDoCheck, zblargPatches, zblargWithPython and zblargAaa with a minimal risk of a new unrelated package being named that. It would also be more explicit, as zblargWithPython and fooWithPython would be different, while var-withPython and var-withPython in packages zblarg and foo wouldn't be. And I think this is a common enough practice in various language and build systems already, so this wouldn't be too hard to adopt here. |
An example for when I've encountered this unexpected default populating logic was when taking in an |
Does NixOS/rfcs#169 at least partially address this issue? |
I would say that if you need to pass And if you are doing that trying to follow DRY or something, that is just more mess. Especially since using The boolean/enum feature parameters are also ugly but at least they typically follow consistent naming pattern that is unlikely to conflict. Lastly, as for internal packages, it might be fine if they are not overridable. They are often temporary or tied to the main derivation closely enough that the need to override them should be rare. Though if we really want to, …we could create a private scope and call the package from within – something like the example below. Then it would be just possible to use override like with any other package
|
So if you're doing a factory, but you still need a couple of inputs, that you'd rather not pass through, what would you recommend instead of auto-wiring with Is there room for a Arguably in hindsight, wouldn't that have been a better behavior for |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: |
So we have an unfortunate example now: #324199 uses I didn't initially realize that top-level attributes introduced by users through overlays might also affect our compatibility. |
I extended the docs for pkgs/by-name to discourage being more fancy than simple |
Another idea that would also help remove splicing but requires extending the nix language: { lib # ← could be in a "platformIndependent" set instead of top level
, sources
, options =
{ enableFoo ? true
, enableBar ? false
}
, buildHost =
{ stdenv
, cmake
, sometool
}
, hostTarget =
{ libfoo
, libbar
}
}:
stdenv.mkDerivation ... |
In a certain sense yes. @Atemu was working on a module system. |
I take issue with this. I converted ffmpeg to a new override API a while back where the source, version etc. are intentionally defined in the function parameters: #295691 (While doing so I also ran into the same issue @TomaSajt ran into.) This method explicitly exposes the This has proven to work well and have some very nice properties. Therefore I'd like propose the exact opposite to @flokli: Reserve names that are likely to be part of package APIs such as
This has been discussed in RFC 169.
It's actually quite simple to implement and upgrade existing flags defined as drv override inputs to a module system interface. IMHO it quite neatly solves this problem and one of the primary problems RFC 169 intends to resolve or at least removes quite a lot of limitations around it. We will need to figure out a way to measure the performance impact of such a module system before we can apply it more broadly. This is quite tricky as we'd need to actually convert override flags to mini module systems in order to measure the impact of it being used more widely. One idea I had on this would be to create an overlay which would generate a small module system for each package and force their eval by injecting their results via |
Could you provide a link to the discussion? The rfc page is long and there are a lot of collapsed threads |
Please check out this previous PR of mine, that was essentially done and could address this problem: |
Problem
To make overriding more feasible, people often write something like
But this is actually dangerous. We don't know when a top-level package named "doCheck", "patches" or "foo" will appear. While the first two can easily be found on ofBorg failures, the third might be quietly passed, causing more problems (and it even looks unrelated!).
Reproduce
This should be "1", right?
Well it's not.
Solution
My idea is that we set some "reserved attribute prefixes", such as names starting with "var-", and make sure that they cannot be used for top-level package names. We may also need to take the same approach for other sets that define
callPackage
.The text was updated successfully, but these errors were encountered: