summaryrefslogtreecommitdiff
path: root/modules/nix-access-tokens/default.nix
blob: a3b7abfaa281ce90d185959472fe0f46c3205325 (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
{ lib, config, hostName ,... }:

let
  cfg = config.nix.includeAccessTokens;
in {
  options = {
    nix.includeAccessTokens.enable = lib.mkEnableOption "including access tokens in nix.conf" // { default = lib.elem hostName ["sif" "surtr" "vidhar"]; };
  };

  config = lib.mkIf cfg.enable {
    nix = {
      extraOptions = ''
        !include ${config.sops.secrets.nixAccessTokens.path}
      '';
    };

    sops.secrets.nixAccessTokens = {
      format = "binary";
      sopsFile = ./nix.conf;
      mode = "0440";
      group = "wheel";
    };
  };
}