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

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

  config = let
    channelPath = "/etc/nix/channels/nixpkgs";
  in
    mkIf cfg.enable {
      nix = {
        package = mkDefault pkgs.nixFlakes;

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

        settings = {
          auto-optimise-store = true;
          experimental-features = ["nix-command" "flakes" "auto-allocate-uids" "repl-flake"];
        };

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

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