2009-03-30 17:22:19 +04:00
|
|
|
/* Some functions for manipulating meta attributes, as well as the
|
|
|
|
name attribute. */
|
|
|
|
|
2013-12-26 06:22:29 +04:00
|
|
|
let lib = import ./default.nix;
|
|
|
|
in
|
|
|
|
|
2009-03-30 17:22:19 +04:00
|
|
|
rec {
|
|
|
|
|
|
|
|
|
|
|
|
/* Add to or override the meta attributes of the given
|
|
|
|
derivation.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
addMetaAttrs {description = "Bla blah";} somePkg
|
|
|
|
*/
|
|
|
|
addMetaAttrs = newAttrs: drv:
|
|
|
|
drv // { meta = (if drv ? meta then drv.meta else {}) // newAttrs; };
|
|
|
|
|
|
|
|
|
|
|
|
/* Change the symbolic name of a package for presentation purposes
|
|
|
|
(i.e., so that nix-env users can tell them apart).
|
|
|
|
*/
|
|
|
|
setName = name: drv: drv // {inherit name;};
|
|
|
|
|
|
|
|
|
|
|
|
/* Like `setName', but takes the previous name as an argument.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
updateName (oldName: oldName + "-experimental") somePkg
|
|
|
|
*/
|
|
|
|
updateName = updater: drv: drv // {name = updater (drv.name);};
|
|
|
|
|
|
|
|
|
|
|
|
/* Append a suffix to the name of a package. !!! the suffix should
|
|
|
|
really be appended *before* the version, at least most of the
|
|
|
|
time.
|
|
|
|
*/
|
|
|
|
appendToName = suffix: updateName (name: "${name}-${suffix}");
|
|
|
|
|
|
|
|
|
2013-12-26 06:22:29 +04:00
|
|
|
/* Apply a function to each derivation and only to derivations in an attrset
|
|
|
|
*/
|
|
|
|
mapDerivationAttrset = f: set: lib.mapAttrs (name: pkg: if lib.isDerivation pkg then (f pkg) else pkg) set;
|
|
|
|
|
|
|
|
|
2009-03-30 17:22:19 +04:00
|
|
|
/* Decrease the nix-env priority of the package, i.e., other
|
|
|
|
versions/variants of the package will be preferred.
|
|
|
|
*/
|
|
|
|
lowPrio = drv: addMetaAttrs { priority = "10"; } drv;
|
|
|
|
|
2013-12-26 06:22:29 +04:00
|
|
|
|
|
|
|
/* Apply lowPrio to an attrset with derivations
|
|
|
|
*/
|
|
|
|
lowPrioSet = set: mapDerivationAttrset lowPrio set;
|
|
|
|
|
|
|
|
|
2010-07-22 12:59:46 +04:00
|
|
|
/* Increase the nix-env priority of the package, i.e., this
|
|
|
|
version/variant of the package will be preferred.
|
|
|
|
*/
|
2013-02-25 15:31:19 +04:00
|
|
|
hiPrio = drv: addMetaAttrs { priority = "-10"; } drv;
|
2013-12-26 06:22:29 +04:00
|
|
|
|
|
|
|
|
|
|
|
/* Apply hiPrio to an attrset with derivations
|
|
|
|
*/
|
|
|
|
hiPrioSet = set: mapDerivationAttrset hiPrio set;
|
2009-03-30 17:22:19 +04:00
|
|
|
|
|
|
|
}
|