aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
blob: f2625a7f65640259d0f658e40a86ccbb99e12766 (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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";
    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 = "github:maxaudron/catinator";
    ac-cup-server.url = "github:maxaudron/ac-cup-server";
    ac-cup-server.inputs.nixpkgs.follows = "nixpkgs";
    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
              backup
              teamspeak
              postgresql
              quassel
              powerdns
              acme
              authentik
              hydra
              homeassistant
              games
              languagetool
              git
              laplace
              catinator
              pastor
              # litellm
              monitoring
              monitoring-node
              homepage
              web
              {
                services.nginx.virtualHosts."musicbrainz.vapor.systems" = (self.lib.nginx.proxyDomain "vapor.systems" "http://127.0.0.1:5000/");
              }
            ];
            phaenn = mkSystem [
              (import ./machines/phaenn)
              zfs
              acme
              tlmp
              monitoring-node
            ];
            mail = nixpkgs.lib.nixosSystem {
              inherit specialArgs;
              system = "aarch64-linux";

              modules = (with self.nixosModules; [
                nixinate.nixosModules.default
                overlays

                common
                backup
                users
                wireguard
                crypto

                (import ./machines/mail)
                hetzner
                acme

                mailserver
              ]);
            };
            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
            ];
          };
        };
      perSystem = { config, pkgs, ... }: {
        formatter = pkgs.nixfmt-rfc-style;
      };
      systems = [
        "x86_64-linux"
        "x86_64-darwin"
        "aarch64-linux"
        "aarch64-darwin"
      ];
    };
}