blob: 796ee537e5fe855e144c349117efae60e0cb1d96 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
{ config, lib, pkgs, ... }:
with import <stockholm/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
|