summaryrefslogtreecommitdiff
path: root/modules/base/default.nix
blob: d5c0dc9107479df2c080ebe40a620a00e0ef1620 (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
55
56
{
  config,
  lib,
  pkgs,
  ...
}: let
  cfg = config.base;
  inherit (lib) mkDefault mkEnableOption mkIf;
in {
  options.base.enable = mkEnableOption "base module";

  imports = [
    ./documentation.nix
    ./packages.nix
  ];

  config = let
    channelPath = "/etc/nix/channels/nixpkgs";
  in
    mkIf cfg.enable {
      base = {
        documentation.enable = mkDefault true;
        defaultPackages.enable = mkDefault true;
      };

      nix = {
        package = mkDefault pkgs.nixFlakes;

        gc = {
          automatic = mkDefault true;
          dates = mkDefault "weekly";
          options = mkDefault "--delete-older-than 7d";
        };

        settings = {
          auto-optimise-store = true;
          warn-dirty = false;
          experimental-features = ["nix-command" "flakes"];
          trusted-substituters = [
            "https://nix-community.cachix.org"
          ];
          trusted-public-keys = [
            "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
          ];
        };

        nixPath = [
          "nixpkgs=${channelPath}"
        ];
      };

      systemd.tmpfiles.rules = [
        "L+ ${channelPath}     - - - - ${pkgs.path}"
      ];
    };
}