summaryrefslogtreecommitdiffstats
path: root/krebs/3modules/nixpkgs.nix
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2016-02-11 21:31:15 +0100
committermakefu <github@syntax-fehler.de>2016-02-11 21:31:15 +0100
commit014cbb7598c5d45cfc4cc7e1ec81c92e000eabfb (patch)
treefab0e894948010cd73be18ad2c68cd4750bd2419 /krebs/3modules/nixpkgs.nix
parent8ecdb889dd3081ba29c6ea7eb35f60b30420d201 (diff)
parent7b3b839cc7a2af73dee9858e6ebcc7be831eb481 (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..4129f9483
--- /dev/null
+++ b/krebs/3modules/nixpkgs.nix
@@ -0,0 +1,43 @@
+{ config, pkgs, lib, ... }:
+with lib;
+let
+ cfg = config.krebs.nixpkgs;
+
+ out = {
+ options.krebs.nixpkgs = api;
+ config = 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 = mkIf (cfg.allowUnfreePredicate != null) {
+ nixpkgs.config.allowUnfreePredicate = cfg.allowUnfreePredicate;
+ };
+in out