-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
68 lines (63 loc) · 2.11 KB
/
flake.nix
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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs = inputs@{ self, ... }:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-darwin" ];
perSystem = { pkgs, lib, ... }:
let
mkColmenaApps = nodeName: rec {
# Runs `colmena` executable.
default.program = lib.getExe pkgs.colmena;
# SSH's to the deployment target of `nodeName`
ssh.program = pkgs.writeShellScriptBin "ssh-${nodeName}"
''
ADDR=''$(${default.program} eval -E '{ nodes, ... }:
let cfg = nodes.${nodeName}.config.deployment;
in "''${cfg.targetUser}@''${cfg.targetHost}"' | tr -d '"'
)
set -x
ssh $ADDR
'';
# Run's `colmena apply`. Enables remote build on macOS.
deploy.program = pkgs.writeShellScriptBin "deploy-${nodeName}"
(if pkgs.stdenv.isLinux
then "${default.program} apply"
else "${default.program} apply --build-on-target");
};
in
{
# Base DigitalOcean image
packages.doImage =
(pkgs.nixos
(import ./modules/doImage.nix { inherit inputs; })
).digitalOceanImage;
apps = mkColmenaApps "fpindia-chat";
# Run `nix fmt` to format the Nix files.
formatter = pkgs.nixpkgs-fmt;
};
flake = {
colmena = {
meta = {
nixpkgs = import inputs.nixpkgs {
system = "x86_64-linux";
overlays = [ ];
};
specialArgs = { inherit inputs; };
};
fpindia-chat = { pkgs, ... }: {
deployment = {
targetHost = "165.22.214.173"; # DigitalOcean droplet IP
targetUser = "admin";
};
imports = [
./modules/doImage.nix
./hosts/fpindia-chat
];
};
};
};
};
}