From 506525af3574cce5e4a7db846e53fe110169fab8 Mon Sep 17 00:00:00 2001 From: Crony Akatsuki Date: Sun, 25 Jan 2026 19:46:53 +0100 Subject: [PATCH] feat: move stuff around a bit, created new modules. --- hosts/skadi/configuration.nix | 216 +---------------------- modules/linux/nixos/default.nix | 7 + modules/linux/nixos/flatpak.nix | 26 +++ modules/linux/nixos/gaming.nix | 7 + modules/linux/nixos/general-services.nix | 9 + modules/linux/nixos/nix-options.nix | 64 +++++++ modules/linux/nixos/ollama.nix | 3 - modules/linux/nixos/oom.nix | 1 - modules/linux/nixos/pc-services.nix | 28 +++ modules/linux/nixos/pipewire.nix | 97 ++++++++++ modules/linux/nixos/qemu.nix | 3 + modules/linux/nixos/wireguard.nix | 1 - 12 files changed, 247 insertions(+), 215 deletions(-) create mode 100644 modules/linux/nixos/flatpak.nix create mode 100644 modules/linux/nixos/nix-options.nix create mode 100644 modules/linux/nixos/pc-services.nix create mode 100644 modules/linux/nixos/pipewire.nix diff --git a/hosts/skadi/configuration.nix b/hosts/skadi/configuration.nix index fa89fe8..2c6acbe 100644 --- a/hosts/skadi/configuration.nix +++ b/hosts/skadi/configuration.nix @@ -35,6 +35,8 @@ # Use the xanmod kernel boot.kernelPackages = pkgs.cachyosKernels.linuxPackages-cachyos-latest-lto-x86_64-v3; + + # Setup userspace schedulers services.scx = { enable = true; scheduler = "scx_lavd"; @@ -43,12 +45,6 @@ # Get nicer hostname networking.hostName = "skadi"; # Define your hostname. - # Enable flakes - nix.settings.experimental-features = ["nix-command" "flakes"]; - - # Enable trusted users - nix.settings.trusted-users = ["root" "@wheel"]; - # Setup gpu hardware.graphics = { enable = true; @@ -90,151 +86,8 @@ LC_TIME = "hr_HR.UTF-8"; }; - # # Enable the X11 windowing system. - # services.xserver.enable = true; - # - # # Configure keymap in X11 - # services.xserver.xkb = { - # layout = "us"; - # variant = ""; - # options = "caps:escape"; - # }; - - # Enable seatd - services.seatd.enable = true; - - # Enable flatpak - services.flatpak = { - enable = true; - packages = [ - "com.dec05eba.gpu_screen_recorder" - ]; - - uninstallUnmanaged = true; - - update.auto = { - enable = true; - onCalendar = "weekly"; - }; - }; - networking.firewall.allowedTCPPorts = [42000 42001]; - # Enable coolercontrol to setup fancurves - programs.coolercontrol = { - enable = true; - }; - - # Setup gpu fan curves and light undervolt - services.lact.enable = true; - - # Setup display brightness changing using ddcutil - hardware.i2c.enable = true; - - # Setup rgb control - services.hardware.openrgb.enable = true; - - # Needed modules to have fan control and ntsync - boot.kernelModules = ["coretemp" "nct6775" "ntsync"]; - - # Enable ratbagd to customize mouse options - services.ratbagd.enable = true; - - # Enable dconf - programs.dconf.enable = true; - - # Enable AAGL - # programs.anime-game-launcher.enable = true; - - # Enable sleepy launcher - programs.sleepy-launcher.enable = true; - - # Enable sound with pipewire. - security.rtkit.enable = true; - services.pipewire = { - enable = true; - pulse.enable = true; - alsa = { - enable = true; - support32Bit = true; - }; - wireplumber.extraConfig = { - "51-disable-suspension" = { - "monitor.alsa.rules" = [ - { - matches = [ - { - node.name = "~alsa_input.*"; - } - { - node.name = "~alsa_output.*"; - } - ]; - actions = { - update-props = { - "session.suspend-timeout-seconds" = 0; - }; - }; - } - ]; - "monitor.bluez.rules" = [ - { - matches = [ - { - node.name = "~alsa_input.*"; - } - { - node.name = "~alsa_output.*"; - } - ]; - actions = { - update-props = { - "session.suspend-timeout-seconds" = 0; - }; - }; - } - ]; - }; - }; - extraConfig = { - pipewire."99-silent.bell.conf" = { - "context.properties" = { - "modules.x11.bell" = false; - }; - }; - pipewire."92-low-latency" = { - "context.properties" = { - "default.clock.rate" = 48000; - "default.clock.quantum" = 64; - "default.clock.min-quantum" = 64; - "default.clock.max-quantum" = 64; - }; - }; - pipewire-pulse."92-low-latency" = { - "context.properties" = [ - { - name = "libpipewire-module-protocol-pulse"; - args = {}; - } - ]; - "pulse.properties" = { - "pulse.min.req" = "64/48000"; - "pulse.default.req" = "64/48000"; - "pulse.max.req" = "64/48000"; - "pulse.min.quantum" = "64/48000"; - "pulse.max.quantum" = "64/48000"; - }; - "stream.properties" = { - "node.latency" = "64/48000"; - "resample.quality" = 1; - }; - }; - }; - }; - - # Fix not saving my state - hardware.alsa.enablePersistence = true; - # Enable appimages programs.appimage = { enable = true; @@ -256,60 +109,6 @@ users.mutableUsers = false; - # Allow unfree packages - nixpkgs.config.allowUnfree = true; - - # Setup community cache - nix.settings = { - substituters = [ - "https://nix-community.cachix.org" - "https://hyprland.cachix.org" - "https://ezkea.cachix.org" - "https://nix-gaming.cachix.org" - "https://cache.nixos-cuda.org" - "https://deploy-rs.cachix.org" - "https://attic.xuyh0120.win/lantian" - ]; - trusted-substituters = [ - "https://hyprland.cachix.org" - ]; - trusted-public-keys = [ - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" - "ezkea.cachix.org-1:ioBmUbJTZIKsHmWWXPe1FSFbeVe+afhfgqgTSNd34eI=" - "nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4=" - "cache.nixos-cuda.org:74DUi4Ye579gUqzH4ziL9IyiJBlDpMRn9MBN8oNan9M=" - "deploy-rs.cachix.org-1:xfNobmiwF/vzvK1gpfediPwpdIP0rpDV2rYqx40zdSI=" - "lantian:EeAUQ+W+6r7EtwnmYjeVwx5kOGEBpjlBfPlzGlTNvHc=" - ]; - }; - - # setup custom packages - nixpkgs = { - overlays = [ - (final: prev: { - # Fix for wl-clipboard not having support for not setting sensitive for password managers - wl-clipboard = prev.wl-clipboard.overrideAttrs (old: { - version = "24-04-25"; - src = prev.fetchFromGitHub { - owner = "bugaevc"; - repo = "wl-clipboard"; - rev = "aaa927ee7f7d91bcc25a3b68f60d01005d3b0f7f"; - hash = "sha256-V8JAai4gZ1nzia4kmQVeBwidQ+Sx5A5on3SJGSevrUU="; - }; - }); - }) - (import inputs.emacs-overlay) - inputs.nix-cachyos-kernel.overlays.pinned - ]; - }; - - # Optimise storage - nix.optimise = { - automatic = true; - dates = ["weekly"]; - }; - # Enable my flake specific settings crony.gaming.enable = true; crony.additional-hardware.enable = true; @@ -323,9 +122,10 @@ crony.sunshine.enable = true; crony.bluetooth.enable = true; crony.localsend.enable = true; - - # Setup spice usb redirection - virtualisation.spiceUSBRedirection.enable = true; + crony.flatpak.enable = true; + crony.qemu.enable = true; + crony.pc-services.enable = true; + crony.pipewire.enable = true; # Mount additional drive for games fileSystems."/mnt/games" = { @@ -354,12 +154,8 @@ libva-utils alsa-utils ddcutil - quickemu ]; - # Enable nixd to see nixpkgs path - nix.nixPath = ["nixpkgs=${inputs.nixpkgs}"]; - # DO NOT CHANGE system.stateVersion = "24.11"; } diff --git a/modules/linux/nixos/default.nix b/modules/linux/nixos/default.nix index a26dbd8..0a3a12d 100644 --- a/modules/linux/nixos/default.nix +++ b/modules/linux/nixos/default.nix @@ -29,6 +29,10 @@ ./kanata.nix ./keyd.nix ./localsend.nix + ./nix-options.nix + ./flatpak.nix + ./pc-services.nix + ./pipewire.nix ]; crony.bluetooth.enable = lib.mkDefault true; @@ -60,4 +64,7 @@ crony.kanata.enable = lib.mkDefault false; crony.keyd.enable = lib.mkDefault true; crony.localsend.enable = lib.mkDefault false; + crony.flatpak.enable = lib.mkDefault false; + crony.pc-services.enable = lib.mkDefault false; + crony.pipewire.enable = lib.mkDefault false; } diff --git a/modules/linux/nixos/flatpak.nix b/modules/linux/nixos/flatpak.nix new file mode 100644 index 0000000..1658b8b --- /dev/null +++ b/modules/linux/nixos/flatpak.nix @@ -0,0 +1,26 @@ +{ + config, + lib, + ... +}: { + options = { + crony.flatpak.enable = lib.mkEnableOption "Enable and install flatpak packages."; + }; + + config = lib.mkIf config.crony.flatpak.enable { + # Enable flatpak + services.flatpak = { + enable = true; + packages = [ + "com.dec05eba.gpu_screen_recorder" + ]; + + uninstallUnmanaged = true; + + update.auto = { + enable = true; + onCalendar = "weekly"; + }; + }; + }; +} diff --git a/modules/linux/nixos/gaming.nix b/modules/linux/nixos/gaming.nix index 7ae9669..de62293 100644 --- a/modules/linux/nixos/gaming.nix +++ b/modules/linux/nixos/gaming.nix @@ -9,6 +9,9 @@ crony.gaming.enable = lib.mkEnableOption "enable gaming related stuff, like steam and gamemode"; }; config = lib.mkIf config.crony.gaming.enable { + # Setup ntsync + boot.kernelModules = ["ntsync"]; + # Install steam programs.steam = { enable = true; @@ -36,6 +39,7 @@ }; }; }; + # Setup esync systemd.settings.Manager = { DefaultLimitNOFILE = 1048576; @@ -49,6 +53,9 @@ } ]; + # Enable sleepy launcher + programs.sleepy-launcher.enable = true; + # Setup switch pro controller hardware.steam-hardware.enable = true; services.joycond.enable = true; diff --git a/modules/linux/nixos/general-services.nix b/modules/linux/nixos/general-services.nix index 94fea29..d6d37a2 100644 --- a/modules/linux/nixos/general-services.nix +++ b/modules/linux/nixos/general-services.nix @@ -34,5 +34,14 @@ # Setup fstrim services.fstrim.enable = true; + + # Enable seatd + services.seatd.enable = true; + + # Enable ratbagd to customize mouse options + services.ratbagd.enable = true; + + # Enable dconf + programs.dconf.enable = true; }; } diff --git a/modules/linux/nixos/nix-options.nix b/modules/linux/nixos/nix-options.nix new file mode 100644 index 0000000..ea9c756 --- /dev/null +++ b/modules/linux/nixos/nix-options.nix @@ -0,0 +1,64 @@ +{inputs, ...}: { + # Enable flakes + nix.settings.experimental-features = ["nix-command" "flakes"]; + + # Enable trusted users + nix.settings.trusted-users = ["root" "@wheel"]; + + # Setup community cache + nix.settings = { + substituters = [ + "https://nix-community.cachix.org" + "https://hyprland.cachix.org" + "https://ezkea.cachix.org" + "https://nix-gaming.cachix.org" + "https://cache.nixos-cuda.org" + "https://deploy-rs.cachix.org" + "https://attic.xuyh0120.win/lantian" + ]; + trusted-substituters = [ + "https://hyprland.cachix.org" + ]; + trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" + "ezkea.cachix.org-1:ioBmUbJTZIKsHmWWXPe1FSFbeVe+afhfgqgTSNd34eI=" + "nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4=" + "cache.nixos-cuda.org:74DUi4Ye579gUqzH4ziL9IyiJBlDpMRn9MBN8oNan9M=" + "deploy-rs.cachix.org-1:xfNobmiwF/vzvK1gpfediPwpdIP0rpDV2rYqx40zdSI=" + "lantian:EeAUQ+W+6r7EtwnmYjeVwx5kOGEBpjlBfPlzGlTNvHc=" + ]; + }; + + # setup custom packages + nixpkgs = { + overlays = [ + (final: prev: { + # Fix for wl-clipboard not having support for not setting sensitive for password managers + wl-clipboard = prev.wl-clipboard.overrideAttrs (old: { + version = "24-04-25"; + src = prev.fetchFromGitHub { + owner = "bugaevc"; + repo = "wl-clipboard"; + rev = "aaa927ee7f7d91bcc25a3b68f60d01005d3b0f7f"; + hash = "sha256-V8JAai4gZ1nzia4kmQVeBwidQ+Sx5A5on3SJGSevrUU="; + }; + }); + }) + (import inputs.emacs-overlay) + inputs.nix-cachyos-kernel.overlays.pinned + ]; + }; + + # Optimise storage + nix.optimise = { + automatic = true; + dates = ["weekly"]; + }; + + # Enable nixd to see nixpkgs path + nix.nixPath = ["nixpkgs=${inputs.nixpkgs}"]; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; +} diff --git a/modules/linux/nixos/ollama.nix b/modules/linux/nixos/ollama.nix index 6f73f58..afd998f 100644 --- a/modules/linux/nixos/ollama.nix +++ b/modules/linux/nixos/ollama.nix @@ -15,8 +15,5 @@ loadModels = ["gpt-oss:20b"]; environmentVariables = {OLLAMA_KEEP_ALIVE = "2m";}; }; - - # systemd.services.ollama.wantedBy = lib.mkForce []; - # systemd.services.ollama-model-loader.wantedBy = lib.mkForce []; }; } diff --git a/modules/linux/nixos/oom.nix b/modules/linux/nixos/oom.nix index ddb8079..305666a 100644 --- a/modules/linux/nixos/oom.nix +++ b/modules/linux/nixos/oom.nix @@ -8,7 +8,6 @@ }; config = lib.mkIf config.crony.oom.enable { - nix.settings.max-jobs = 8; services.earlyoom = { enable = true; enableNotifications = true; diff --git a/modules/linux/nixos/pc-services.nix b/modules/linux/nixos/pc-services.nix new file mode 100644 index 0000000..7f6173d --- /dev/null +++ b/modules/linux/nixos/pc-services.nix @@ -0,0 +1,28 @@ +{ + config, + lib, + ... +}: { + options = { + crony.pc-services.enable = lib.mkEnableOption "Enable and setup pc related service for gpu/fan/rgb management."; + }; + + config = lib.mkIf config.crony.pc-services.enable { + # Enable coolercontrol to setup fancurves + programs.coolercontrol = { + enable = true; + }; + + # Setup gpu fan curves and light undervolt + services.lact.enable = true; + + # Setup display brightness changing using ddcutil + hardware.i2c.enable = true; + + # Setup rgb control + services.hardware.openrgb.enable = true; + + # Needed modules to have fan control + boot.kernelModules = ["coretemp" "nct6775"]; + }; +} diff --git a/modules/linux/nixos/pipewire.nix b/modules/linux/nixos/pipewire.nix new file mode 100644 index 0000000..5e456fb --- /dev/null +++ b/modules/linux/nixos/pipewire.nix @@ -0,0 +1,97 @@ +{ + config, + lib, + ... +}: { + options = { + crony.pipewire.enable = lib.mkEnableOption "Enable and setup pipewire with settings."; + }; + + config = lib.mkIf config.crony.pipewire.enable { + # Enable sound with pipewire. + security.rtkit.enable = true; + services.pipewire = { + enable = true; + pulse.enable = true; + alsa = { + enable = true; + support32Bit = true; + }; + wireplumber.extraConfig = { + "51-disable-suspension" = { + "monitor.alsa.rules" = [ + { + matches = [ + { + node.name = "~alsa_input.*"; + } + { + node.name = "~alsa_output.*"; + } + ]; + actions = { + update-props = { + "session.suspend-timeout-seconds" = 0; + }; + }; + } + ]; + "monitor.bluez.rules" = [ + { + matches = [ + { + node.name = "~alsa_input.*"; + } + { + node.name = "~alsa_output.*"; + } + ]; + actions = { + update-props = { + "session.suspend-timeout-seconds" = 0; + }; + }; + } + ]; + }; + }; + extraConfig = { + pipewire."99-silent.bell.conf" = { + "context.properties" = { + "modules.x11.bell" = false; + }; + }; + pipewire."92-low-latency" = { + "context.properties" = { + "default.clock.rate" = 48000; + "default.clock.quantum" = 64; + "default.clock.min-quantum" = 64; + "default.clock.max-quantum" = 64; + }; + }; + pipewire-pulse."92-low-latency" = { + "context.properties" = [ + { + name = "libpipewire-module-protocol-pulse"; + args = {}; + } + ]; + "pulse.properties" = { + "pulse.min.req" = "64/48000"; + "pulse.default.req" = "64/48000"; + "pulse.max.req" = "64/48000"; + "pulse.min.quantum" = "64/48000"; + "pulse.max.quantum" = "64/48000"; + }; + "stream.properties" = { + "node.latency" = "64/48000"; + "resample.quality" = 1; + }; + }; + }; + }; + + # Fix not saving my state + hardware.alsa.enablePersistence = true; + }; +} diff --git a/modules/linux/nixos/qemu.nix b/modules/linux/nixos/qemu.nix index b12b78d..d6c4256 100644 --- a/modules/linux/nixos/qemu.nix +++ b/modules/linux/nixos/qemu.nix @@ -15,5 +15,8 @@ qemu quickemu ]; + + # Setup spice usb redirection + virtualisation.spiceUSBRedirection.enable = true; }; } diff --git a/modules/linux/nixos/wireguard.nix b/modules/linux/nixos/wireguard.nix index c2d467c..90ca9de 100644 --- a/modules/linux/nixos/wireguard.nix +++ b/modules/linux/nixos/wireguard.nix @@ -15,7 +15,6 @@ }; networking.wg-quick.interfaces.wg1 = { autostart = false; - # configFile = "${config.age.secrets.wg-home.path}"; configFile = "${config.age.secrets.wg-ymir-home.path}"; }; };