Serge Bazanski | 6abe4fa | 2020-10-03 00:18:34 +0200 | [diff] [blame] | 1 | # 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 Bazanski | a0332a7 | 2021-03-17 22:12:43 +0100 | [diff] [blame] | 9 | # d=$(nix-build -A 'ops.machines."'$machine'"'.toplevel) |
Serge Bazanski | 6abe4fa | 2020-10-03 00:18:34 +0200 | [diff] [blame] | 10 | # |
Serge Bazanski | a0332a7 | 2021-03-17 22:12:43 +0100 | [diff] [blame] | 11 | # To then deploy derivation $d on $machine: |
Serge Bazanski | 6abe4fa | 2020-10-03 00:18:34 +0200 | [diff] [blame] | 12 | # |
Serge Bazanski | 6abe4fa | 2020-10-03 00:18:34 +0200 | [diff] [blame] | 13 | # nix-copy-closure --to root@$machine $d |
| 14 | # ssh root@$machine $d/bin/switch-to-configuration |
| 15 | # |
| 16 | # TODO(q3k): merge this with //cluster/clustercfg - this should be unified! |
| 17 | |
| 18 | { hscloud, pkgs, ... }: |
| 19 | |
| 20 | let |
| 21 | # Stopgap measure to import //cluster/nix machine definitions into new |
| 22 | # //ops/machines infrastructure. |
| 23 | # TODO(q3k): inject defs-cluster-k0.nix / defs-machines.nix content via |
| 24 | # nixos options instead of having module definitions loading it themselves, |
| 25 | # deduplicate list of machines below with defs-machines.nix somehow. |
| 26 | mkClusterMachine = name: pkgs.nixos ({ config, pkgs, ... }: { |
| 27 | # The hostname is used by //cluster/nix machinery to load the appropriate |
| 28 | # config from defs-machines into defs-cluster-k0. |
| 29 | networking.hostName = name; |
| 30 | imports = [ |
| 31 | ../cluster/nix/modules/base.nix |
| 32 | ../cluster/nix/modules/kubernetes.nix |
| 33 | ]; |
| 34 | }); |
| 35 | |
Serge Bazanski | a0332a7 | 2021-03-17 22:12:43 +0100 | [diff] [blame] | 36 | mkMachine = pkgs: paths: pkgs.nixos ({ config, pkgs, ... }: { |
Serge Bazanski | 6abe4fa | 2020-10-03 00:18:34 +0200 | [diff] [blame] | 37 | imports = paths; |
| 38 | }); |
| 39 | |
| 40 | in { |
| 41 | "bc01n01.hswaw.net" = mkClusterMachine "bc01n01"; |
| 42 | "bc01n02.hswaw.net" = mkClusterMachine "bc01n02"; |
| 43 | "bc01n03.hswaw.net" = mkClusterMachine "bc01n03"; |
| 44 | "dcr01s22.hswaw.net" = mkClusterMachine "dcr01s22"; |
| 45 | "dcr01s24.hswaw.net" = mkClusterMachine "dcr01s24"; |
| 46 | |
Serge Bazanski | a0332a7 | 2021-03-17 22:12:43 +0100 | [diff] [blame] | 47 | # edge01 still lives on an old nixpkgs checkout. |
| 48 | # TODO(b/3): unpin and deploy. |
| 49 | "edge01.waw.bgp.wtf" = mkMachine ( |
| 50 | import (pkgs.fetchFromGitHub { |
| 51 | owner = "nixos"; |
| 52 | repo = "nixpkgs-channels"; |
| 53 | rev = "c59ea8b8a0e7f927e7291c14ea6cd1bd3a16ff38"; |
| 54 | sha256 = "1ak7jqx94fjhc68xh1lh35kh3w3ndbadprrb762qgvcfb8351x8v"; |
| 55 | }) {} |
| 56 | ) [ |
Serge Bazanski | 6abe4fa | 2020-10-03 00:18:34 +0200 | [diff] [blame] | 57 | ../bgpwtf/machines/edge01.waw.bgp.wtf.nix |
| 58 | ../bgpwtf/machines/edge01.waw.bgp.wtf-hardware.nix |
| 59 | ]; |
| 60 | } |