-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathflake.nix
More file actions
93 lines (82 loc) · 3 KB
/
Copy pathflake.nix
File metadata and controls
93 lines (82 loc) · 3 KB
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
91
92
93
# SPDX-FileCopyrightText: 2021 Serokell <https://serokell.io/>
#
# SPDX-License-Identifier: CC0-1.0
{
description = "NixOS systems for internal services";
inputs = {
nixpkgs.url = "github:serokell/nixpkgs";
serokell-nix.url = "github:serokell/serokell.nix";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
deploy-rs.url = "github:serokell/deploy-rs";
flake-utils.url = "github:numtide/flake-utils";
vault-secrets.url = "github:serokell/vault-secrets";
};
outputs = { self, nixpkgs, serokell-nix, deploy-rs, flake-utils, 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;
};
terraformFor = pkgs: pkgs.terraform.withPlugins (p: with p; [ aws ]);
in {
nixosConfigurations = mapAttrs (const mkSystem) servers;
nixosModules = import ./modules;
overlay = import ./packages;
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;
};
} // flake-utils.lib.eachSystem [ "x86_64-linux" ] (system:
let
pkgs = serokell-nix.lib.pkgsWith nixpkgs.legacyPackages.${system} [
serokell-nix.overlay
vault-secrets.overlay
];
in {
packages = { inherit (pkgs.extend self.overlay) mtg; };
devShell = 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
];
};
checks = deploy-rs.lib.${system}.deployChecks self.deploy // {
trailing-whitespace = pkgs.build.checkTrailingWhitespace ./.;
# FIXME VPC provider is not packaged
# terraform = pkgs.runCommand "terraform-check" {
# src = ./terraform;
# buildInputs = [ (terraformFor pkgs) ];
# } ''
# cp -r $src ./terraform
# terraform init -backend=false terraform
# terraform validate terraform
# touch $out
# '';
};
});
}