summaryrefslogtreecommitdiffstats
path: root/lib/meta.nix
diff options
context:
space:
mode:
authorJan Malakhovski <oxij@oxij.org>2018-11-18 08:26:13 +0000
committerJan Malakhovski <oxij@oxij.org>2018-11-22 08:59:48 +0000
commit1b3629ef3491cac741f8b00ce116a44c1cc914f9 (patch)
tree9e30a383b036270d2143ccdfe166b8044c868ed4 /lib/meta.nix
parent3ae0407d3c9dbb7cdf049b69ebb32e62c39357e7 (diff)
lib: implement `setPrio`
For when `hiPrio` and `lowPrio` are not enough.
Diffstat (limited to 'lib/meta.nix')
-rw-r--r--lib/meta.nix11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/meta.nix b/lib/meta.nix
index 199030c103af..2e83c4247ddf 100644
--- a/lib/meta.nix
+++ b/lib/meta.nix
@@ -41,16 +41,18 @@ rec {
let x = builtins.parseDrvName name; in "${x.name}-${suffix}-${x.version}");
- /* Apply a function to each derivation and only to derivations in an attrset
+ /* 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;
+ /* Set the nix-env priority of the package.
+ */
+ setPrio = priority: addMetaAttrs { inherit priority; };
/* 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;
-
+ lowPrio = setPrio 10;
/* Apply lowPrio to an attrset with derivations
*/
@@ -60,8 +62,7 @@ rec {
/* 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;
-
+ hiPrio = setPrio (-10);
/* Apply hiPrio to an attrset with derivations
*/