This repository has been archived by the owner on Jun 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
85 lines (73 loc) · 2.77 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
{
description = "NixOS systems for the stakerdao projects";
nixConfig = {
flake-registry = "https://github.com/serokell/flake-registry/raw/master/flake-registry.json";
};
inputs = {
stakerdao-agora.url = "git+ssh://[email protected]/serokell/stakerdao-agora";
bridge-web.url = "git+ssh://[email protected]/stakerdao/bridge-web";
};
outputs =
{ self, nixpkgs, serokell-nix, deploy-rs, vault-secrets, ... }@inputs:
let
inherit (nixpkgs.lib) nixosSystem filterAttrs const recursiveUpdate;
inherit (builtins) readDir mapAttrs;
system = "x86_64-linux";
servers = mapAttrs (path: _: import (./servers + "/${path}"))
(filterAttrs (_: t: t == "directory") (readDir ./servers));
mkSystem = config:
nixosSystem {
inherit system;
modules = [ config ./common.nix ];
specialArgs.inputs = inputs;
};
deployChecks =
mapAttrs (_: lib: lib.deployChecks self.deploy) deploy-rs.lib;
terraformFor = pkgs: pkgs.terraform_0_13.withPlugins (p: with p; [ aws ]);
checks = mapAttrs (_: pkgs:
let pkgs' = pkgs.extend serokell-nix.overlay;
in {
trailing-whitespace = pkgs'.build.checkTrailingWhitespace ./.;
# terraform = pkgs'.build.validateTerraform {
# src = ./terraform;
# terraform = terraformFor pkgs;
# };
}) nixpkgs.legacyPackages;
in {
nixosConfigurations = mapAttrs (const mkSystem) servers;
nixosSystems =
builtins.mapAttrs (_: machine: machine.config.system.build.toplevel)
self.nixosConfigurations;
deploy = {
magicRollback = true;
autoRollback = true;
sshOpts = [ "-p" "17788" ];
nodes = mapAttrs (_: nixosConfig: {
hostname =
"${nixosConfig.config.networking.hostName}.${nixosConfig.config.networking.domain}";
profiles.system.user = "root";
profiles.system.path =
deploy-rs.lib.${system}.activate.nixos nixosConfig;
}) self.nixosConfigurations;
};
devShell = mapAttrs (system: deploy:
let
pkgs = serokell-nix.lib.pkgsWith nixpkgs.legacyPackages.${system} [
serokell-nix.overlay
vault-secrets.overlay
];
in pkgs.mkShell {
VAULT_ADDR = "https://vault.serokell.org:8200";
SSH_OPTS = "${builtins.concatStringsSep " " self.deploy.sshOpts}";
buildInputs = [
deploy-rs.packages.${system}.deploy-rs
pkgs.vault
(pkgs.vault-push-approle-envs self)
(pkgs.vault-push-approles self)
(terraformFor pkgs)
pkgs.nixUnstable
];
}) deploy-rs.defaultPackage;
checks = recursiveUpdate deployChecks checks;
};
}