From dad04a00626cbc255f98abc892e7d943d630e245 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Mon, 8 Feb 2021 22:26:22 +0000 Subject: [PATCH] ops/nixos: add other blade hosts blade-paris and blade-kim are TBD --- ops/nixos/blade-chakotay/default.nix | 24 +++++++++++++++ ops/nixos/blade-kim/default.nix | 24 +++++++++++++++ ops/nixos/blade-paris/default.nix | 24 +++++++++++++++ ops/nixos/blade-torres/default.nix | 24 +++++++++++++++ ops/nixos/blade-tuvok/default.nix | 24 +++++++++++++++ ops/nixos/default.nix | 5 ++++ ops/nixos/install.sh | 45 ++++++++++++++++++++++++++++ ops/nixos/lib/blade.nix | 3 ++ 8 files changed, 173 insertions(+) create mode 100644 ops/nixos/blade-chakotay/default.nix create mode 100644 ops/nixos/blade-kim/default.nix create mode 100644 ops/nixos/blade-paris/default.nix create mode 100644 ops/nixos/blade-torres/default.nix create mode 100644 ops/nixos/blade-tuvok/default.nix create mode 100755 ops/nixos/install.sh diff --git a/ops/nixos/blade-chakotay/default.nix b/ops/nixos/blade-chakotay/default.nix new file mode 100644 index 0000000000..cc828c6217 --- /dev/null +++ b/ops/nixos/blade-chakotay/default.nix @@ -0,0 +1,24 @@ +# SPDX-FileCopyrightText: 2020 Luke Granger-Brown +# +# SPDX-License-Identifier: Apache-2.0 + +{ depot, lib, pkgs, rebuilder, config, ... }: +let + inherit (depot.ops) secrets; +in { + imports = [ + ../lib/blade.nix + ]; + + boot.loader.grub.device = "/dev/disk/by-id/usb-USB_SanDisk_3.2Gen1_01012b89ef8e36218414588461cda968a6fbfa5bf39e398aaeda43d9e398b05f86800000000000000000000097b1f26d001a240091558107b6a8e160-0:0"; + + # Networking! + networking = { + hostName = "blade-chakotay"; + hostId = "40bc5a75"; + interfaces.bond0.ipv4.addresses = [{ + address = "192.168.1.182"; + prefixLength = 24; + }]; + }; +} diff --git a/ops/nixos/blade-kim/default.nix b/ops/nixos/blade-kim/default.nix new file mode 100644 index 0000000000..cce39ad9ad --- /dev/null +++ b/ops/nixos/blade-kim/default.nix @@ -0,0 +1,24 @@ +# SPDX-FileCopyrightText: 2020 Luke Granger-Brown +# +# SPDX-License-Identifier: Apache-2.0 + +{ depot, lib, pkgs, rebuilder, config, ... }: +let + inherit (depot.ops) secrets; +in { + imports = [ + ../lib/blade.nix + ]; + + boot.loader.grub.device = ""; + + # Networking! + networking = { + hostName = "blade-kim"; + hostId = "1643efb6"; + interfaces.bond0.ipv4.addresses = [{ + address = "192.168.1.183"; + prefixLength = 24; + }]; + }; +} diff --git a/ops/nixos/blade-paris/default.nix b/ops/nixos/blade-paris/default.nix new file mode 100644 index 0000000000..36ea1b763d --- /dev/null +++ b/ops/nixos/blade-paris/default.nix @@ -0,0 +1,24 @@ +# SPDX-FileCopyrightText: 2020 Luke Granger-Brown +# +# SPDX-License-Identifier: Apache-2.0 + +{ depot, lib, pkgs, rebuilder, config, ... }: +let + inherit (depot.ops) secrets; +in { + imports = [ + ../lib/blade.nix + ]; + + boot.loader.grub.device = ""; + + # Networking! + networking = { + hostName = "blade-paris"; + hostId = "41b2a198"; + interfaces.bond0.ipv4.addresses = [{ + address = "192.168.1.184"; + prefixLength = 24; + }]; + }; +} diff --git a/ops/nixos/blade-torres/default.nix b/ops/nixos/blade-torres/default.nix new file mode 100644 index 0000000000..7955280bf0 --- /dev/null +++ b/ops/nixos/blade-torres/default.nix @@ -0,0 +1,24 @@ +# SPDX-FileCopyrightText: 2020 Luke Granger-Brown +# +# SPDX-License-Identifier: Apache-2.0 + +{ depot, lib, pkgs, rebuilder, config, ... }: +let + inherit (depot.ops) secrets; +in { + imports = [ + ../lib/blade.nix + ]; + + boot.loader.grub.device = "/dev/disk/by-id/usb-USB_SanDisk_3.2Gen1_01011cbe2d1b827aedae2d5668fecf2a2dbdab7d0ecc0416f6e7c5485ecec8f5e5870000000000000000000080ce63590095210091558107b6a8e55d-0:0"; + + # Networking! + networking = { + hostName = "blade-torres"; + hostId = "86db1d9c"; + interfaces.bond0.ipv4.addresses = [{ + address = "192.168.1.185"; + prefixLength = 24; + }]; + }; +} diff --git a/ops/nixos/blade-tuvok/default.nix b/ops/nixos/blade-tuvok/default.nix new file mode 100644 index 0000000000..9b4396c2a1 --- /dev/null +++ b/ops/nixos/blade-tuvok/default.nix @@ -0,0 +1,24 @@ +# SPDX-FileCopyrightText: 2020 Luke Granger-Brown +# +# SPDX-License-Identifier: Apache-2.0 + +{ depot, lib, pkgs, rebuilder, config, ... }: +let + inherit (depot.ops) secrets; +in { + imports = [ + ../lib/blade.nix + ]; + + boot.loader.grub.device = "/dev/disk/by-id/usb-USB_SanDisk_3.2Gen1_0101cabb1ebdbdc0fd7b18edd207d43717c39c4a59d1b138b363e315841eca15743400000000000000000000443273100087260091558107b6a8e06e-0:0"; + + # Networking! + networking = { + hostName = "blade-tuvok"; + hostId = "525229f7"; + interfaces.bond0.ipv4.addresses = [{ + address = "192.168.1.181"; + prefixLength = 24; + }]; + }; +} diff --git a/ops/nixos/default.nix b/ops/nixos/default.nix index 0679b3c763..5b6a13d084 100644 --- a/ops/nixos/default.nix +++ b/ops/nixos/default.nix @@ -26,6 +26,11 @@ let "clouvider-lon01" "etheroute-lon01" "blade-janeway" + "blade-tuvok" + "blade-paris" + "blade-torres" + "blade-chakotay" + "blade-kim" ]; rebuilder = system: (import ./lib/rebuilder.nix (args // { system = system; })); systemCfgs = lib.genAttrs systems diff --git a/ops/nixos/install.sh b/ops/nixos/install.sh new file mode 100755 index 0000000000..fbf1d0b14d --- /dev/null +++ b/ops/nixos/install.sh @@ -0,0 +1,45 @@ +#!/bin/sh + +# SPDX-FileCopyrightText: 2020 Luke Granger-Brown +# +# SPDX-License-Identifier: Apache-2.0 + +set -eu + +if [ $EUID -ne 0 ]; then + exec sudo "$0" "$@" +fi + +if [ $# -lt 1 ]; then + echo "Usage: $0 hostname" >&2 + exit 1 +fi + +depot_parent() { + pd="$(readlink -f "$1")/" + if [ "${pd#*/depot/}" = "$pd" ]; then + return + fi + pd="$(readlink -f "${pd%/depot/*}/depot")" + echo "$pd" +} + +depot_path() { + pd="$(depot_parent "$PWD")" + if [ "$pd" = "" ]; then + pd="$(depot_parent "$(readlink -f "$0")")" + fi + echo "$pd" +} + +readonly targethostname="$1" +readonly depot="$(depot_path)" +if [ "$depot" = "" ]; then + echo "This script needs to be executed in-depot (or the script itself should be in-depot)." + exit 1 +fi +readonly system="$(nix-build -E '(import "'"$(depot_path)"'" {}).ops.nixos.'"${targethostname}" --option sandbox false --no-out-link)" +nixos-install --root /mnt --system "$system" --no-root-passwd + +echo "Copying myself..." +cp -R "$depot/" "/mnt/home/lukegb/depot/" diff --git a/ops/nixos/lib/blade.nix b/ops/nixos/lib/blade.nix index e0defb95af..07dfdeacb6 100644 --- a/ops/nixos/lib/blade.nix +++ b/ops/nixos/lib/blade.nix @@ -41,6 +41,9 @@ in { miimon = "1000"; lacp_rate = "fast"; }; + interfaces = [ + "enp4s0f0" "enp4s0f1" + ]; }; defaultGateway = "192.168.1.5";