diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2009-03-30 13:22:19 +0000 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2009-03-30 13:22:19 +0000 |
commit | 2405d872307fbeed7a29aff162c4f8172c30ca8f (patch) | |
tree | d2ca29ed80f9dfe198f4ff460a568609b20952fa /pkgs/lib/meta.nix | |
parent | 750592060568ee0dd914f47ae3cf82e86c5631c1 (diff) | |
download | nixlib-2405d872307fbeed7a29aff162c4f8172c30ca8f.tar nixlib-2405d872307fbeed7a29aff162c4f8172c30ca8f.tar.gz nixlib-2405d872307fbeed7a29aff162c4f8172c30ca8f.tar.bz2 nixlib-2405d872307fbeed7a29aff162c4f8172c30ca8f.tar.lz nixlib-2405d872307fbeed7a29aff162c4f8172c30ca8f.tar.xz nixlib-2405d872307fbeed7a29aff162c4f8172c30ca8f.tar.zst nixlib-2405d872307fbeed7a29aff162c4f8172c30ca8f.zip |
* Move some functions for manipulating meta and name attributes out of
all-packages.nix and into lib. svn path=/nixpkgs/trunk/; revision=14778
Diffstat (limited to 'pkgs/lib/meta.nix')
-rw-r--r-- | pkgs/lib/meta.nix | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/pkgs/lib/meta.nix b/pkgs/lib/meta.nix new file mode 100644 index 000000000000..56463361928f --- /dev/null +++ b/pkgs/lib/meta.nix @@ -0,0 +1,44 @@ +/* Some functions for manipulating meta attributes, as well as the + name attribute. */ + +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}"); + + + /* 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; + + +} |