aboutsummaryrefslogtreecommitdiff
path: root/lib/meta.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-10 13:28:21 +0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-10-10 13:28:21 +0200
commit5fef92c4a0c91153e3edac3a61a232581765074a (patch)
tree291d684d0ef71e200e6d8ab5c33fc1aca467cbb3 /lib/meta.nix
parent2a537fb369d1479748fe233261eaadfa5c2fa930 (diff)
Move pkgs/lib/ to lib/
Diffstat (limited to 'lib/meta.nix')
-rw-r--r--lib/meta.nix48
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/meta.nix b/lib/meta.nix
new file mode 100644
index 000000000000..a5afce9e0cb1
--- /dev/null
+++ b/lib/meta.nix
@@ -0,0 +1,48 @@
+/* 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;
+
+ /* Increase the nix-env priority of the package, i.e., this
+ version/variant of the package will be preferred.
+ */
+ hiPrio = drv: addMetaAttrs { priority = "-10"; } drv;
+
+}