summaryrefslogtreecommitdiffstats
path: root/krebs/3modules/nixpkgs.nix
diff options
context:
space:
mode:
authorlassulus <lass@aidsballs.de>2016-02-16 17:15:00 +0100
committerlassulus <lass@aidsballs.de>2016-02-16 17:15:00 +0100
commit0b0b0d65ee05583529df831985580e392713d29a (patch)
tree7eb6799a996924d8e895c54633a47ea3d7a92a4c /krebs/3modules/nixpkgs.nix
parent3d30e9cc9014ec6189410944015d3cd7d5ca95a6 (diff)
parentb7a92f63884af00eb0243ec9328be689a6c9b845 (diff)
Merge remote-tracking branch 'cd/master'
Diffstat (limited to 'krebs/3modules/nixpkgs.nix')
-rw-r--r--krebs/3modules/nixpkgs.nix43
1 files changed, 43 insertions, 0 deletions
diff --git a/krebs/3modules/nixpkgs.nix b/krebs/3modules/nixpkgs.nix
new file mode 100644
index 000000000..5816b8a30
--- /dev/null
+++ b/krebs/3modules/nixpkgs.nix
@@ -0,0 +1,43 @@
+{ config, lib, pkgs, ... }:
+with config.krebs.lib;
+let
+ cfg = config.krebs.nixpkgs;
+
+ out = {
+ options.krebs.nixpkgs = api;
+ config = lib.mkIf cfg.enable imp;
+ };
+
+ api = {
+ enable = mkEnableOption "krebs.nixpkgs" // { default = true; };
+
+ allowUnfreePredicate = mkOption {
+ description = ''
+ This option is similar to `nixpkgs.config.allowUnfreePredicate'
+ but can be defined in several modules. An unfree package will be
+ allowed if any of the defined predicates returns true.
+ '';
+ type = types.nullOr (mkOptionType {
+ name = "Predicate";
+ check = isFunction;
+ merge = _locs: defs: pkg: let
+ evalPredicateDef = def: let
+ allow = def.value pkg;
+ in if cfg.verbose && allow
+ then trace "unfree ‘${pkg.name}’ allowed in ${def.file}" allow
+ else allow;
+ in any evalPredicateDef defs;
+ });
+ default = null;
+ };
+
+ verbose = mkOption {
+ type = types.bool;
+ default = false;
+ };
+ };
+
+ imp = lib.mkIf (cfg.allowUnfreePredicate != null) {
+ nixpkgs.config.allowUnfreePredicate = cfg.allowUnfreePredicate;
+ };
+in out