[Nix-dev] joining attribute sets recursively

Eelco Dolstra e.dolstra at tudelft.nl
Mon Jan 16 16:50:10 CET 2012


On 16/01/12 15:37, Florian Friesdorf wrote:

> config = mkIf cfg.enable {
>   ...
>   powerManagement.cpuFreqGovernor = "ondemand";
> } // cfg.aggressive ? {
>   ...
>   powerManagement.scsiLinkPolicy = "min_power";
> } : {};

Indeed it would be good to have a way of writing this down in a nice way.
(Using two different modules as Marc suggested isn't very elegant.)  Maybe
something like

  config = mkUnion
    [ (mkIf cfg.foo {
        ... attrs ...
      })
      (mkIf cfg.bar {
        ... attrs ...
      })
      ...
    ];

-- 
Eelco Dolstra | http://www.st.ewi.tudelft.nl/~dolstra/


More information about the nix-dev mailing list