From 9472db45773a560a18d64650ad7d8628c8b956d3 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Sat, 8 Jan 2022 21:49:09 +0000 Subject: [PATCH] ops/nixos: consolidate Frantech VM configs into lib/frantech.nix --- ops/nixos/frantech-las01/default.nix | 49 ++--------------------- ops/nixos/frantech-lux01/default.nix | 49 ++--------------------- ops/nixos/frantech-nyc01/default.nix | 50 ++--------------------- ops/nixos/lib/frantech.nix | 59 ++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 139 deletions(-) create mode 100644 ops/nixos/lib/frantech.nix diff --git a/ops/nixos/frantech-las01/default.nix b/ops/nixos/frantech-las01/default.nix index e9b879a875..ec46492968 100644 --- a/ops/nixos/frantech-las01/default.nix +++ b/ops/nixos/frantech-las01/default.nix @@ -7,64 +7,21 @@ let inherit (depot.ops) secrets; in { imports = [ - ../../../third_party/nixpkgs/nixos/modules/profiles/qemu-guest.nix - ../lib/low-space.nix - ../lib/coredns/default.nix + ../lib/frantech.nix ]; - boot.initrd.availableKernelModules = [ - "ata_piix" - "uhci_hcd" - "virtio_pci" - "virtio_scsi" - "sr_mod" - "virtio_blk" - ]; - boot.kernelModules = [ "kvm-amd" ]; - - # Use GRUB. - boot.loader.grub.enable = true; - boot.loader.grub.version = 2; - boot.loader.grub.device = "/dev/vda"; - - powerManagement.cpuFreqGovernor = lib.mkDefault "performance"; - - fileSystems = { - "/" = { - device = "/dev/vda1"; - fsType = "ext4"; - }; - }; - - nix.maxJobs = lib.mkDefault 1; - - # Networking! networking = { hostName = "frantech-las01"; - domain = "as205479.net"; hostId = "2b6a8f37"; - nameservers = [ - "2001:4860:4860::8888" - "2001:4860:4860::8844" - "8.8.8.8" - "8.8.4.4" - ]; - defaultGateway = { - address = "205.185.116.1"; - interface = "ens3"; - }; - defaultGateway6 = { - address = "2605:6400:20::1"; - interface = "ens3"; - }; + defaultGateway.address = "205.185.116.1"; + defaultGateway6.address = "2605:6400:20::1"; interfaces.ens3 = { ipv4.addresses = [{ address = "205.185.116.42"; prefixLength = 24; }]; ipv6.addresses = [{ address = "2605:6400:20:179b::1"; prefixLength = 48; }]; }; }; my.ip.tailscale = "100.127.132.77"; - my.coredns.bind = [ "ens3" "tailscale0" "127.0.0.1" "::1" ]; system.stateVersion = "21.05"; } diff --git a/ops/nixos/frantech-lux01/default.nix b/ops/nixos/frantech-lux01/default.nix index eb3235db49..99bcfe5e94 100644 --- a/ops/nixos/frantech-lux01/default.nix +++ b/ops/nixos/frantech-lux01/default.nix @@ -7,64 +7,21 @@ let inherit (depot.ops) secrets; in { imports = [ - ../../../third_party/nixpkgs/nixos/modules/profiles/qemu-guest.nix - ../lib/low-space.nix - ../lib/coredns/default.nix + ../lib/frantech.nix ]; - boot.initrd.availableKernelModules = [ - "ata_piix" - "uhci_hcd" - "virtio_pci" - "virtio_scsi" - "sr_mod" - "virtio_blk" - ]; - boot.kernelModules = [ "kvm-amd" ]; - - # Use GRUB. - boot.loader.grub.enable = true; - boot.loader.grub.version = 2; - boot.loader.grub.device = "/dev/vda"; - - powerManagement.cpuFreqGovernor = lib.mkDefault "performance"; - - fileSystems = { - "/" = { - device = "/dev/vda1"; - fsType = "ext4"; - }; - }; - - nix.maxJobs = lib.mkDefault 1; - - # Networking! networking = { hostName = "frantech-lux01"; - domain = "as205479.net"; hostId = "92a60220"; - nameservers = [ - "2001:4860:4860::8888" - "2001:4860:4860::8844" - "8.8.8.8" - "8.8.4.4" - ]; - defaultGateway = { - address = "107.189.4.1"; - interface = "ens3"; - }; - defaultGateway6 = { - address = "2605:6400:30::1"; - interface = "ens3"; - }; + defaultGateway.address = "107.189.4.1"; + defaultGateway6.address = "2605:6400:30::1"; interfaces.ens3 = { ipv4.addresses = [{ address = "107.189.4.182"; prefixLength = 24; }]; ipv6.addresses = [{ address = "2605:6400:30:f1d2::1"; prefixLength = 48; }]; }; }; my.ip.tailscale = "100.125.159.57"; - my.coredns.bind = [ "ens3" "tailscale0" "127.0.0.1" "::1" ]; system.stateVersion = "21.05"; } diff --git a/ops/nixos/frantech-nyc01/default.nix b/ops/nixos/frantech-nyc01/default.nix index 57a82a1ddc..ab91db4ef9 100644 --- a/ops/nixos/frantech-nyc01/default.nix +++ b/ops/nixos/frantech-nyc01/default.nix @@ -8,66 +8,22 @@ let machineSecrets = secrets.machineSpecific.frantech-nyc01; in { imports = [ - ../../../third_party/nixpkgs/nixos/modules/profiles/qemu-guest.nix - ../lib/low-space.nix - ../lib/coredns/default.nix + ../lib/frantech.nix ../lib/bgp.nix - ../lib/minotarproxy.nix ]; - boot.initrd.availableKernelModules = [ - "ata_piix" - "uhci_hcd" - "virtio_pci" - "virtio_scsi" - "sr_mod" - "virtio_blk" - ]; - boot.kernelModules = [ "kvm-amd" ]; - - # Use GRUB. - boot.loader.grub.enable = true; - boot.loader.grub.version = 2; - boot.loader.grub.device = "/dev/vda"; - - powerManagement.cpuFreqGovernor = lib.mkDefault "performance"; - - fileSystems = { - "/" = { - device = "/dev/vda1"; - fsType = "ext4"; - }; - }; - - nix.maxJobs = lib.mkDefault 1; - - # Networking! networking = { hostName = "frantech-nyc01"; - domain = "as205479.net"; hostId = "251837df"; - nameservers = [ - "2001:4860:4860::8888" - "2001:4860:4860::8844" - "8.8.8.8" - "8.8.4.4" - ]; - defaultGateway = { - address = "199.195.254.1"; - interface = "ens3"; - }; - defaultGateway6 = { - address = "2605:6400:10::1"; - interface = "ens3"; - }; + defaultGateway.address = "199.195.254.1"; + defaultGateway6.address = "2605:6400:10::1"; interfaces.ens3 = { ipv4.addresses = [{ address = "199.195.254.60"; prefixLength = 24; }]; ipv6.addresses = [{ address = "2605:6400:10:c77::1"; prefixLength = 48; }]; }; }; my.ip.tailscale = "100.99.236.25"; - my.coredns.bind = [ "ens3" "tailscale0" "127.0.0.1" "::1" ]; services.lukegbgp = let local = { asn = 205479; diff --git a/ops/nixos/lib/frantech.nix b/ops/nixos/lib/frantech.nix new file mode 100644 index 0000000000..bdb636afe2 --- /dev/null +++ b/ops/nixos/lib/frantech.nix @@ -0,0 +1,59 @@ +# SPDX-FileCopyrightText: 2020 Luke Granger-Brown +# +# SPDX-License-Identifier: Apache-2.0 + +{ depot, lib, pkgs, rebuilder, config, ... }: +let + inherit (depot.ops) secrets; +in { + imports = [ + ../../../third_party/nixpkgs/nixos/modules/profiles/qemu-guest.nix + ../lib/low-space.nix + ../lib/coredns/default.nix + ]; + + boot.initrd.availableKernelModules = [ + "ata_piix" + "uhci_hcd" + "virtio_pci" + "virtio_scsi" + "sr_mod" + "virtio_blk" + ]; + boot.kernelModules = [ "kvm-amd" ]; + + # Use GRUB. + boot.loader.grub.enable = true; + boot.loader.grub.version = 2; + boot.loader.grub.device = "/dev/vda"; + + powerManagement.cpuFreqGovernor = lib.mkDefault "performance"; + + fileSystems = { + "/" = { + device = "/dev/vda1"; + fsType = "ext4"; + }; + }; + + nix.maxJobs = lib.mkDefault 1; + + # Networking! + networking = { + domain = "as205479.net"; + + nameservers = [ + "2001:4860:4860::8888" + "2001:4860:4860::8844" + "8.8.8.8" + "8.8.4.4" + ]; + defaultGateway = { + interface = "ens3"; + }; + defaultGateway6 = { + interface = "ens3"; + }; + }; + my.coredns.bind = [ "ens3" "tailscale0" "127.0.0.1" "::1" ]; +}