On Mon, 16 Jan 2012 16:50:10 +0100, Eelco Dolstra <[email protected]> wrote: > 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 ... > }) > ... > ];
hmm - not sure whether mkUnion or mkMerge (as Marc suggests) cuts
it. The term *merge* is pretty generic and it would depend on a merge
algorithm what happens. A union for sets is defined as all elements
without duplicates, with a quick search I could not find a definition
for key/val pairs / associative arrays / attribute sets. Maybe looking
at the possible behaviours helps finding a name:
mkX [ {
a = 1;
b = 1;
c.a = 1;
} {
b = 2;
c.b = 2;
d = 2;
} ]
possible results:
- error because of colliding b
- first value taken: { a = 1; b = 1; c = { a = 1; b = 2 }; d = 2}
- last value taken: { a = 1; b = 2; c = { a = 1; b = 2 }; d = 2}
- both values taken: { a = 1; b = [1 2]; c = { a = 1; b = 2 }; d = 2}
--
Florian Friesdorf <[email protected]>
GPG FPR: 7A13 5EEE 1421 9FC2 108D BAAF 38F8 99A3 0C45 F083
Jabber/XMPP: [email protected]
IRC: chaoflow on freenode,ircnet,blafasel,OFTC
pgpVss9v3soS0.pgp
Description: PGP signature
_______________________________________________ nix-dev mailing list [email protected] http://lists.science.uu.nl/mailman/listinfo/nix-dev
