[Nix-dev] recursiveUpdate for lists

Игорь Пашев pashev.igor at gmail.com
Tue Oct 11 17:42:40 CEST 2016


2016-10-11 16:44 GMT+03:00 Tomasz Czyż <tomasz.czyz at gmail.com>:
> Basically I created simple wrapper function to create systemd services.
>
> The function produces something like
>
> {
>   my-service={
>     requires=["service1.service"];
>   };
> }
>
> I want to customize it after with recursiveUpdate function, I want to merge
> it with
>
> {
>   my-service={
>     requires=["some-other.service"]
>   };
> }
>
> I tried to avoid module stuff as in that case if I understand correctly I
> need to prepare my description of systemd service on top of standard nix
> systemd config structures which is probably big waste.
>
> What do you think?


I don't think it's a waste :-)

I'd and I really go with modules, because it's clean:


options = {
 # you options, like attrsOf str
};

config = {
 systemd.services = ... # here you map your options (merged for you
already!) to systemd options.
};

And, apparently, existing modules already do merge for you:
https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/system/boot/systemd-unit-options.nix#L86


More information about the nix-dev mailing list