From bdfcda81e763f2fe0b3285f18048428e6e95662a Mon Sep 17 00:00:00 2001 From: Evgeny Egorochkin Date: Thu, 26 Dec 2013 04:22:29 +0200 Subject: [PATCH] add lowPrioSet and hiPrioSet functions to enable changing of priorities of attrsets with packages such as kde. --- lib/meta.nix | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/meta.nix b/lib/meta.nix index a5afce9e0cb..74e9cfb411c 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; }