[Nix-dev] Overwriting or merging Nix expressions

Nicolas Pierron nicolas.b.pierron at gmail.com
Sat Aug 16 18:03:36 CEST 2014


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.

-- 
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron - http://nbp.name/


More information about the nix-dev mailing list