at 17.09-beta 1.9 kB view raw
1/* Some functions for manipulating meta attributes, as well as the 2 name attribute. */ 3 4let lib = import ./default.nix; 5in 6 7rec { 8 9 10 /* Add to or override the meta attributes of the given 11 derivation. 12 13 Example: 14 addMetaAttrs {description = "Bla blah";} somePkg 15 */ 16 addMetaAttrs = newAttrs: drv: 17 drv // { meta = (drv.meta or {}) // newAttrs; }; 18 19 20 /* Disable Hydra builds of given derivation. 21 */ 22 dontDistribute = drv: addMetaAttrs { hydraPlatforms = []; } drv; 23 24 25 /* Change the symbolic name of a package for presentation purposes 26 (i.e., so that nix-env users can tell them apart). 27 */ 28 setName = name: drv: drv // {inherit name;}; 29 30 31 /* Like `setName', but takes the previous name as an argument. 32 33 Example: 34 updateName (oldName: oldName + "-experimental") somePkg 35 */ 36 updateName = updater: drv: drv // {name = updater (drv.name);}; 37 38 39 /* Append a suffix to the name of a package (before the version 40 part). */ 41 appendToName = suffix: updateName (name: 42 let x = builtins.parseDrvName name; in "${x.name}-${suffix}-${x.version}"); 43 44 45 /* Apply a function to each derivation and only to derivations in an attrset 46 */ 47 mapDerivationAttrset = f: set: lib.mapAttrs (name: pkg: if lib.isDerivation pkg then (f pkg) else pkg) set; 48 49 50 /* Decrease the nix-env priority of the package, i.e., other 51 versions/variants of the package will be preferred. 52 */ 53 lowPrio = drv: addMetaAttrs { priority = 10; } drv; 54 55 56 /* Apply lowPrio to an attrset with derivations 57 */ 58 lowPrioSet = set: mapDerivationAttrset lowPrio set; 59 60 61 /* Increase the nix-env priority of the package, i.e., this 62 version/variant of the package will be preferred. 63 */ 64 hiPrio = drv: addMetaAttrs { priority = -10; } drv; 65 66 67 /* Apply hiPrio to an attrset with derivations 68 */ 69 hiPrioSet = set: mapDerivationAttrset hiPrio set; 70 71}