about summary refs log tree commit diff
path: root/modules/nixpkgs.nix
blob: 1e55876472e9dd8e7dc552165575452e57b44ee7 (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
{ config, lib, ... }:

let
  allowedUnf = config.nixpkgs.allowedUnfree;
  allowedIns = config.nixpkgs.allowedInsecure;
in
{
  options.nixpkgs = {
    allowedUnfree = lib.mkOption {
      type = lib.types.listOf lib.types.str;
      default = [ ];
      description = ''
        Allows for unfree packages by their name.
      '';
    };

    allowedInsecure = lib.mkOption {
      type = lib.types.listOf lib.types.str;
      default = [ ];
      description = ''
        Allows for insecure packages by their name.
      '';
    };
  };

  config = lib.mkMerge [
    (lib.mkIf
      (allowedUnf != [ ])
      { nixpkgs.config.allowUnfreePredicate = (pkg: __elem (lib.getName pkg) allowedUnf); })
    (lib.mkIf
      (allowedIns != [ ])
      { nixpkgs.config.allowInsecurePredicate = (pkg: __elem (lib.getName pkg) allowedIns); })
  ];
}