[Nix-dev] Overwriting or merging Nix expressions

Roger Qiu roger.qiu at polycademy.com
Tue Jul 8 00:45:37 CEST 2014


Hello Wout,

Do you mean something like this:

# Inside B.nix
something.enable = true;

# Inside A.nix that imports B.nix
something.enable // false;

The link you sent me didn't give an example of overwriting a previous 
expression.

Also what about the merging of:

services.cron.enable = false;

services = {
      other.stuff = blah;
};

Are you saying that I need to overwrite the whole services.cron.enable 
with services // {}.. etc?

Thanks,
Roger

On 8/07/2014 3:08 AM, Wout Mertens wrote:
> Hi Roger,
>
> to override in this way, you can merge attribute sets with the // 
> operator, which will prefer the attribute on the right-hand side.
>
> http://nixos.org/nix/manual/#idm47361539098656
>
> you get the duplicate error because the language is functional, 
> everything at the same level is evaluated at the same time. You can 
> enforce ordering with let.
>
> Wout.
>
>
> On Mon, Jul 7, 2014 at 8:50 AM, Roger Qiu <roger.qiu at polycademy.com 
> <mailto:roger.qiu at polycademy.com>> wrote:
>
>     Hello Nix Devs,
>
>     I was wondering if there's a way to override Nix expressions.
>
>     Say I define a Nix expressions such as:
>
>     something.enable = true;
>
>     But later on I decide to change it to:
>
>     something.enable = false;
>
>     Would this work? I find myself getting duplicate errors. One time
>     I had
>     something like this:
>
>     services.cron.enable = false;
>
>     services = {
>          other.stuff = blah;
>     };
>
>     And this resulted in a duplicate error. This example is actually
>     more to
>     do with merging rather than conflicting entries.
>
>     However, say if I had a nix file called B.nix, and in A.nix I imported
>     B.nix, I may sometimes want to overwrite that was in B. I find myself
>     needing to do this with the generated hardware-configuration.nix file.
>
>     Thanks,
>     Roger
>
>     --
>     Founder of Polycademy & SnapSearch
>     http://polycademy.com
>     https://snapsearch.io
>     +61420925975 <tel:%2B61420925975>
>
>     _______________________________________________
>     nix-dev mailing list
>     nix-dev at lists.science.uu.nl <mailto:nix-dev at lists.science.uu.nl>
>     http://lists.science.uu.nl/mailman/listinfo/nix-dev
>
>

-- 
Founder of Polycademy & SnapSearch
http://polycademy.com
https://snapsearch.io
+61420925975

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.science.uu.nl/pipermail/nix-dev/attachments/20140708/dfce72d4/attachment.html 


More information about the nix-dev mailing list