[Nix-dev] Overwriting or merging Nix expressions

Roger Qiu roger.qiu at polycademy.com
Sun Aug 17 06:33:56 CEST 2014


Hello Nicolas,

You mean something like this?

something.enable = mkDefault 101 true; # at 101
something.enable = false; # at 100

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.

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.

Thanks,
Roger

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 <roger.qiu at polycademy.com> 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



More information about the nix-dev mailing list