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