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 |
Serge Bazanski | 0ec06d7 | 2021-04-18 20:12:20 +0200 | [diff] [blame] | 14 | # 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 Bazanski | 6abe4fa | 2020-10-03 00:18:34 +0200 | [diff] [blame] | 18 | # |
| 19 | # TODO(q3k): merge this with //cluster/clustercfg - this should be unified! |
| 20 | |
| 21 | { hscloud, pkgs, ... }: |
| 22 | |
| 23 | let |
| 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 Bazanski | a0332a7 | 2021-03-17 22:12:43 +0100 | [diff] [blame] | 39 | mkMachine = pkgs: paths: pkgs.nixos ({ config, pkgs, ... }: { |
Serge Bazanski | 6abe4fa | 2020-10-03 00:18:34 +0200 | [diff] [blame] | 40 | imports = paths; |
| 41 | }); |
| 42 | |
| 43 | in { |
| 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 Bazanski | a0332a7 | 2021-03-17 22:12:43 +0100 | [diff] [blame] | 50 | # 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 Bazanski | 6abe4fa | 2020-10-03 00:18:34 +0200 | [diff] [blame] | 60 | ../bgpwtf/machines/edge01.waw.bgp.wtf.nix |
| 61 | ../bgpwtf/machines/edge01.waw.bgp.wtf-hardware.nix |
| 62 | ]; |
| 63 | } |