about summary refs log tree commit diff
path: root/modules/nix.nix
blob: 8396739d10d0e9b63df7fdafb09c1b15d75d3084 (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
  allowed = config.nix.allowedUnfree;
in
{
  options.nix = {
    experimentalFeatures = lib.mkOption {
      type = lib.types.separatedString " ";
      default = "";
      description = ''
        Enables experimental features
      '';
    };

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

  config = lib.mkMerge [
    (lib.mkIf (config.nix.experimentalFeatures != "") { nix.extraOptions = "experimental-features = ${config.nix.experimentalFeatures}"; })
    (lib.mkIf (allowed != [ ]) { nixpkgs.config.allowUnfreePredicate = (pkg: __elem (lib.getName pkg) allowed); })
    { nix.settings.auto-optimise-store = lib.mkDefault true; }
    {
      nix.gc.automatic = lib.mkDefault true;
      nix.gc.options = lib.mkDefault "--delete-older-than 10d";
    }
  ];
}