summaryrefslogtreecommitdiff
path: root/systems/default.nix
blob: ae37e1cad0188e89096eb739a11bd63099bd0768 (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
{
  lib,
  withSystem,
  inputs,
  self,
  ...
}: let
  /*
  basic nixosSystem/darwinSystem wrapper; can override
  the exact builder by supplying an argument
  */
  toSystem = builder: name: args:
    (args.builder or builder) (
      (builtins.removeAttrs args ["builder"])
      // {
        modules = args.modules ++ [./${name}];
        specialArgs = {
          inherit inputs self;
          inputs' = withSystem (args.system or "x86_64-linux") ({inputs', ...}: inputs');
          secretsDir = ../secrets/${name};
        };
      }
    );

  mapSystems = builder: lib.mapAttrs (toSystem builder);

  mapDarwin = mapSystems inputs.darwin.lib.darwinSystem;
  mapNixOS = mapSystems inputs.nixpkgs.lib.nixosSystem;
  common = import ./common.nix {inherit inputs self;};
in {
  imports = [./deploy.nix];

  flake = {
    darwinConfigurations = mapDarwin {
      caroline = {
        system = "x86_64-darwin";
        modules = common.darwin;
      };
    };

    nixosConfigurations = mapNixOS {
      glados = {
        system = "x86_64-linux";
        modules = common.personal;
      };

      glados-wsl = {
        system = "x86_64-linux";
        modules = common.personal;
      };

      atlas = {
        builder = inputs.nixpkgs-stable.lib.nixosSystem;
        system = "aarch64-linux";
        modules = common.server;
      };
    };

    legacyPackages.x86_64-linux.turret = withSystem "x86_64-linux" ({pkgs, ...}:
      pkgs.callPackage ./turret {
        inherit (inputs) openwrt-imagebuilder;
      });
  };
}