summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/meta.nix19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/meta.nix b/lib/meta.nix
index a5afce9e0cb1..74e9cfb411c4 100644
--- a/lib/meta.nix
+++ b/lib/meta.nix
@@ -1,6 +1,9 @@
/* Some functions for manipulating meta attributes, as well as the
name attribute. */
+let lib = import ./default.nix;
+in
+
rec {
@@ -35,14 +38,30 @@ rec {
appendToName = suffix: updateName (name: "${name}-${suffix}");
+ /* 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;
+
+
/* 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;
+
+ /* Apply lowPrio to an attrset with derivations
+ */
+ lowPrioSet = set: mapDerivationAttrset lowPrio set;
+
+
/* 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;
+
+
+ /* Apply hiPrio to an attrset with derivations
+ */
+ hiPrioSet = set: mapDerivationAttrset hiPrio set;
}