From 26f641b1917036dc5600afe7be7ae2cfef6af3d4 Mon Sep 17 00:00:00 2001 From: Superredstone Date: Sat, 31 Jan 2026 21:19:32 +0100 Subject: [PATCH] Code refactor --- machines/bomba/configuration.nix | 11 ----------- machines/bomba/default.nix | 2 ++ machines/bomba/networking.nix | 11 +++++++++++ machines/bomba/services.nix | 6 ++++++ machines/katana/networking.nix | 20 +++++++++++-------- machines/katana/nvidia.nix | 26 +++++++++++++------------ machines/katana/services.nix | 15 +++++++------- machines/katana/virtualisation.nix | 11 +++++------ machines/workstation/default.nix | 6 ++++-- machines/workstation/networking.nix | 19 ++++++------------ machines/workstation/services.nix | 20 ++++++++++--------- machines/workstation/virtualisation.nix | 11 +++++------ modules/packages.nix | 1 + 13 files changed, 84 insertions(+), 75 deletions(-) create mode 100644 machines/bomba/networking.nix create mode 100644 machines/bomba/services.nix diff --git a/machines/bomba/configuration.nix b/machines/bomba/configuration.nix index 6b77e81..19b2074 100644 --- a/machines/bomba/configuration.nix +++ b/machines/bomba/configuration.nix @@ -8,18 +8,7 @@ boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; - networking.networkmanager.enable = true; - time.timeZone = "Europe/Rome"; nixpkgs.config.allowUnfree = true; - - services = { - openssh.enable = true; - udisks2.enable = true; - }; - - networking.firewall.allowedTCPPorts = [ 22 ]; - networking.firewall.allowedUDPPorts = [ ]; - networking.firewall.enable = true; } diff --git a/machines/bomba/default.nix b/machines/bomba/default.nix index 6f9011c..4b11fdf 100644 --- a/machines/bomba/default.nix +++ b/machines/bomba/default.nix @@ -3,6 +3,8 @@ imports = [ ./configuration.nix ./hardware.nix + ./networking.nix + ./services.nix ./virtualisation.nix ]; diff --git a/machines/bomba/networking.nix b/machines/bomba/networking.nix new file mode 100644 index 0000000..ede7014 --- /dev/null +++ b/machines/bomba/networking.nix @@ -0,0 +1,11 @@ +{ ... }: +{ + networking = { + networkmanager.enable = true; + firewall = { + allowedTCPPorts = [ 22 ]; + allowedUDPPorts = [ ]; + enable = true; + }; + }; +} diff --git a/machines/bomba/services.nix b/machines/bomba/services.nix new file mode 100644 index 0000000..887f880 --- /dev/null +++ b/machines/bomba/services.nix @@ -0,0 +1,6 @@ +{ ... }: +{ + services = { + openssh.enable = true; + }; +} diff --git a/machines/katana/networking.nix b/machines/katana/networking.nix index a776157..ed13744 100644 --- a/machines/katana/networking.nix +++ b/machines/katana/networking.nix @@ -1,12 +1,16 @@ { ... }: { - networking.networkmanager.enable = true; - networking.firewall = { - checkReversePath = false; - allowedUDPPorts = [ 25565 1194 ]; - allowedTCPPorts = [ 25565 443 ]; + networking = { + networkmanager.enable = true; + wireguard.enable = true; + firewall = { + checkReversePath = false; + allowedUDPPorts = [ 25565 ]; + allowedTCPPorts = [ 25565 ]; + }; + }; + hardware.bluetooth = { + enable = true; + powerOnBoot = true; }; - hardware.bluetooth.enable = true; - hardware.bluetooth.powerOnBoot = true; - networking.wireguard.enable = true; } diff --git a/machines/katana/nvidia.nix b/machines/katana/nvidia.nix index 5139e06..d29af37 100644 --- a/machines/katana/nvidia.nix +++ b/machines/katana/nvidia.nix @@ -1,18 +1,20 @@ { config, ... }: { - hardware.graphics.enable = true; - hardware.nvidia = { - modesetting.enable = true; - package = config.boot.kernelPackages.nvidiaPackages.beta; - open = true; - prime = { - offload = { - enable = true; - enableOffloadCmd = true; - }; + hardware = { + graphics.enable = true; + nvidia = { + modesetting.enable = true; + package = config.boot.kernelPackages.nvidiaPackages.beta; + open = true; + prime = { + offload = { + enable = true; + enableOffloadCmd = true; + }; - intelBusId = "PCI:0:2:0"; - nvidiaBusId = "PCI:1:0:0"; + intelBusId = "PCI:0:2:0"; + nvidiaBusId = "PCI:1:0:0"; + }; }; }; } diff --git a/machines/katana/services.nix b/machines/katana/services.nix index 23ffc82..0195dce 100644 --- a/machines/katana/services.nix +++ b/machines/katana/services.nix @@ -1,11 +1,10 @@ { ... }: { - services.flatpak.enable = true; - services.xserver.videoDrivers = ["nvidia"]; - - # Enable CUPS to print documents. - services.printing.enable = true; - - # Required for piper to work - services.ratbagd.enable = true; + services = { + flatpak.enable = true; + printing.enable = true; + # Required for piper to work + ratbagd.enable = true; + xserver.videoDrivers = ["nvidia"]; + }; } diff --git a/machines/katana/virtualisation.nix b/machines/katana/virtualisation.nix index 7bb0401..5695329 100644 --- a/machines/katana/virtualisation.nix +++ b/machines/katana/virtualisation.nix @@ -1,11 +1,10 @@ { currentSystemUser, ... }: { - # virtualisation.podman.enable = true; - # virtualisation.podman.dockerCompat = true; - virtualisation.docker.enable = true; - # programs.virt-manager.enable = true; users.groups.libvirtd.members = ["${currentSystemUser}"]; - virtualisation.libvirtd.enable = true; - virtualisation.spiceUSBRedirection.enable = true; + virtualisation = { + docker.enable = true; + libvirtd.enable = true; + spiceUSBRedirection.enable = true; + }; } diff --git a/machines/workstation/default.nix b/machines/workstation/default.nix index abab42d..971aa35 100644 --- a/machines/workstation/default.nix +++ b/machines/workstation/default.nix @@ -9,8 +9,10 @@ networking.hostName = "workstation"; # Define your hostname. - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; + boot.loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; + }; system.stateVersion = "24.11"; # Did you read the comment? } diff --git a/machines/workstation/networking.nix b/machines/workstation/networking.nix index da96d68..5cd5453 100644 --- a/machines/workstation/networking.nix +++ b/machines/workstation/networking.nix @@ -1,16 +1,9 @@ { ... }: { - networking.networkmanager.enable = true; - networking.firewall.allowedUDPPorts = [ 8000 23 ]; - networking.firewall.allowedTCPPorts = [ 8000 23 ]; - # networking.bridges = { - # "br0" = { - # interfaces = [ "eno1" ]; - # }; - # }; - # networking.interfaces.br0.ipv4.addresses = [{ - # address = "192.168.1.235"; - # prefixLength = 24; - # }]; - networking.nameservers = [ "1.1.1.1" "1.0.0.1" ]; + networking = { + networkmanager.enable = true; + firewall.allowedUDPPorts = [ 8000 ]; + firewall.allowedTCPPorts = [ 8000 ]; + nameservers = [ "1.1.1.1" "1.0.0.1" ]; + }; } diff --git a/machines/workstation/services.nix b/machines/workstation/services.nix index 3b16037..57e0243 100644 --- a/machines/workstation/services.nix +++ b/machines/workstation/services.nix @@ -1,15 +1,17 @@ { ... }: { - services.flatpak.enable = true; + services = { + flatpak.enable = true; - # Enable CUPS to print documents. - services.printing.enable = true; - services.openssh = { - enable = true; - ports = [ 22 ]; - settings = { - PasswordAuthentication = true; - PermitRootLogin = "no"; + # Enable CUPS to print documents. + printing.enable = true; + openssh = { + enable = true; + ports = [ 22 ]; + settings = { + PasswordAuthentication = true; + PermitRootLogin = "no"; + }; }; }; } diff --git a/machines/workstation/virtualisation.nix b/machines/workstation/virtualisation.nix index ca24259..5695329 100644 --- a/machines/workstation/virtualisation.nix +++ b/machines/workstation/virtualisation.nix @@ -1,11 +1,10 @@ { currentSystemUser, ... }: { - # virtualisation.podman.enable = true; - # virtualisation.podman.dockerCompat = true; - virtualisation.docker.enable = true; - programs.virt-manager.enable = true; users.groups.libvirtd.members = ["${currentSystemUser}"]; - virtualisation.libvirtd.enable = true; - virtualisation.spiceUSBRedirection.enable = true; + virtualisation = { + docker.enable = true; + libvirtd.enable = true; + spiceUSBRedirection.enable = true; + }; } diff --git a/modules/packages.nix b/modules/packages.nix index e51379a..feeac1c 100644 --- a/modules/packages.nix +++ b/modules/packages.nix @@ -60,6 +60,7 @@ mpv nextcloud-client piper + spotube telegram-desktop thunderbird ] else [])