updated modules to work for cloud

This commit is contained in:
Wyatt J. Miller 2024-12-23 15:35:36 -05:00
parent 972cd76421
commit 86970a7f6c
10 changed files with 178 additions and 131 deletions

13
flake.lock generated
View File

@ -28,15 +28,16 @@
] ]
}, },
"locked": { "locked": {
"lastModified": 1734344598, "lastModified": 1734366194,
"narHash": "sha256-wNX3hsScqDdqKWOO87wETUEi7a/QlPVgpC/Lh5rFOuA=", "narHash": "sha256-vykpJ1xsdkv0j8WOVXrRFHUAdp9NXHpxdnn1F4pYgSw=",
"owner": "nix-community", "owner": "nix-community",
"repo": "home-manager", "repo": "home-manager",
"rev": "83ecd50915a09dca928971139d3a102377a8d242", "rev": "80b0fdf483c5d1cb75aaad909bd390d48673857f",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "nix-community", "owner": "nix-community",
"ref": "release-24.11",
"repo": "home-manager", "repo": "home-manager",
"type": "github" "type": "github"
} }
@ -93,11 +94,11 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1734323986, "lastModified": 1734737257,
"narHash": "sha256-m/lh6hYMIWDYHCAsn81CDAiXoT3gmxXI9J987W5tZrE=", "narHash": "sha256-GIMyMt1pkkoXdCq9un859bX6YQZ/iYtukb9R5luazLM=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "394571358ce82dff7411395829aa6a3aad45b907", "rev": "1c6e20d41d6a9c1d737945962160e8571df55daa",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@ -5,7 +5,7 @@
nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=v0.4.1"; nix-flatpak.url = "github:gmodena/nix-flatpak/?ref=v0.4.1";
nix-ld.url = "github:Mic92/nix-ld"; nix-ld.url = "github:Mic92/nix-ld";
home-manager = { home-manager = {
url = "github:nix-community/home-manager"; url = "github:nix-community/home-manager/release-24.11";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
darwin = { darwin = {

View File

@ -16,16 +16,6 @@
} }
] ]
else flatpakRemotes; 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; packages = flatpakPackages;
update = { update = {
auto = { auto = {

View File

@ -71,15 +71,10 @@ in {
}; };
wine = { wine = {
enable = lib.mkOption { enable = lib.mkEnableOption "Enable Wine support for Lutris";
type = lib.types.bool;
default = true;
description = "Enable Wine support for Lutris";
};
package = lib.mkOption { package = lib.mkOption {
type = lib.types.package; type = lib.types.package;
default = pkgs.wineWow; default = pkgs.wine-staging;
description = "Wine package to use with Lutris"; description = "Wine package to use with Lutris";
}; };
}; };
@ -107,10 +102,10 @@ in {
}; };
}; };
minecraft = lib.mkOption { minecraft = {
enable = lib.mkEnableOption "Minecraft in the form of PrismLauncher, a tool for launching Minecraft"; enable = lib.mkEnableOption "Minecraft in the form of PrismLauncher, a tool for launching Minecraft";
}; };
ffxiv = lib.mkOption { ffxiv = {
enable = lib.mkEnableOption "Final Fantasy XIV and it's accompanied (unofficial) launcher"; enable = lib.mkEnableOption "Final Fantasy XIV and it's accompanied (unofficial) launcher";
}; };
}; };
@ -145,36 +140,20 @@ in {
}; };
environment.systemPackages = environment.systemPackages =
lib.mkIf cfg.lutris.enable ( (lib.optionals cfg.lutris.enable (
# Base Lutris package [cfg.lutris.package] ++
[cfg.lutris.package]
++
# Wine packages if enabled
(lib.optionals cfg.lutris.wine.enable [ (lib.optionals cfg.lutris.wine.enable [
cfg.lutris.wine.package cfg.lutris.wine.package
pkgs.winetricks pkgs.winetricks
]) ]) ++
++
# Proton and compatibility tools
(lib.optionals cfg.lutris.compatibility.protonSupport [ (lib.optionals cfg.lutris.compatibility.protonSupport [
pkgs.proton-ge-custom pkgs.protonup-ng
]) pkgs.protonup-qt
++ ]) ++
# Extra compatibility tools cfg.lutris.compatibility.extraTools ++
cfg.lutris.compatibility.extraTools
++
# User-specified extra packages
cfg.lutris.extraPackages cfg.lutris.extraPackages
) )) ++
lib.mkIf (lib.optionals cfg.minecraft.enable [pkgs.prismlauncher]) ++
cfg.minecraft.enable [pkgs.prismlauncher] (lib.optionals cfg.ffxiv.enable [pkgs.xivlauncher]);
lib.mkIf
cfg.ffxiv.enable [pkgs.xivlauncher];
# Wine configuration
programs.wine = lib.mkIf (cfg.lutris.enable && cfg.lutris.wine.enable) {
enable = true;
package = cfg.lutris.wine.package;
};
}; };
} }

View File

@ -1,42 +1,107 @@
{ {
pkgs,
lib,
config, config,
lib,
pkgs,
... ...
}: { }:
nixosModules.gpuHardware = {gpuVendor ? null, ...}: { with lib; let
hardware.opengl = { cfg = config.graphics;
# Always enable OpenGL support in {
enable = true; options.graphics = {
gpuVendor = mkOption {
type = types.enum ["nvidia" "amd" "intel" "none"];
default = "none";
description = "GPU vendor to configure graphics drivers for";
};
# Dynamically select packages based on GPU vendor enable = mkEnableOption "graphics configuration";
extraPackages = with pkgs; (
# Base packages that are always included wayland = {
[ enable = mkEnableOption "Wayland support";
mesa
libvdpau-va-gl variableRefreshRate = mkOption {
libva type = types.bool;
libva-utils default = false;
] description = "Enable variable refresh rate (FreeSync/G-Sync) support";
# Vendor-specific packages };
++ ( };
if gpuVendor == "intel"
then [ vulkan = {
intel-vaapi-driver enable = mkEnableOption "Vulkan support";
intel-media-driver
] debug = mkOption {
else if gpuVendor == "amd" type = types.bool;
then [ default = false;
rocm-opencl-icd description = "Enable Vulkan validation layers";
] };
else if gpuVendor == "nvidia"
then [
# Add Nvidia-specific packages if needed
nvidia-vaapi-driver
]
else []
)
);
}; };
}; };
config = mkIf cfg.enable (mkMerge [
{
environment.systemPackages = with pkgs; [
glxinfo
vulkan-tools
mesa-demos
];
}
(mkIf (cfg.gpuVendor == "nvidia") {
services.xserver.videoDrivers = ["nvidia"];
hardware.nvidia = {
package = config.boot.kernelPackages.nvidiaPackages.stable;
open = true;
modesetting.enable = true;
powerManagement.enable = true;
};
environment.systemPackages = with pkgs; [
nvidia-vaapi-driver
nvtopPackages.full
];
})
(mkIf (cfg.gpuVendor == "amd") {
services.xserver.videoDrivers = ["amdgpu"];
hardware.opengl.extraPackages = with pkgs; [
rocm-opencl-icd
rocm-opencl-runtime
amdvlk
];
environment.systemPackages = with pkgs; [
radeontop
];
})
(mkIf (cfg.gpuVendor == "intel") {
services.xserver.videoDrivers = ["modesetting"];
hardware.opengl.extraPackages = with pkgs; [
intel-media-driver
intel-compute-runtime
];
})
(mkIf cfg.wayland.enable {
programs.xwayland.enable = true;
environment.sessionVariables = {
MOZ_ENABLE_WAYLAND = "1";
QT_QPA_PLATFORM = "wayland";
SDL_VIDEODRIVER = "wayland";
};
})
(mkIf cfg.vulkan.enable {
environment.systemPackages = with pkgs;
[
vulkan-loader
vulkan-validation-layers
]
++ (
if cfg.vulkan.debug
then [
vulkan-tools
]
else []
);
})
]);
} }

View File

@ -1,17 +1,32 @@
{ {
config, config,
lib,
pkgs, pkgs,
userName, userName,
... ...
}: { }:
let flatpakPackages = [
"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"
];
in {
imports = [ imports = [
../../apps/flatpak.nix (import ../../apps/flatpak.nix {
inherit lib pkgs flatpakPackages;
})
../../apps/gaming.nix
../../graphics
../../pwrMgmt ../../pwrMgmt
../../sound/pipewire.nix ../../sound/pipewire.nix
../../sound/shairport.nix ../../sound/shairport.nix
../../virtualization/podman.nix ../../virtualization/podman.nix
../../virtualization/hardware.nix ../../virtualization/hardware.nix
(config.nixosModules.gpuHardware {gpuVendor = "amd";})
]; ];
# Enable flakes for NixOS # Enable flakes for NixOS
@ -68,8 +83,15 @@
# Enable Polkit # Enable Polkit
security.polkit.enable = true; security.polkit.enable = true;
graphics = {
enable = true;
gpuVendor = "nvidia"; # or "amd" or "intel"
wayland.enable = true;
vulkan.enable = true;
};
# Gaming module (see ../../apps/gaming.nix) # Gaming module (see ../../apps/gaming.nix)
customGaming = { gaming = {
steam = { steam = {
enable = true; enable = true;
firewall = { firewall = {
@ -83,13 +105,10 @@
enable = true; enable = true;
wine = { wine = {
enable = true; enable = true;
package = pkgs.wine; package = pkgs.wine-staging;
}; };
compatibility = { compatibility = {
protonSupport = true; protonSupport = true;
extraTools = with pkgs; [
proton-ge-custom
];
}; };
extraPackages = with pkgs; [ extraPackages = with pkgs; [
gamemode gamemode
@ -97,17 +116,18 @@
]; ];
}; };
ffxiv.enable = true;
minecraft.enable = true; minecraft.enable = true;
}; };
# Power management (see ../../pwrMgmt/default.nix) # Power management (see ../../pwrMgmt/default.nix)
customPowerManagement = { pwrMgmt = {
enable = true; enable = true;
cpuFreqGovernor = "performance"; cpuFreqGovernor = "performance";
powertop.enable = false; powertop.enable = false;
}; };
containers.podman = { podman = {
enable = true; enable = true;
extraPackages = with pkgs; [ extraPackages = with pkgs; [
docker-credential-helpers docker-credential-helpers
@ -119,9 +139,9 @@
]; ];
}; };
customNetworking = { networking = {
firewall.enable = true; firewall.enable = true;
networkManager.enable = true; networkmanager.enable = true;
}; };
# Enable dconf # Enable dconf
@ -130,6 +150,9 @@
# Add username to groups "wheel" and "video" - more may be added here later # Add username to groups "wheel" and "video" - more may be added here later
users.users.${userName}.extraGroups = ["wheel" "video" "gamemode" "podman" "network"]; users.users.${userName}.extraGroups = ["wheel" "video" "gamemode" "podman" "network"];
# Flatpak packages (see ../../apps/flatpak.nix)
services.flatpak.packages = flatpakPackages;
# XDG stuff # XDG stuff
xdg = { xdg = {
portal = { portal = {
@ -150,11 +173,5 @@
}; };
}; };
# Firewall stuff not allowed in common user and network creation system.stateVersion = "24.11";
networking.firewall.enable = true; # VERY important, do not touch
networking.firewall.allowedTCPPorts = [];
networking.firewall.allowedUDPPorts = [];
networking.networkmanager.enable = true; # Linux tool for managing network connections
system.stateVersion = "24.05";
} }

View File

@ -1,15 +1,14 @@
{ {
config, config,
lib, lib,
pkgs,
... ...
}: let }: let
cfg = config.customNetworking; cfg = config.networking;
in { in {
options.customNetworking = { options.networking = {
# Firewall Configuration # Firewall Configuration
firewall = { firewall = {
enable = lib.mkOption { enable = lib.mkEnableOption {
type = lib.types.bool; type = lib.types.bool;
default = true; default = true;
description = "Enable system firewall"; description = "Enable system firewall";
@ -18,49 +17,49 @@ in {
tcpPorts = { tcpPorts = {
# Predefined, default common service ports # Predefined, default common service ports
ssh = { ssh = {
enable = lib.mkOption { enable = lib.mkEnableOption {
type = lib.types.bool; type = lib.types.bool;
default = false; default = false;
description = "Open SSH service port (22)"; description = "Open SSH service port (22)";
}; };
}; };
web = { web = {
enable = lib.mkOption { enable = lib.mkEnableOption {
type = lib.types.bool; type = lib.types.bool;
default = false; default = false;
description = "Open common web service ports (80, 443)"; description = "Open common web service ports (80, 443)";
}; };
}; };
smtp = { smtp = {
enable = lib.mkOption { enable = lib.mkEnableOption {
type = lib.types.bool; type = lib.types.bool;
default = false; default = false;
description = "Open SMTP service ports (25, 465, 587)"; description = "Open SMTP service ports (25, 465, 587)";
}; };
}; };
imap = { imap = {
enable = lib.mkOption { enable = lib.mkEnableOption {
type = lib.types.bool; type = lib.types.bool;
default = false; default = false;
description = "Open IMAP service ports (143, 993)"; description = "Open IMAP service ports (143, 993)";
}; };
}; };
mysql = { mysql = {
enable = lib.mkOption { enable = lib.mkEnableOption {
type = lib.types.bool; type = lib.types.bool;
default = false; default = false;
description = "Open MySQL service port (3306)"; description = "Open MySQL service port (3306)";
}; };
}; };
mssql = { mssql = {
enable = lib.mkOption { enable = lib.mkEnableOption {
type = lib.types.bool; type = lib.types.bool;
default = false; default = false;
description = "Open Microsoft SQL Server service port (1433)"; description = "Open Microsoft SQL Server service port (1433)";
}; };
}; };
postgres = { postgres = {
enable = lib.mkOption { enable = lib.mkEnableOption {
type = lib.types.bool; type = lib.types.bool;
default = false; default = false;
description = "Open Postgres service port (5432)"; description = "Open Postgres service port (5432)";
@ -75,14 +74,14 @@ in {
udpPorts = { udpPorts = {
dns = { dns = {
enable = lib.mkOption { enable = lib.mkEnableOption {
type = lib.types.bool; type = lib.types.bool;
default = false; default = false;
description = "Open DNS service port (53)"; description = "Open DNS service port (53)";
}; };
}; };
ntp = { ntp = {
enable = lib.mkOption { enable = lib.mkEnableOption {
type = lib.types.bool; type = lib.types.bool;
default = false; default = false;
description = "Open NTP service port (123)"; description = "Open NTP service port (123)";
@ -97,7 +96,7 @@ in {
}; };
networkManager = { networkManager = {
enable = lib.mkOption { enable = lib.mkEnableOption {
type = lib.types.bool; type = lib.types.bool;
default = true; default = true;
description = "Enable NetworkManager for network connection management"; description = "Enable NetworkManager for network connection management";

View File

@ -1,15 +1,13 @@
{ {
config, config,
lib, lib,
pkgs,
... ...
}: let }: let
# Define a more flexible power management module cfg = config.pwrMgmt;
cfg = config.pwrMgnt;
in { in {
# Define options for customizable power management options.pwrMgmt = {
options.pwrMgnt = {
enable = lib.mkEnableOption "Custom power management configuration"; enable = lib.mkEnableOption "Custom power management configuration";
cpuFreqGovernor = lib.mkOption { cpuFreqGovernor = lib.mkOption {
type = lib.types.enum [ type = lib.types.enum [
"performance" "performance"
@ -21,7 +19,6 @@ in {
description = "CPU frequency scaling governor to use"; description = "CPU frequency scaling governor to use";
}; };
# PowerTop Configuration
powertop = { powertop = {
enable = lib.mkEnableOption "PowerTop power management tool"; enable = lib.mkEnableOption "PowerTop power management tool";
@ -32,7 +29,6 @@ in {
}; };
}; };
# Battery-specific settings (for laptops)
battery = { battery = {
enable = lib.mkEnableOption "Battery-specific power management"; enable = lib.mkEnableOption "Battery-specific power management";
@ -56,7 +52,7 @@ in {
cpuFreqGovernor = cfg.cpuFreqGovernor; cpuFreqGovernor = cfg.cpuFreqGovernor;
}; };
services.powertop.enable = cfg.powertop.enable; environment.systemPackages = lib.mkIf cfg.powertop.enable [pkgs.powertop];
systemd.services.battery-charge-threshold = lib.mkIf cfg.battery.enable { systemd.services.battery-charge-threshold = lib.mkIf cfg.battery.enable {
description = "Set battery charge thresholds"; description = "Set battery charge thresholds";
wantedBy = ["multi-user.target"]; wantedBy = ["multi-user.target"];

View File

@ -1,4 +1,4 @@
{pkgs}: { {pkgs, ...}: {
services.shairport-sync = { services.shairport-sync = {
enable = pkgs.stdenv.isLinux; enable = pkgs.stdenv.isLinux;
openFirewall = pkgs.stdenv.isLinux; openFirewall = pkgs.stdenv.isLinux;

View File

@ -4,9 +4,9 @@
pkgs, pkgs,
... ...
}: let }: let
cfg = config.containers.podman; cfg = config.podman;
in { in {
options.containers = { options = {
podman = { podman = {
enable = lib.mkEnableOption "Podman container runtime"; enable = lib.mkEnableOption "Podman container runtime";