blob: 0e63228963d470242cc685590a2f84c6620155b9 [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
Serge Bazanskia0332a72021-03-17 22:12:43 +01009# d=$(nix-build -A 'ops.machines."'$machine'"'.toplevel)
Serge Bazanski6abe4fa2020-10-03 00:18:34 +020010#
Serge Bazanskia0332a72021-03-17 22:12:43 +010011# To then deploy derivation $d on $machine:
Serge Bazanski6abe4fa2020-10-03 00:18:34 +020012#
Serge Bazanski6abe4fa2020-10-03 00:18:34 +020013# nix-copy-closure --to root@$machine $d
Serge Bazanski0ec06d72021-04-18 20:12:20 +020014# ssh root@$machine $d/bin/switch-to-configuration dry-activate
15# ssh root@$machine $d/bin/switch-to-configuration test
16# ssh root@$machine nix-env -p /nix/var/nix/profiles/system --set $d
17# ssh root@$machine $d/bin/switch-to-configuration boot
Serge Bazanski6abe4fa2020-10-03 00:18:34 +020018#
19# TODO(q3k): merge this with //cluster/clustercfg - this should be unified!
20
21{ hscloud, pkgs, ... }:
22
23let
24 # Stopgap measure to import //cluster/nix machine definitions into new
25 # //ops/machines infrastructure.
26 # TODO(q3k): inject defs-cluster-k0.nix / defs-machines.nix content via
27 # nixos options instead of having module definitions loading it themselves,
28 # deduplicate list of machines below with defs-machines.nix somehow.
29 mkClusterMachine = name: pkgs.nixos ({ config, pkgs, ... }: {
30 # The hostname is used by //cluster/nix machinery to load the appropriate
31 # config from defs-machines into defs-cluster-k0.
32 networking.hostName = name;
33 imports = [
34 ../cluster/nix/modules/base.nix
35 ../cluster/nix/modules/kubernetes.nix
36 ];
37 });
38
Serge Bazanskia0332a72021-03-17 22:12:43 +010039 mkMachine = pkgs: paths: pkgs.nixos ({ config, pkgs, ... }: {
Serge Bazanski6abe4fa2020-10-03 00:18:34 +020040 imports = paths;
41 });
42
43in {
44 "bc01n01.hswaw.net" = mkClusterMachine "bc01n01";
45 "bc01n02.hswaw.net" = mkClusterMachine "bc01n02";
46 "bc01n03.hswaw.net" = mkClusterMachine "bc01n03";
47 "dcr01s22.hswaw.net" = mkClusterMachine "dcr01s22";
48 "dcr01s24.hswaw.net" = mkClusterMachine "dcr01s24";
49
Serge Bazanskia0332a72021-03-17 22:12:43 +010050 # edge01 still lives on an old nixpkgs checkout.
51 # TODO(b/3): unpin and deploy.
52 "edge01.waw.bgp.wtf" = mkMachine (
53 import (pkgs.fetchFromGitHub {
54 owner = "nixos";
55 repo = "nixpkgs-channels";
56 rev = "c59ea8b8a0e7f927e7291c14ea6cd1bd3a16ff38";
57 sha256 = "1ak7jqx94fjhc68xh1lh35kh3w3ndbadprrb762qgvcfb8351x8v";
58 }) {}
59 ) [
Serge Bazanski6abe4fa2020-10-03 00:18:34 +020060 ../bgpwtf/machines/edge01.waw.bgp.wtf.nix
61 ../bgpwtf/machines/edge01.waw.bgp.wtf-hardware.nix
62 ];
63}