diff --git a/flake.nix b/flake.nix index cdaa2b2..65478a7 100644 --- a/flake.nix +++ b/flake.nix @@ -97,10 +97,7 @@ configs = [ # Systems nixos/installer.nix - nixos/boxes/colony - nixos/vms/estuary - nixos/containers/vaultwarden.nix # Homes home-manager/configs/castle.nix diff --git a/nixos/boxes/colony/default.nix b/nixos/boxes/colony/default.nix index d479ddf..c2ef006 100644 --- a/nixos/boxes/colony/default.nix +++ b/nixos/boxes/colony/default.nix @@ -1,4 +1,6 @@ { + imports = [ ./vms ]; + nixos.systems.colony = { system = "x86_64-linux"; nixpkgs = "mine-stable"; @@ -27,7 +29,7 @@ inherit (lib.my) networkdAssignment; in { - imports = [ "${modulesPath}/profiles/qemu-guest.nix" ./vms.nix ]; + imports = [ "${modulesPath}/profiles/qemu-guest.nix" ]; networking.domain = lib.my.colonyDomain; diff --git a/nixos/boxes/colony/vms.nix b/nixos/boxes/colony/vms.nix deleted file mode 100644 index c452f52..0000000 --- a/nixos/boxes/colony/vms.nix +++ /dev/null @@ -1,63 +0,0 @@ -{ lib, pkgs, config, systems, ... }: -let - wanBDF = - if config.my.build.isDevVM then "00:02.0" else "01:00.0"; -in -{ - systemd = { - services."vm@estuary" = { - # Depend the interface, networkd wait-online would deadlock... - requires = [ "sys-subsystem-net-devices-base.device" ]; - preStart = '' - count=0 - while ! ${pkgs.iproute2}/bin/ip link show dev base > /dev/null 2>&1; do - count=$((count+1)) - if [ $count -ge 5 ]; then - echo "Timed out waiting for bridge interface" - fi - sleep 0.5 - done - ''; - }; - }; - - my = { - vms = { - instances.estuary = { - uuid = "59f51efb-7e6d-477b-a263-ed9620dbc87b"; - networks.base.mac = "52:54:00:ab:f1:52"; - drives = { - installer = { - backend = { - driver = "file"; - filename = "${systems.installer.configuration.config.my.buildAs.iso}/iso/nixos.iso"; - read-only = "on"; - }; - format.driver = "raw"; - frontend = "ide-cd"; - frontendOpts = { - bootindex = 1; - }; - }; - disk = { - backend = { - driver = "host_device"; - filename = "/dev/ssds/vm-estuary"; - # It appears this needs to be set on the backend _and_ the format - discard = "unmap"; - }; - format = { - driver = "raw"; - discard = "unmap"; - }; - frontend = "virtio-blk"; - frontendOpts = { - bootindex = 0; - }; - }; - }; - hostDevices."${wanBDF}" = { }; - }; - }; - }; -} diff --git a/nixos/boxes/colony/vms/default.nix b/nixos/boxes/colony/vms/default.nix new file mode 100644 index 0000000..f5416d5 --- /dev/null +++ b/nixos/boxes/colony/vms/default.nix @@ -0,0 +1,69 @@ +{ + imports = [ + ./estuary + ]; + + nixos.systems.colony.configuration = { lib, pkgs, config, systems, ... }: + let + wanBDF = + if config.my.build.isDevVM then "00:02.0" else "01:00.0"; + in + { + systemd = { + services."vm@estuary" = { + # Depend the interface, networkd wait-online would deadlock... + requires = [ "sys-subsystem-net-devices-base.device" ]; + preStart = '' + count=0 + while ! ${pkgs.iproute2}/bin/ip link show dev base > /dev/null 2>&1; do + count=$((count+1)) + if [ $count -ge 5 ]; then + echo "Timed out waiting for bridge interface" + fi + sleep 0.5 + done + ''; + }; + }; + + my = { + vms = { + instances.estuary = { + uuid = "59f51efb-7e6d-477b-a263-ed9620dbc87b"; + networks.base.mac = "52:54:00:ab:f1:52"; + drives = { + installer = { + backend = { + driver = "file"; + filename = "${systems.installer.configuration.config.my.buildAs.iso}/iso/nixos.iso"; + read-only = "on"; + }; + format.driver = "raw"; + frontend = "ide-cd"; + frontendOpts = { + bootindex = 1; + }; + }; + disk = { + backend = { + driver = "host_device"; + filename = "/dev/ssds/vm-estuary"; + # It appears this needs to be set on the backend _and_ the format + discard = "unmap"; + }; + format = { + driver = "raw"; + discard = "unmap"; + }; + frontend = "virtio-blk"; + frontendOpts = { + bootindex = 0; + }; + }; + }; + hostDevices."${wanBDF}" = { }; + }; + }; + }; + }; +} diff --git a/nixos/vms/estuary/default.nix b/nixos/boxes/colony/vms/estuary/default.nix similarity index 100% rename from nixos/vms/estuary/default.nix rename to nixos/boxes/colony/vms/estuary/default.nix diff --git a/nixos/vms/estuary/dns.nix b/nixos/boxes/colony/vms/estuary/dns.nix similarity index 100% rename from nixos/vms/estuary/dns.nix rename to nixos/boxes/colony/vms/estuary/dns.nix