summaryrefslogtreecommitdiff
path: root/systems/deploy.nix
blob: 186ff37e77a1b045b91c8babe19740b3700da3f5 (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
{
  lib,
  inputs,
  self,
  ...
}: let
  targets = ["atlas"];

  getDeploy = pkgs:
    (import pkgs.path {
      inherit (pkgs) system;
      overlays = [
        inputs.deploy.overlay
        (_: prev: {
          deploy-rs = {
            inherit (pkgs) deploy-rs;
            inherit (prev.deploy-rs) lib;
          };
        })
      ];
    })
    .deploy-rs;

  getType = pkgs:
    if pkgs.stdenv.isDarwin
    then "darwin"
    else "nixos";

  toDeployNode = hostname: system: {
    sshUser = "root";
    inherit hostname;
    profiles.system.path = (getDeploy system.pkgs).lib.activate.${getType system.pkgs} system;
  };
in {
  flake.deploy = {
    remoteBuild = true;
    fastConnection = false;
    nodes = lib.pipe (self.nixosConfigurations // self.darwinConfigurations) [
      (lib.getAttrs targets)
      (lib.mapAttrs toDeployNode)
    ];
  };
}