From ce31b2de37c38699c263d1cfe77500ef4af3d946 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cyryl=20P=C5=82otnicki?= Date: Wed, 9 Nov 2022 17:50:48 +0000 Subject: [PATCH] set bolty to static ip address and create a bridge --- nixos/boxes/bolty/default.nix | 25 +++++++++++++++++++++++-- nixos/boxes/bolty/home-assistant.nix | 26 ++++++++++++-------------- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/nixos/boxes/bolty/default.nix b/nixos/boxes/bolty/default.nix index bd51178e..0bcc6407 100644 --- a/nixos/boxes/bolty/default.nix +++ b/nixos/boxes/bolty/default.nix @@ -1,4 +1,8 @@ -{ config, pkgs, inputs, lib, ... }: { +{ config, pkgs, inputs, lib, ... }: +let + physicalInterface = "enp4s0"; + bridgeInterface = "br0"; +in { imports = [ ./bolty-boot.nix ./real-hardware.nix @@ -12,7 +16,24 @@ networking = { hostName = "bolty"; useDHCP = false; - interfaces.enp4s0.useDHCP = true; + defaultGateway = { + address = "10.0.0.1"; + interface = "${bridgeInterface}"; + }; + nameservers = [ "91.239.100.100" "89.233.43.71" "1.1.1.1" ]; + interfaces = { + "${physicalInterface}" = { + useDHCP = false; + wakeOnLan.enable = true; + }; + "${bridgeInterface}" = { + ipv4.addresses = [{ + "address" = "10.0.0.8"; + "prefixLength" = 24; + }]; + }; + }; + bridges = { "${bridgeInterface}".interfaces = [ "${physicalInterface}" ]; }; }; powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; diff --git a/nixos/boxes/bolty/home-assistant.nix b/nixos/boxes/bolty/home-assistant.nix index 4ebdafc4..caefc3df 100644 --- a/nixos/boxes/bolty/home-assistant.nix +++ b/nixos/boxes/bolty/home-assistant.nix @@ -1,19 +1,17 @@ -{ config, pkgs, inputs, lib, ... }: { +{ config, pkgs, inputs, lib, ... }: +let port = 8123; +in { imports = [ ]; - networking.firewall.allowedTCPPorts = [ 8123 ]; - virtualisation.oci-containers = { - backend = "podman"; - containers.homeassistant = { - volumes = [ "home-assistant:/config" ]; - environment.TZ = "Europe/London"; - image = - "ghcr.io/home-assistant/home-assistant:stable@sha256:5e3d2dde141812a4a54c140f3cbf52b9c74168bf25e8560978f499578902a363"; - extraOptions = [ - "--network=host" - "--privileged" - "--device=/dev/ttyACM1:/dev/ttyACM1" - ]; + networking.firewall.allowedTCPPorts = [ port ]; + + boot.kernelModules = [ "kvm_amd" ]; + virtualisation = { + libvirtd = { + enable = true; + qemu.ovmf.enable = true; }; }; + environment.systemPackages = with pkgs; [ qemu virt-manager usbutils ]; + }