summaryrefslogtreecommitdiff
path: root/parts/modules/nixos/base/nix.nix
blob: 3dcac11c40bdb2983b3e4fd23bf30b13dc3307d1 (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
{
  config,
  lib,
  inputs,
  ...
}: let
  inherit (builtins) attrNames map;
  inherit (lib) mkDefault mkIf;
  cfg = config.base.nix-settings;

  channelPath = i: "/etc/nix/channels/${i}";

  mapInputs = fn: map fn (attrNames inputs);
in {
  config = mkIf cfg.enable {
    nix = {
      nixPath = mapInputs (i: "${i}=${channelPath i}");
      gc.dates = mkDefault "weekly";
    };

    systemd.tmpfiles.rules =
      mapInputs (i: "L+ ${channelPath i}     - - - - ${inputs.${i}.outPath}");
  };
}