summary refs log tree commit diff
path: root/lib
diff options
context:
space:
mode:
authorMichael Raskin <7c6f434c@mail.ru>2019-01-18 08:23:31 +0000
committerGitHub <noreply@github.com>2019-01-18 08:23:31 +0000
commit4d0e1b792fe859c7e06dd9b6d60068d4da6e2cd2 (patch)
treee1bdf34608a3afe214bf7b49841df590115d72c7 /lib
parent9f5b5fee9c4c13c1495ecbe042a651ad033aad6d (diff)
parent1b3629ef3491cac741f8b00ce116a44c1cc914f9 (diff)
downloadnixpkgs-4d0e1b792fe859c7e06dd9b6d60068d4da6e2cd2.tar
nixpkgs-4d0e1b792fe859c7e06dd9b6d60068d4da6e2cd2.tar.gz
nixpkgs-4d0e1b792fe859c7e06dd9b6d60068d4da6e2cd2.tar.bz2
nixpkgs-4d0e1b792fe859c7e06dd9b6d60068d4da6e2cd2.tar.lz
nixpkgs-4d0e1b792fe859c7e06dd9b6d60068d4da6e2cd2.tar.xz
nixpkgs-4d0e1b792fe859c7e06dd9b6d60068d4da6e2cd2.tar.zst
nixpkgs-4d0e1b792fe859c7e06dd9b6d60068d4da6e2cd2.zip
Merge pull request #50561 from oxij/lib/setPrio
lib: implement `setPrio`
Diffstat (limited to 'lib')
-rw-r--r--lib/default.nix2
-rw-r--r--lib/meta.nix11
2 files changed, 7 insertions, 6 deletions
diff --git a/lib/default.nix b/lib/default.nix
index 48eb99a7198..d400907ebb0 100644
--- a/lib/default.nix
+++ b/lib/default.nix
@@ -94,7 +94,7 @@ let
       callPackageWith callPackagesWith extendDerivation hydraJob
       makeScope;
     inherit (meta) addMetaAttrs dontDistribute setName updateName
-      appendToName mapDerivationAttrset lowPrio lowPrioSet hiPrio
+      appendToName mapDerivationAttrset setPrio lowPrio lowPrioSet hiPrio
       hiPrioSet;
     inherit (sources) pathType pathIsDirectory cleanSourceFilter
       cleanSource sourceByRegex sourceFilesBySuffices
diff --git a/lib/meta.nix b/lib/meta.nix
index 199030c103a..2e83c4247dd 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
   */