From d8a9e92dff745a3ceda7a2d616c235d458807d80 Mon Sep 17 00:00:00 2001 From: "Wyatt J. Miller" Date: Thu, 12 Dec 2024 20:41:58 -0500 Subject: [PATCH] code dump v1 --- flake.nix | 6 +- modules/apps/flatpak.nix | 36 ++++++++++ modules/graphics/default.nix | 42 +++++++++++ modules/machine/cloud/configuration.nix | 79 +++------------------ modules/machine/cloud/default.nix | 6 ++ modules/machine/sephiroth/configuration.nix | 19 ++--- modules/machine/sephiroth/default.nix | 6 ++ modules/sound/pipewire.nix | 6 ++ modules/sound/shairport.nix | 7 ++ modules/virtualization/docker.nix | 6 ++ modules/virtualization/hardware.nix | 4 ++ modules/virtualization/podman.nix | 7 ++ 12 files changed, 137 insertions(+), 87 deletions(-) create mode 100644 modules/apps/flatpak.nix create mode 100644 modules/graphics/default.nix create mode 100644 modules/machine/cloud/default.nix create mode 100644 modules/machine/sephiroth/default.nix create mode 100644 modules/sound/pipewire.nix create mode 100644 modules/sound/shairport.nix create mode 100644 modules/virtualization/docker.nix create mode 100644 modules/virtualization/hardware.nix create mode 100644 modules/virtualization/podman.nix diff --git a/flake.nix b/flake.nix index 5abd142..97fe803 100644 --- a/flake.nix +++ b/flake.nix @@ -39,8 +39,7 @@ modules = [ ./modules/common/core.nix ./modules/common/users.nix - ./modules/machine/sephiroth/configuration.nix - ./modules/machine/sephiroth/apps.nix + ./modules/machine/sephiroth home-manager.darwinModules.home-manager { @@ -64,8 +63,7 @@ nix-ld.nixosModules.nix-ld ./modules/common/core.nix ./modules/common/users.nix - ./modules/machine/cloud/hardware-configuration.nix - ./modules/machine/cloud/configuration.nix + ./modules/machine/cloud home-manager.nixosModules.home-manager { diff --git a/modules/apps/flatpak.nix b/modules/apps/flatpak.nix new file mode 100644 index 0000000..42c43f5 --- /dev/null +++ b/modules/apps/flatpak.nix @@ -0,0 +1,36 @@ +{ + lib, + pkgs, + flatpakPackages ? [], + flatpakRemotes ? [], +}: { + services.flatpak = { + enable = true; + remotes = + if flatpakRemotes == [] + then [ + { + name = "flathub"; + location = "https://dl.flathub.org/repo/flathub.flatpakrepo"; + } + ] + else flatpakRemotes; + # packages = [ + # "com.github.tchx84.Flatseal" + # "com.slack.Slack" + # "info.beyondallreason.bar" + # "io.dbeaver.DBeaverCommunity" + # "io.openrct2.OpenRCT2" + # "md.obsidian.Obsidian" + # "org.prismlauncher.PrismLauncher" + # "sh.cider.Cider" + # ]; + packages = flatpakPackages; + update = { + auto = { + enable = true; + onCalendar = "weekly"; + }; + }; + }; +} diff --git a/modules/graphics/default.nix b/modules/graphics/default.nix new file mode 100644 index 0000000..62b4668 --- /dev/null +++ b/modules/graphics/default.nix @@ -0,0 +1,42 @@ +{ + pkgs, + lib, + config, + ... +}: { + nixosModules.gpuHardware = {gpuVendor ? null, ...}: { + hardware.opengl = { + # Always enable OpenGL support + enable = true; + + # Dynamically select packages based on GPU vendor + extraPackages = with pkgs; ( + # Base packages that are always included + [ + mesa + libvdpau-va-gl + libva + libva-utils + ] + # Vendor-specific packages + ++ ( + if gpuVendor == "intel" + then [ + intel-vaapi-driver + intel-media-driver + ] + else if gpuVendor == "amd" + then [ + rocm-opencl-icd + ] + else if gpuVendor == "nvidia" + then [ + # Add Nvidia-specific packages if needed + nvidia-vaapi-driver + ] + else [] + ) + ); + }; + }; +} diff --git a/modules/machine/cloud/configuration.nix b/modules/machine/cloud/configuration.nix index 726b98b..f62f39e 100644 --- a/modules/machine/cloud/configuration.nix +++ b/modules/machine/cloud/configuration.nix @@ -1,8 +1,18 @@ { + config, pkgs, userName, ... }: { + imports = [ + ../../apps/flatpak.nix + ../../sound/pipewire.nix + ../../sound/shairport.nix + ../../virtualization/podman.nix + ../../virtualization/hardware.nix + (config.nixosModules.gpuHardware {gpuVendor = "amd";}) + ]; + # Enable flakes for NixOS nix.settings.experimental-features = ["nix-command" "flakes"]; @@ -10,46 +20,12 @@ boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; - # Install and enable common graphics drivers - hardware.opengl = { - # driSupport = true; - extraPackages = with pkgs; [ - mesa - libvdpau-va-gl - libva - libva-utils - intel-vaapi-driver # for Intel - intel-media-driver # for Intel - rocm-opencl-icd # for AMD - ]; - }; - - # For systems with AMD graphics, this enables Vulkan on 32-bit applications - # For 64-bit application, however, Vulkan is enabled by default - # hardware.graphics.driSupport32Bit = true; - - # For systems with AMD graphics, enable AMDVLK - #hardware.graphics = { - # extraPackages = with pkgs; [ - # amdvlk - # ]; - # extraPackages32 = with pkgs; [ - # driversi686Linux - # ]; - #}; - # Enable Bluetooth if present hardware.bluetooth.enable = true; # Set your timezone time.timeZone = "America/Detroit"; - # Enable Pipewire (sound) - services.pipewire = { - enable = true; - pulse.enable = true; - }; - # Enable touchpad services.libinput.enable = true; @@ -59,7 +35,6 @@ neovim git wireguard-tools - podman buildah podman-tui podman-compose @@ -160,34 +135,6 @@ networking.firewall.allowedUDPPorts = []; networking.networkmanager.enable = true; # Linux tool for managing network connections - # Enable Flatpak (app containerization) - # services.flatpak.enable = true; - services.flatpak = { - enable = true; - remotes = [ - { - name = "flathub"; - location = "https://dl.flathub.org/repo/flathub.flatpakrepo"; - } - ]; - packages = [ - "com.github.tchx84.Flatseal" - "com.slack.Slack" - "info.beyondallreason.bar" - "io.dbeaver.DBeaverCommunity" - "io.openrct2.OpenRCT2" - "md.obsidian.Obsidian" - "org.prismlauncher.PrismLauncher" - "sh.cider.Cider" - ]; - update = { - auto = { - enable = true; - onCalendar = "weekly"; - }; - }; - }; - # Enable Podman (OCI containers) virtualisation.podman = { enable = true; @@ -195,12 +142,6 @@ defaultNetwork.settings.dns_enabled = true; }; - services.shairport-sync = { - enable = pkgs.stdenv.isLinux; - openFirewall = pkgs.stdenv.isLinux; - arguments = "-v -o pw"; - }; - # users.users."${userName}" = { # group = "${userName}"; # isNormalUser = true; diff --git a/modules/machine/cloud/default.nix b/modules/machine/cloud/default.nix new file mode 100644 index 0000000..187a110 --- /dev/null +++ b/modules/machine/cloud/default.nix @@ -0,0 +1,6 @@ +{...}: { + imports = [ + ./configuration.nix + ./hardware-configuration.nix + ]; +} diff --git a/modules/machine/sephiroth/configuration.nix b/modules/machine/sephiroth/configuration.nix index f2adfad..d234627 100644 --- a/modules/machine/sephiroth/configuration.nix +++ b/modules/machine/sephiroth/configuration.nix @@ -3,30 +3,22 @@ hostname, ... }: { + imports = [ + ../../virtualization/podman.nix + ]; + system = { - # activationScripts are executed every time you boot the system or run `nixos-rebuild` / `darwin-rebuild`. activationScripts.postUserActivation.text = '' - # activateSettings -u will reload the settings from the database and apply them to the current session, - # so we do not need to logout and login again to make the changes take effect. /System/Library/PrivateFrameworks/SystemAdministration.framework/Resources/activateSettings -u ''; defaults = { - menuExtraClock.Show24Hour = true; # show 24 hour clock + menuExtraClock.Show24Hour = true; - # customize dock dock = { autohide = true; - # show-recents = false; # disable recent apps - - # # customize Hot Corners - # wvous-tl-corner = 2; # top-left - Mission Control - # wvous-tr-corner = 13; # top-right - Lock Screen - # wvous-bl-corner = 3; # bottom-left - Application Windows - # wvous-br-corner = 4; # bottom-right - Desktop }; - # # customize finder finder = { _FXShowPosixPathInTitle = true; # show full path in finder title AppleShowAllExtensions = true; # show all file extensions @@ -36,7 +28,6 @@ ShowStatusBar = true; # show status bar }; - # # customize trackpad # trackpad = { # Clicking = true; # enable tap to click # TrackpadRightClick = true; # enable two finger right click diff --git a/modules/machine/sephiroth/default.nix b/modules/machine/sephiroth/default.nix new file mode 100644 index 0000000..fcb07f3 --- /dev/null +++ b/modules/machine/sephiroth/default.nix @@ -0,0 +1,6 @@ +{...}: { + imports = [ + ./apps.nix + ./configuration.nix + ]; +} diff --git a/modules/sound/pipewire.nix b/modules/sound/pipewire.nix new file mode 100644 index 0000000..56e3063 --- /dev/null +++ b/modules/sound/pipewire.nix @@ -0,0 +1,6 @@ +{...}: { + services.pipewire = { + enable = true; + pulse.enable = true; + }; +} diff --git a/modules/sound/shairport.nix b/modules/sound/shairport.nix new file mode 100644 index 0000000..a81d82f --- /dev/null +++ b/modules/sound/shairport.nix @@ -0,0 +1,7 @@ +{pkgs}: { + services.shairport-sync = { + enable = pkgs.stdenv.isLinux; + openFirewall = pkgs.stdenv.isLinux; + arguments = "-v -o pw"; + }; +} diff --git a/modules/virtualization/docker.nix b/modules/virtualization/docker.nix new file mode 100644 index 0000000..25f7831 --- /dev/null +++ b/modules/virtualization/docker.nix @@ -0,0 +1,6 @@ +{...}: { + virtualisation.docker = { + enable = true; + enableOnBoot = true; + }; +} diff --git a/modules/virtualization/hardware.nix b/modules/virtualization/hardware.nix new file mode 100644 index 0000000..37f8b42 --- /dev/null +++ b/modules/virtualization/hardware.nix @@ -0,0 +1,4 @@ +{...}: { + virtualisation.libvirtd.enable = true; + programs.virt-manager.enable = true; +} diff --git a/modules/virtualization/podman.nix b/modules/virtualization/podman.nix new file mode 100644 index 0000000..b9e685a --- /dev/null +++ b/modules/virtualization/podman.nix @@ -0,0 +1,7 @@ +{...}: { + virtualisation.podman = { + enable = true; + dockerSocket.enable = true; + defaultNetwork.settings.dns_enabled = true; + }; +}