summaryrefslogtreecommitdiff
path: root/nixos/modules/nix.nix
blob: 635a96b78b5e605f841588c946a65666b7442db1 (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
44
45
46
47
48
49
50
51
52
53
54
{ config, lib, pkgs, ... }:
with lib;

let
  cfg = config.eth.nix;

  mozilla = import (builtins.fetchTarball
    "https://github.com/mozilla/nixpkgs-mozilla/archive/master.tar.gz");

  eth = import ../../pkgs;

in {
  options.eth.nix = {
    allowUnfree = mkOption {
      type = types.bool;
      description = "Allow non-free software.";
      default = false;
    };

    gc = {
      enable = mkEnableOption "Enable the garbage collector.";
      schedule = mkOption {
        type = types.str;
        default = config.nix.gc.dates;
        description = "A systemd.time(7) timespec";
      };
      olderThan = mkOption {
        type = types.str;
        default = "30d";
        description = "Garbage-collect NixOS configurations older than this.";
      };
    };

    overlays = {
      eth     = mkEnableOption "Eth (yours truly)";
      mozilla = mkEnableOption "Mozilla (Rust, Firefox, etc)";
    };
  };

  config = {
    nixpkgs.config.allowUnfree = cfg.allowUnfree;

    nix.gc = {
      automatic = cfg.gc.enable;
      dates = cfg.gc.schedule;
      options = "--delete-older-than ${cfg.gc.olderThan}";
    };

    nixpkgs.overlays = builtins.concatLists [
      ( if cfg.overlays.eth     then [ eth     ] else [] )
      ( if cfg.overlays.mozilla then [ mozilla ] else [] )
    ];
  };
}