[Nix-dev] joining attribute sets recursively

Florian Friesdorf flo at chaoflow.net
Mon Jan 16 15:37:44 CET 2012


Hi,

I'd like to extend power-management.nix with an aggressive setting:

      aggressive = mkOption {
        default = false;
        description =
          ''
            Whether to enable aggressive power management features. An
            area for experimentation. Please send feedback about this
            to the list.
          '';
      };

and:

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

Now for one the syntax is incorrect and for another
powerManagement.cpuFreqGovernor would not be set, as powerManagement
will be overriden with the value from the second attribute set.

Is there a way to recursively merge attribute sets, so that
cpuFreqGovernor and scsiLinkPolicy would be set in powerManagement?

How can I achieve the conditional merge?

I tried:

config = mkIf cfg.enable ({
  ...
} // (if cfg.aggressive then {
  ...
} else { }));

--> infinite recursion

regards
florian
-- 
Florian Friesdorf <flo at chaoflow.net>
  GPG FPR: 7A13 5EEE 1421 9FC2 108D  BAAF 38F8 99A3 0C45 F083
Jabber/XMPP: flo at chaoflow.net
IRC: chaoflow on freenode,ircnet,blafasel,OFTC
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
Url : http://lists.science.uu.nl/pipermail/nix-dev/attachments/20120116/5e05556a/attachment.bin 


More information about the nix-dev mailing list