From 51c74e2b1f8abe73ea2cd8838ff40a921b4fc016 Mon Sep 17 00:00:00 2001 From: Aly Raffauf Date: Fri, 29 Mar 2024 21:51:10 -0400 Subject: [PATCH] moved homelab virtualization config to apps modules --- hosts/lavaridge/default.nix | 9 +++++---- hosts/petalburg/default.nix | 16 +++++++++------- hosts/rustboro/default.nix | 8 +++++--- nixosModules/apps/default.nix | 2 +- .../virtualization => apps/podman}/default.nix | 9 ++++----- nixosModules/apps/virt-manager/default.nix | 15 +++++++++++++++ nixosModules/homeLab/default.nix | 13 +++---------- nixosModules/homeLab/nixContainers/default.nix | 1 + nixosModules/homeLab/ociContainers/default.nix | 3 +++ 9 files changed, 46 insertions(+), 30 deletions(-) rename nixosModules/{homeLab/virtualization => apps/podman}/default.nix (57%) create mode 100644 nixosModules/apps/virt-manager/default.nix diff --git a/hosts/lavaridge/default.nix b/hosts/lavaridge/default.nix index 932b8b82..9fca3441 100644 --- a/hosts/lavaridge/default.nix +++ b/hosts/lavaridge/default.nix @@ -23,7 +23,7 @@ fwupd.enable = true; fprintd.package = pkgs.fprintd.overrideAttrs { mesonCheckFlags = [ "--no-suite" "fprintd:TestPamFprintd" ]; - }; + }; }; systemConfig = { @@ -38,12 +38,13 @@ apps = { flatpak.enable = true; + podman.enable = true; steam.enable = true; + virt-manager.enable = true; }; - homeLab.virtualization.enable = true; - - users.users.aly.hashedPassword = "$y$j9T$O9NgTk6iRfh3mxiRDvfdm1$BjvsAKYEMB3C28652FF15cj/i.3TgQAObQvR0rN1E6C"; + users.users.aly.hashedPassword = + "$y$j9T$O9NgTk6iRfh3mxiRDvfdm1$BjvsAKYEMB3C28652FF15cj/i.3TgQAObQvR0rN1E6C"; system.stateVersion = "23.11"; # Did you read the comment? } diff --git a/hosts/petalburg/default.nix b/hosts/petalburg/default.nix index d0c3aef9..2cb1cd34 100644 --- a/hosts/petalburg/default.nix +++ b/hosts/petalburg/default.nix @@ -81,15 +81,17 @@ in { desktopEnvironments.gnome.enable = true; }; - apps = { - flatpak.enable = true; - steam.enable = false; + systemConfig = { + plymouth.enable = true; + zramSwap.enable = true; }; - homeLab.virtualization.enable = true; - - systemConfig.plymouth.enable = true; - systemConfig.zramSwap.enable = true; + apps = { + flatpak.enable = true; + podman.enable = true; + steam.enable = true; + virt-manager.enable = true; + }; system.stateVersion = "23.11"; } diff --git a/hosts/rustboro/default.nix b/hosts/rustboro/default.nix index fb99d0c0..79025e62 100644 --- a/hosts/rustboro/default.nix +++ b/hosts/rustboro/default.nix @@ -17,6 +17,11 @@ powerManagement.cpuFreqGovernor = "ondemand"; + systemConfig = { + plymouth.enable = true; + zramSwap.enable = true; + }; + desktopConfig = { enable = true; windowManagers.hyprland.enable = true; @@ -27,8 +32,5 @@ steam.enable = false; }; - systemConfig.plymouth.enable = true; - systemConfig.zramSwap.enable = true; - system.stateVersion = "23.11"; # Did you read the comment? } diff --git a/nixosModules/apps/default.nix b/nixosModules/apps/default.nix index b3e4dd5e..1e11b1fc 100644 --- a/nixosModules/apps/default.nix +++ b/nixosModules/apps/default.nix @@ -1,5 +1,5 @@ { pkgs, lib, config, ... }: { - imports = [ ./flatpak ./steam ]; + imports = [ ./flatpak ./steam ./podman ./virt-manager ]; } diff --git a/nixosModules/homeLab/virtualization/default.nix b/nixosModules/apps/podman/default.nix similarity index 57% rename from nixosModules/homeLab/virtualization/default.nix rename to nixosModules/apps/podman/default.nix index d392aa6e..f4648398 100644 --- a/nixosModules/homeLab/virtualization/default.nix +++ b/nixosModules/apps/podman/default.nix @@ -1,15 +1,13 @@ { pkgs, lib, config, ... }: { options = { - homeLab.virtualization.enable = - lib.mkEnableOption "Enables podman and virt-manager virtualization."; + apps.podman.enable = + lib.mkEnableOption "Enables Podman for OCI container support."; }; - config = lib.mkIf config.homeLab.virtualization.enable { - programs.virt-manager.enable = true; + config = lib.mkIf config.apps.podman.enable { virtualisation = { - libvirtd.enable = true; oci-containers = { backend = "podman"; }; podman = { # Required for containers under podman-compose to be able to talk to each other. @@ -17,5 +15,6 @@ enable = true; }; }; + }; } diff --git a/nixosModules/apps/virt-manager/default.nix b/nixosModules/apps/virt-manager/default.nix new file mode 100644 index 00000000..91710dd2 --- /dev/null +++ b/nixosModules/apps/virt-manager/default.nix @@ -0,0 +1,15 @@ +{ pkgs, lib, config, ... }: { + + options = { + apps.virt-manager.enable = + lib.mkEnableOption "Enables virt-manager with TPM and EFI support."; + }; + + config = lib.mkIf config.apps.virt-manager.enable { + + programs.virt-manager.enable = true; + + virtualisation = { libvirtd.enable = true; }; + + }; +} diff --git a/nixosModules/homeLab/default.nix b/nixosModules/homeLab/default.nix index 4c53de03..55a44028 100644 --- a/nixosModules/homeLab/default.nix +++ b/nixosModules/homeLab/default.nix @@ -1,16 +1,10 @@ { pkgs, lib, config, ... }: { - imports = [ - ./binaryCache - ./reverseProxy - ./nixContainers - ./ociContainers - ./samba - ./virtualization - ]; + imports = + [ ./binaryCache ./reverseProxy ./nixContainers ./ociContainers ./samba ]; options = { - homeLab.enable = lib.mkEnableOption "Enables fully functional HomeLab."; + homeLab.enable = lib.mkEnableOption "Enables fully functional Home Lab."; }; config = lib.mkIf config.homeLab.enable { @@ -19,6 +13,5 @@ homeLab.ociContainers.enable = lib.mkDefault true; homeLab.reverseProxy.enable = lib.mkDefault true; homeLab.samba.enable = lib.mkDefault true; - homeLab.virtualization.enable = lib.mkDefault true; }; } diff --git a/nixosModules/homeLab/nixContainers/default.nix b/nixosModules/homeLab/nixContainers/default.nix index 56b2facf..282d0786 100644 --- a/nixosModules/homeLab/nixContainers/default.nix +++ b/nixosModules/homeLab/nixContainers/default.nix @@ -6,6 +6,7 @@ }; config = lib.mkIf config.homeLab.nixContainers.enable { + containers.navidrome = { autoStart = true; bindMounts."/Music".hostPath = "/mnt/Media/Music"; diff --git a/nixosModules/homeLab/ociContainers/default.nix b/nixosModules/homeLab/ociContainers/default.nix index 0e1c49f1..78585a99 100644 --- a/nixosModules/homeLab/ociContainers/default.nix +++ b/nixosModules/homeLab/ociContainers/default.nix @@ -6,6 +6,9 @@ }; config = lib.mkIf config.homeLab.ociContainers.enable { + + apps.podman.enable = lib.mkDefault true; + virtualisation.oci-containers.containers = { audiobookshelf = { ports = [ "0.0.0.0:13378:80" ];