-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
90 lines (83 loc) · 2.56 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
{
description = "My server configuration";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
deploy-rs = {
url = "github:serokell/deploy-rs";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{ self, nixpkgs, deploy-rs, sops-nix, ... }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages."${system}";
mkSystem = name: mode: modules: nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = inputs;
modules = [
sops-nix.nixosModules.sops
./modules.nix
./${name}/default.nix
./${name}/hardware-configuration.${mode}.nix
] ++ modules;
};
mkServer = name: modules: {
"${name}" = mkSystem name "prod" (modules "prod");
"${name}Dev" = mkSystem name "dev" (modules "dev");
};
in {
nixosConfigurations = nixpkgs.lib.attrsets.mergeAttrsList [
(mkServer "vps" (mode: [ ./settings.${mode}.nix ]))
(mkServer "caladan" (_: []))
];
nixosModules = {
haproxy = ./modules/haproxy.nix;
};
packages."${system}".immich = pkgs.callPackage ./pkgs/immich/default.nix {};
devShells."${system}".default = pkgs.mkShell {
packages = [
deploy-rs.packages."${system}".default
pkgs.sops
];
};
deploy.nodes = {
vpsDev = {
sshUser = "root";
hostname = "vps-dev";
profiles.system = {
user = "root";
path = deploy-rs.lib."${system}".activate.nixos self.nixosConfigurations.vpsDev;
};
};
vps = {
sshUser = "root";
hostname = "vps";
profiles.system = {
user = "root";
path = deploy-rs.lib."${system}".activate.nixos self.nixosConfigurations.vps;
};
};
caladanDev = {
sshUser = "root";
hostname = "vps-dev";
profiles.system = {
user = "root";
path = deploy-rs.lib."${system}".activate.nixos self.nixosConfigurations.caladanDev;
};
};
caladan = {
sshUser = "root";
hostname = "caladan";
profiles.system = {
user = "root";
path = deploy-rs.lib."${system}".activate.nixos self.nixosConfigurations.caladan;
};
};
};
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
};
}