On Sun, Aug 17, 2014 at 6:33 AM, Roger Qiu <[email protected]> wrote: > You mean something like this? > > something.enable = mkDefault 101 true; # at 101 > something.enable = false; # at 100
something.enable = mkDefault true; # at 1000 [1] something.enable = false; # at 100 [1] https://github.com/NixOS/nixpkgs/blob/master/lib/modules.nix#L318 > Or something like: > > something.enable = true; # at 100 > something.enable = mkOverride 99 false; # at 99 > > In both cases the second something.enable has a lower priority than the > original statement. Yes, this is what I mean. > Would have prefered if this overriding could be done similar to CSS, so > later definitions would always override prior definitions unless specified > to be immutable. Modules have no ordering, one module can be imported from any other and made visible to all. There is no redefinition, only multiple definitions with different properties (mkOverride, mkOrder, mkIf, mkMerge). A global ordering based on the order of modules does not makes sense, as the mkOverride and mkOrder are highlighting. We have 2 properties to express 2 different kinds of ordering, one which is used to hide definitions with lower priorities, and the other which is used to sort definitions before giving them to the "merge" function of the option. Ordering based on the imports order would not make any sense because this would then depend on the traversal made of these imports, and I do not think that basing any choice on such "unknown thing" makes sense to users. > On 17/08/2014 2:03 AM, Nicolas Pierron wrote: >> >> Hi Roger, >> >> Sorry for the late answer. >> >> On Mon, Jul 7, 2014 at 8:50 AM, Roger Qiu <[email protected]> >> wrote: >>> >>> I was wondering if there's a way to override Nix expressions. >> >> I think you are specifically talking about NixOS modules, right? >> >>> Say I define a Nix expressions such as: >>> >>> something.enable = true; >>> >>> But later on I decide to change it to: >>> >>> something.enable = false; >> >> What you are looking for is having a higher priority for the new >> option definition, or a lower one for the all option definition. >> >> something.enable = mkOverride 99 false; >> >> The default priority is 100, smaller means that it would be taken first. >> >> mkDefault can be used the opposite way, to define a default value >> (with a smaller priority) in a module based on other options value. >> This is useful to define sane relations, while having the default >> syntax work by default to override the the option, if the default is >> not satisfying. >> > > -- > Founder of Polycademy & SnapSearch > http://polycademy.com > https://snapsearch.io > +61420925975 > -- Nicolas Pierron http://www.linkedin.com/in/nicolasbpierron - http://nbp.name/ _______________________________________________ nix-dev mailing list [email protected] http://lists.science.uu.nl/mailman/listinfo/nix-dev
