aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
blob: 5ec3a681caee30d0235aa501ada3eb8328451808 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
    nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
    nixpkgs-master.url = "github:NixOS/nixpkgs/master";
    flake-parts.url = "github:hercules-ci/flake-parts";
    nixinate.url = "github:maxaudron/nixinate";

    secrets = {
      url = "git+ssh://git@gitlab.com/cocainefarm/k8s/secrets";
      flake = false;
    };

    catinator.url = "gitlab:cocainefarm/catinator";
    pastor.url = "gitlab:cocainefarm/pastor/feature/nix";

    authentik-nix.url = "github:nix-community/authentik-nix";
  };

  outputs =
    inputs@{
      self,
      nixpkgs,
      nixpkgs-unstable,
      nixpkgs-master,
      flake-parts,
      nixinate,
      authentik-nix,
      ...
    }:
    flake-parts.lib.mkFlake { inherit inputs; } {
      imports = [
        nixinate.flakeModule
        ./lib
      ];
      flake =
        let
          system = "x86_64-linux";
          specialArgs = inputs // {
            nodes = self.nixosConfigurations;
          };

          overlay-unstable = final: prev: {
            unstable = import nixpkgs-unstable {
              system = prev.system;
              config.allowUnfree = true;
            };
          };
          overlay-master = final: prev: {
            master = import nixpkgs-master {
              system = prev.system;
              config.allowUnfree = true;
            };
          };

          overlays =
            { config, pkgs, ... }:
            {
              nixpkgs.overlays = [
                overlay-unstable
                overlay-master
              ];
            };

          mkSystem =
            modules:
            nixpkgs.lib.nixosSystem {
              inherit specialArgs system;
              modules =
                modules
                ++ (with self.nixosModules; [
                  nixinate.nixosModules.default
                  overlays

                  common
                  users
                  wireguard
                  crypto
                ]);
            };
        in
        {
          nixosModules = import ./modules;
          nixosConfigurations = with self.nixosModules; {
            # vultr-image = mkSystem [ common users image vultr ];

            ettves = mkSystem [
              (import ./machines/ettves)
              inputs.authentik-nix.nixosModules.default
              zfs
              teamspeak
              postgresql
              quassel
              powerdns
              acme
              authentik
              hydra
              homeassistant
              games
              languagetool
              git
              laplace
              catinator
              pastor
              # litellm
              monitoring
              monitoring-node
            ];
            phaenn = mkSystem [
              (import ./machines/phaenn)
              zfs
              acme
              tlmp
              monitoring-node
            ];
            fra01 = mkSystem [
              (import ./machines/fra01)
              vultr
              bgp
              powerdns
              acme
              garage
              monitoring-node
            ];
            nyc01 = mkSystem [
              (import ./machines/nyc01)
              vultr
              bgp
              powerdns
              acme
              garage
              monitoring-node
            ];
            sin01 = mkSystem [
              (import ./machines/sin01)
              vultr
              bgp
              powerdns
              acme
              garage
              monitoring-node
            ];
          };
        };
      systems = [
        "x86_64-linux"
        "x86_64-darwin"
        "aarch64-linux"
        "aarch64-darwin"
      ];
    };
}