lib/modules: implement a way to override a property based on its previous value#286578
lib/modules: implement a way to override a property based on its previous value#286578nrabulinski wants to merge 1 commit intoNixOS:masterfrom
Conversation
|
@infinisil I read through those PRs and while similar, I don't think they are quite the same and, in my humble opinion, my proposal, assuming someone would come in and fully implement it, could prove more useful and composable. From what I understand it, neither of those previously suggested approaches work with priorities. Instead, the one @roberth suggested transforms a default value, while the one by @babbaj transforms the value of the current priority, which introduces more complexity and problems than it solves. |
|
Also, neither contains real-world usecases except for removing a value from a list, which could easily be solved with other solutions, while the ones I showed I can't really see how else one could solve. And while |
|
I'm not sure that we should have this. Encoding logic into priority numbers is ultimately just not an easy to understand concept, and it is not declarative. I've closed my own PR for this reason.
Did you try it? I'm pretty sure it uses the next priority in line; not just Not to give you false hope, but in general I would recommend to split out refactorings from the actual change, into separate commits, because there's a lot going on in the diff that's not essential. |
Naturally, which is why the commit message says it's a proof-of-concept implementation and why I repeatedly state that the implementation is not complete and, in fact, it's broken 😃 |
You're right, I didn't try it, I just read your PR and saw that you moved to #157070 and that's what I based my opinion on.
And what makes you feel like |
By making the overriding feature more capable and complex, we remove an incentive to write good declarative modules that properly support the use cases that might also be achievable with |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/remove-from-list-in-nixos-module-or-homemanager/54761/6 |
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: |
Description of changes
This is by no means meant to be a complete implementation. It's in fact suboptimal and not even fully functional, but I got it done to show that it's possible and that it could prove useful.
My idea is to introduce
mkOverrideWith(name subject to change) which would work like the currentmkOverridewith one caveat: instead of taking an attrset it takes a lambda, which accepts the next highest priority value as its argument. This allows to set a new value for a given property while reusing the previous value.Why would this be useful
Personally I see one big upside of having a mechanism like this: not having to introduce IFD or having to resort to
extendModules.Examples:
extendModulesor other suboptimal solutions. While what I'm proposing here still wouldn't be ideal (I'm happy for someone more knowledgable about the module system to come up with a better solution based on this idea), you could potentially do something like thisThings done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-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.