about summary refs log tree commit diff
path: root/modules/cachix/default.nix
blob: 5222457c52b4c5402e17da1292ca084209a45a0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
{ config, pkgs, lib, ... }:

with lib;
let
  cfg = config.modules.cachix;

  folder = ./caches;
  toImport = name: value: folder + ("/" + name);
  filterCaches = key: value: value == "regular" && lib.hasSuffix ".nix" key;
  imports = lib.mapAttrsToList toImport (lib.filterAttrs filterCaches (builtins.readDir folder));
in
{
  inherit imports;

  options.modules.cachix = {
    enable = mkEnableOption "cachix";
  };

  config = mkIf cfg.enable {
    nix.settings.substituters = [ "https://cache.nixos.org/" ];
    environment.systemPackages = [ pkgs.cachix ];
  };
}