blob: c341ec4480e262795fa7fef0f6233faa4fb27efb [file] [log] [blame]
Serge Bazanski6abe4fa2020-10-03 00:18:34 +02001# Top-level file aggregating all machines managed from hscloud.
2#
3# This allows to have a common attrset of machines that can be deployed
4# in the same way.
5#
6# Currently building/deployment is still done in a half-assed way:
7#
8# machine=edge01.waw.bgp.wtf
9# nix-build -A 'ops.machines."'$machine'"'.toplevel
10#
11# This spits out a derivation path that correponds to the built config of that
12# machine. To deploy it:
13#
14# d=/nix/store/nkdfoobarbazl0ybhazkmeyaylmaoqcr-nixos-system-edge01-20.09pre-git
15# nix-copy-closure --to root@$machine $d
16# ssh root@$machine $d/bin/switch-to-configuration
17#
18# TODO(q3k): merge this with //cluster/clustercfg - this should be unified!
19
20{ hscloud, pkgs, ... }:
21
22let
23 # Stopgap measure to import //cluster/nix machine definitions into new
24 # //ops/machines infrastructure.
25 # TODO(q3k): inject defs-cluster-k0.nix / defs-machines.nix content via
26 # nixos options instead of having module definitions loading it themselves,
27 # deduplicate list of machines below with defs-machines.nix somehow.
28 mkClusterMachine = name: pkgs.nixos ({ config, pkgs, ... }: {
29 # The hostname is used by //cluster/nix machinery to load the appropriate
30 # config from defs-machines into defs-cluster-k0.
31 networking.hostName = name;
32 imports = [
33 ../cluster/nix/modules/base.nix
34 ../cluster/nix/modules/kubernetes.nix
35 ];
36 });
37
38 mkMachine = paths: pkgs.nixos ({ config, pkgs, ... }: {
39 imports = paths;
40 });
41
42in {
43 "bc01n01.hswaw.net" = mkClusterMachine "bc01n01";
44 "bc01n02.hswaw.net" = mkClusterMachine "bc01n02";
45 "bc01n03.hswaw.net" = mkClusterMachine "bc01n03";
46 "dcr01s22.hswaw.net" = mkClusterMachine "dcr01s22";
47 "dcr01s24.hswaw.net" = mkClusterMachine "dcr01s24";
48
49 "edge01.waw.bgp.wtf" = mkMachine [
50 ../bgpwtf/machines/edge01.waw.bgp.wtf.nix
51 ../bgpwtf/machines/edge01.waw.bgp.wtf-hardware.nix
52 ];
53}