-
-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 |
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: