From db7a8a3f6e7678c47b5c0e4dc1dbbfbaa1ef475b Mon Sep 17 00:00:00 2001 From: k3t Date: Mon, 1 Jun 2026 20:33:57 -0600 Subject: [PATCH] integrate htpc and associated configuration --- flake.nix | 71 +++++++++++++++++++++++++-- hosts/board/configuration.nix | 12 +---- hosts/htpc/configuration.nix | 56 +++++++++++++++++++++ hosts/htpc/hardware-configuration.nix | 33 +++++++++++++ hosts/laptop/configuration.nix | 10 ---- modules/audio/base.nix | 7 +++ modules/gui/apps/steam.nix | 17 +++++++ modules/gui/services/fcast.nix | 6 +++ modules/gui/services/xdg.nix | 7 ++- modules/sys/hw/boot.nix | 5 ++ modules/sys/hw/cpu/amd64.nix | 1 + modules/sys/hw/cpu/intel.nix | 1 + modules/sys/hw/gpu/amd.nix | 11 ++++- modules/sys/hw/gpu/intel.nix | 3 +- modules/sys/perf.nix | 20 +++++++- modules/sys/pkgs.nix | 9 +++- modules/sys/rgb.nix | 3 ++ modules/sys/security.nix | 6 ++- modules/sys/sysctl.nix | 18 +++++++ modules/sys/{tz.nix => time.nix} | 15 ++++++ modules/sys/vm.nix | 11 +++++ 21 files changed, 289 insertions(+), 33 deletions(-) create mode 100755 hosts/htpc/configuration.nix create mode 100755 hosts/htpc/hardware-configuration.nix create mode 100644 modules/gui/apps/steam.nix create mode 100644 modules/gui/services/fcast.nix create mode 100644 modules/sys/sysctl.nix rename modules/sys/{tz.nix => time.nix} (56%) create mode 100644 modules/sys/vm.nix diff --git a/flake.nix b/flake.nix index 5f898fb..04e5fa9 100755 --- a/flake.nix +++ b/flake.nix @@ -63,8 +63,10 @@ ./modules/de/kde.nix ./modules/desktop-common.nix + ./modules/gui/services/fcast.nix ./modules/gui/apps/firefox.nix ./modules/gui/apps/spicetify.nix + ./modules/gui/apps/steam.nix ./modules/gui/fonts.nix ./modules/gui/services/flatpak.nix ./modules/gui/services/kdeconnect.nix @@ -92,8 +94,10 @@ ./modules/sys/security.nix ./modules/sys/shell.nix ./modules/sys/stateversion.nix - ./modules/sys/tz.nix + ./modules/sys/sysctl.nix + ./modules/sys/time.nix ./modules/sys/users.nix + ./modules/sys/vm.nix ./hosts/board/configuration.nix spicetify-nix.nixosModules.spicetify @@ -104,6 +108,58 @@ home-manager.users.k3t = ./home/desktop.nix; } ]; + "htpc" = mkHost "x86_64-linux" [ + ./modules/audio/base.nix + ./modules/audio/zeroconf.nix + + ./modules/bluetooth/desktop.nix + ./modules/de/kde.nix + ./modules/desktop-common.nix + + ./modules/gui/services/fcast.nix + ./modules/gui/apps/firefox.nix + ./modules/gui/apps/spicetify.nix + ./modules/gui/apps/steam.nix + ./modules/gui/fonts.nix + ./modules/gui/services/flatpak.nix + ./modules/gui/services/kdeconnect.nix + ./modules/gui/services/kwallet.nix + ./modules/gui/services/xdg.nix + + ./modules/net/services/avahi.nix + ./modules/net/services/fail2ban.nix + ./modules/net/services/networkmanager.nix + ./modules/net/services/printing.nix + ./modules/net/services/tailscale.nix + + ./modules/sys/compat.nix + ./modules/sys/firewall.nix + ./modules/sys/fs/btrfs.nix + ./modules/sys/hw/boot.nix + ./modules/sys/hw/cpu/amd64.nix + ./modules/sys/hw/gpu/amd.nix + ./modules/sys/nix.nix + ./modules/sys/perf.nix + ./modules/sys/pkgs.nix + ./modules/sys/rc/openssh.nix + ./modules/sys/rc/sunshine.nix + ./modules/sys/rgb.nix + ./modules/sys/security.nix + ./modules/sys/shell.nix + ./modules/sys/stateversion.nix + ./modules/sys/sysctl.nix + ./modules/sys/time.nix + ./modules/sys/users.nix + + ./hosts/htpc/configuration.nix + spicetify-nix.nixosModules.spicetify + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.users.k3t = ./home/desktop.nix; + } + ]; "T14" = mkHost "x86_64-linux" [ ./modules/audio/base.nix ./modules/audio/zeroconf.nix @@ -112,8 +168,10 @@ ./modules/de/kde.nix ./modules/desktop-common.nix + ./modules/gui/services/fcast.nix ./modules/gui/apps/firefox.nix ./modules/gui/apps/spicetify.nix + ./modules/gui/apps/steam.nix ./modules/gui/fonts.nix ./modules/gui/services/flatpak.nix ./modules/gui/services/kdeconnect.nix @@ -141,8 +199,10 @@ ./modules/sys/security.nix ./modules/sys/shell.nix ./modules/sys/stateversion.nix - ./modules/sys/tz.nix + ./modules/sys/sysctl.nix + ./modules/sys/time.nix ./modules/sys/users.nix + ./modules/sys/vm.nix ./hosts/laptop/configuration.nix spicetify-nix.nixosModules.spicetify @@ -168,7 +228,7 @@ # ./modules/sys/security.nix # ./modules/sys/shell.nix # ./modules/sys/stateversion.nix - # ./modules/sys/tz.nix + # ./modules/sys/time.nix # ./modules/sys/users.nix # ./modules/pi-common.nix # ./hosts/pi-htpc-old/configuration.nix @@ -195,7 +255,8 @@ ./modules/sys/security.nix ./modules/sys/shell.nix ./modules/sys/stateversion.nix - ./modules/sys/tz.nix + ./modules/sys/sysctl.nix + ./modules/sys/time.nix ./modules/sys/users.nix ./hosts/nixcloud/configuration.nix home-manager.nixosModules.home-manager @@ -223,7 +284,7 @@ # ./modules/sys/security.nix # ./modules/sys/shell.nix # ./modules/sys/stateversion.nix - # ./modules/sys/tz.nix + # ./modules/sys/time.nix # ./modules/sys/users.nix # ./modules/pi-common.nix # ./hosts/pi-htpc-old/configuration.nix diff --git a/hosts/board/configuration.nix b/hosts/board/configuration.nix index f0d83eb..75d1422 100755 --- a/hosts/board/configuration.nix +++ b/hosts/board/configuration.nix @@ -10,17 +10,7 @@ ./hardware-configuration.nix ]; - services.beesd.filesystems = { - root = { - spec = "LABEL=NixOS"; - hashTableSizeMB = 128; - verbosity = "crit"; - extraOptions = [ "--loadavg-target" "1.5" ]; - }; - }; - - networking.hostName = "T14"; # Define your hostname. - services.openssh.enable = true; + networking.hostName = "board"; # Define your hostname. users.users.k3t = { packages = with pkgs; [ diff --git a/hosts/htpc/configuration.nix b/hosts/htpc/configuration.nix new file mode 100755 index 0000000..97dbf7a --- /dev/null +++ b/hosts/htpc/configuration.nix @@ -0,0 +1,56 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). + +{ config, pkgs, ... }: + +let + kodi-with-addons = pkgs.kodi-wayland.withPackages (kodiPkgs: with kodiPkgs; [ + inputstream-adaptive + inputstream-ffmpegdirect + inputstream-rtmp + inputstreamhelper + bluetooth-manager + vfs-sftp + vfs-rar + vfs-libarchive + urllib3 + upnext + trakt + trakt-module + sponsorblock + invidious + simplecache + libretro + libretro-snes9x + libretro-nestopia + jellycon + archive_tool + joystick + keymap + jellyfin + visualization-projectm + visualization-goom + steam-launcher + ]); +in + + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + networking.hostName = "htpc"; # Define your hostname. + + services.displayManager = { + autoLogin.user = "k3t"; + }; + + users.users.k3t = { + packages = with pkgs; [ + kodi-with-addons + ]; + }; +} diff --git a/hosts/htpc/hardware-configuration.nix b/hosts/htpc/hardware-configuration.nix new file mode 100755 index 0000000..11d0ace --- /dev/null +++ b/hosts/htpc/hardware-configuration.nix @@ -0,0 +1,33 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usbhid" "uas" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/9e3085ab-53c4-4301-be0b-ea60edeb5ef5"; + fsType = "btrfs"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/2C85-DE7B"; + fsType = "vfat"; + options = [ "fmask=0022" "dmask=0022" ]; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/54f5cbbd-333d-42b4-ab70-033b2a0d20a2"; } + ]; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; +} + diff --git a/hosts/laptop/configuration.nix b/hosts/laptop/configuration.nix index f0d83eb..7b61d97 100755 --- a/hosts/laptop/configuration.nix +++ b/hosts/laptop/configuration.nix @@ -10,17 +10,7 @@ ./hardware-configuration.nix ]; - services.beesd.filesystems = { - root = { - spec = "LABEL=NixOS"; - hashTableSizeMB = 128; - verbosity = "crit"; - extraOptions = [ "--loadavg-target" "1.5" ]; - }; - }; - networking.hostName = "T14"; # Define your hostname. - services.openssh.enable = true; users.users.k3t = { packages = with pkgs; [ diff --git a/modules/audio/base.nix b/modules/audio/base.nix index 456d5b7..860d754 100644 --- a/modules/audio/base.nix +++ b/modules/audio/base.nix @@ -1,6 +1,13 @@ { pkgs, lib, ... }: { + environment.systemPackages = with pkgs; [ + pavucontrol + pwvucontrol + qpwgraph + easyeffects + ]; + # Enable sound with pipewire. security.rtkit.enable = true; services.pipewire = { diff --git a/modules/gui/apps/steam.nix b/modules/gui/apps/steam.nix new file mode 100644 index 0000000..256e655 --- /dev/null +++ b/modules/gui/apps/steam.nix @@ -0,0 +1,17 @@ +{ pkgs, ... }: + +{ + programs.steam = { + enable = true; + gamescopeSession.enable = true; + extraCompatPackages = with pkgs; [ + proton-ge-bin + ]; + localNetworkGameTransfers.openFirewall = true; + }; + programs.gamemode.enable = true; + programs.gamescope = { + enable = true; + capSysNice = true; + }; +} \ No newline at end of file diff --git a/modules/gui/services/fcast.nix b/modules/gui/services/fcast.nix new file mode 100644 index 0000000..a662c18 --- /dev/null +++ b/modules/gui/services/fcast.nix @@ -0,0 +1,6 @@ +{ + programs.fcast-receiver = { + enable = true; + openFirewall = true; + }; +} \ No newline at end of file diff --git a/modules/gui/services/xdg.nix b/modules/gui/services/xdg.nix index eb3e1ee..f784a02 100644 --- a/modules/gui/services/xdg.nix +++ b/modules/gui/services/xdg.nix @@ -1,3 +1,8 @@ +{ pkgs, ... }: + { - xdg.portal.enable = true; + xdg.portal = { + enable = true; + extraPortals = [ pkgs.xdg-desktop-portal-gtk ]; + }; } \ No newline at end of file diff --git a/modules/sys/hw/boot.nix b/modules/sys/hw/boot.nix index 97438ca..e490345 100644 --- a/modules/sys/hw/boot.nix +++ b/modules/sys/hw/boot.nix @@ -1,6 +1,11 @@ { pkgs, ... }: { + boot.kernelParams = [ + "split_lock_detect=off" + "scsi_mod.use_blk_mq=1" + "transparent_hugepage=madvise" # CachyOS default + ]; boot.loader.limine.enable = true; boot.loader.efi.canTouchEfiVariables = true; boot.extraModulePackages = [ ]; diff --git a/modules/sys/hw/cpu/amd64.nix b/modules/sys/hw/cpu/amd64.nix index 5c7d5df..cf4a151 100644 --- a/modules/sys/hw/cpu/amd64.nix +++ b/modules/sys/hw/cpu/amd64.nix @@ -1,6 +1,7 @@ { pkgs, ... }: { + hardware.cpu.amd.updateMicrocode = true; boot.kernelPackages = pkgs.linuxPackages_xanmod_latest; boot.binfmt.preferStaticEmulators = true; boot.binfmt.emulatedSystems = [ "aarch64-linux" "x86_64-windows" ]; diff --git a/modules/sys/hw/cpu/intel.nix b/modules/sys/hw/cpu/intel.nix index 370b065..ef203b6 100644 --- a/modules/sys/hw/cpu/intel.nix +++ b/modules/sys/hw/cpu/intel.nix @@ -1,6 +1,7 @@ { pkgs, ... }: { + hardware.cpu.intel.updateMicrocode = true; boot.kernelPackages = pkgs.linuxPackages_xanmod_latest; boot.binfmt.preferStaticEmulators = true; boot.binfmt.emulatedSystems = [ "aarch64-linux" "x86_64-windows" ]; diff --git a/modules/sys/hw/gpu/amd.nix b/modules/sys/hw/gpu/amd.nix index 544b7b4..4647657 100644 --- a/modules/sys/hw/gpu/amd.nix +++ b/modules/sys/hw/gpu/amd.nix @@ -1,3 +1,12 @@ +{ pkgs, ... }: { - + # Graphics + hardware.enableRedistributableFirmware = true; + hardware.graphics = { + enable = true; + enable32Bit = true; + extraPackages = with pkgs; [ + vkbasalt + ]; + }; } \ No newline at end of file diff --git a/modules/sys/hw/gpu/intel.nix b/modules/sys/hw/gpu/intel.nix index be05876..5b2e44f 100644 --- a/modules/sys/hw/gpu/intel.nix +++ b/modules/sys/hw/gpu/intel.nix @@ -14,7 +14,8 @@ # Optional (compute / tooling): intel-compute-runtime # OpenCL (NEO) + Level Zero for Arc/Xe # NOTE: 'intel-ocl' also exists as a legacy package; not recommended for Arc/Xe. - # libvdpau-va-gl # Only if you must run VDPAU-only apps + libvdpau-va-gl # Only if you must run VDPAU-only apps + vkbasalt ]; }; } \ No newline at end of file diff --git a/modules/sys/perf.nix b/modules/sys/perf.nix index 75dcbaa..21935c5 100644 --- a/modules/sys/perf.nix +++ b/modules/sys/perf.nix @@ -1,8 +1,24 @@ { + services.beesd.filesystems = { + root = { + spec = "LABEL=NixOS"; + hashTableSizeMB = 128; + verbosity = "crit"; + extraOptions = [ "--loadavg-target" "1.5" ]; + }; + }; + services.fstrim.enable = true; services.system76-scheduler.enable = true; #services.thermald.enable = true; services.power-profiles-daemon.enable = true; systemd.coredump.enable = false; - zramSwap.enable = true; - zramSwap.memoryPercent = 80; + zramSwap = { + enable = true; + algorithm = "zstd"; + memoryPercent = 90; + }; + services.udev.extraRules = '' + ACTION=="add|change", KERNEL=="nvme[0-9]*", ATTR{queue/scheduler}="kyber" + ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="kyber" + ''; } \ No newline at end of file diff --git a/modules/sys/pkgs.nix b/modules/sys/pkgs.nix index 2b7b977..2b37969 100644 --- a/modules/sys/pkgs.nix +++ b/modules/sys/pkgs.nix @@ -9,7 +9,14 @@ htop mosh btop - wget2 python314 + wget2 + dnsutils + fastfetch + peazip + p7zip + whois + ffmpeg + playerctl ]; } \ No newline at end of file diff --git a/modules/sys/rgb.nix b/modules/sys/rgb.nix index b2e36b8..3c16fcc 100644 --- a/modules/sys/rgb.nix +++ b/modules/sys/rgb.nix @@ -1,6 +1,9 @@ { pkgs, lib, ... }: { + environment.systemPackages = with pkgs; [ + openrgb-with-all-plugins + ]; # OpenRGB services.hardware.openrgb = { enable = true; diff --git a/modules/sys/security.nix b/modules/sys/security.nix index c538485..1d9093b 100644 --- a/modules/sys/security.nix +++ b/modules/sys/security.nix @@ -1,5 +1,9 @@ { - security.polkit.enable = true; + security = { + sudo.execWheelOnly = true; + polkit.enable = true; + protectKernelImage = true; + }; system.autoUpgrade = { enable = true; flake = "git+https://k3t.dev/git/nixconf.git?ref=main"; diff --git a/modules/sys/sysctl.nix b/modules/sys/sysctl.nix new file mode 100644 index 0000000..3851d55 --- /dev/null +++ b/modules/sys/sysctl.nix @@ -0,0 +1,18 @@ +{ + # Transparent Hugepages for better memory performance + boot.kernel.sysctl = { + "vm.max_map_count" = 1048576; # For some games that need it + "vm.swappiness" = 200; # Reduce swapping + # BBR congestion control + "net.core.default_qdisc" = "fq"; + "net.ipv4.tcp_congestion_control" = "bbr"; + "kernel.sysrq" = 1; # Enable SysRq for emergency recovery + + # CachyOS performance tweaks + "kernel.nmi_watchdog" = 0; # Disable NMI watchdog (reduces overhead) + "vm.vfs_cache_pressure" = 50; # Better file cache retention + "vm.dirty_ratio" = 10; # Faster writes to disk + "vm.dirty_background_ratio" = 5; # Background write threshold + "kernel.sched_autogroup_enabled" = 0; # Better CPU scheduling for gaming + }; +} \ No newline at end of file diff --git a/modules/sys/tz.nix b/modules/sys/time.nix similarity index 56% rename from modules/sys/tz.nix rename to modules/sys/time.nix index 121e7e7..fd5e229 100644 --- a/modules/sys/tz.nix +++ b/modules/sys/time.nix @@ -1,4 +1,19 @@ { + # NTP configuration - NIST atomic clocks + services.timesyncd = { + enable = true; + servers = [ + "192.168.0.1" + ]; + fallbackServers = [ + "time-a-g.nist.gov" + "time-a.nist.gov" + "time-b.nist.gov" + "time-c.nist.gov" + "time.cloudflare.com" + "0.pool.ntp.org" + ]; + }; time.timeZone = "America/Denver"; i18n.defaultLocale = "en_US.UTF-8"; i18n.extraLocaleSettings = { diff --git a/modules/sys/vm.nix b/modules/sys/vm.nix new file mode 100644 index 0000000..0d6387b --- /dev/null +++ b/modules/sys/vm.nix @@ -0,0 +1,11 @@ +{ pkgs, ... }: + +{ + virtualisation.libvirtd = { + enable = true; + qemu = { + package = pkgs.qemu_kvm; + swtpm.enable = true; # This enables TPM support + }; + }; +} \ No newline at end of file