From 112930703721f51844f1dfbf618f1f8e94110823 Mon Sep 17 00:00:00 2001 From: Nuno David Date: Sat, 19 Sep 2026 17:21:06 +0100 Subject: [PATCH 1/2] feat: setup javelin host --- flake.nix | 1 + hosts/javelin/default.nix | 32 +++++++++++++++++ hosts/javelin/hardware.nix | 70 ++++++++++++++++++++++++++++++++++++ hosts/wopr/default.nix | 3 +- modules/amd.nix | 20 +++++++++++ modules/common.nix | 2 ++ modules/gaming.nix | 1 + modules/hyprland/default.nix | 4 +-- modules/nix.nix | 12 +++++-- modules/nvidia.nix | 4 +-- modules/options.nix | 15 +++----- 11 files changed, 146 insertions(+), 18 deletions(-) create mode 100644 hosts/javelin/default.nix create mode 100644 hosts/javelin/hardware.nix create mode 100644 modules/amd.nix diff --git a/flake.nix b/flake.nix index 6796602..80b54b9 100644 --- a/flake.nix +++ b/flake.nix @@ -68,6 +68,7 @@ hosts = { wopr = "x86_64-linux"; + javelin = "x86_64-linux"; }; forEachSystem = nixpkgs.lib.genAttrs systems; diff --git a/hosts/javelin/default.nix b/hosts/javelin/default.nix new file mode 100644 index 0000000..ef4a312 --- /dev/null +++ b/hosts/javelin/default.nix @@ -0,0 +1,32 @@ +{ + ... +}: +{ + imports = [ + ./hardware.nix + ]; + + host = { + owner = "ndavd"; + name = "javelin"; + + primaryMonitor = { + output = "DP-1"; + width = 2560; + height = 1440; + refreshRate = 240; + scale = 1.0; + }; + secondaryMonitor = { + output = "HDMI-A-1"; + width = 1920; + height = 1080; + refreshRate = 60; + scale = 1.0; + }; + + gpu = "amd"; + + gaming.enable = true; + }; +} diff --git a/hosts/javelin/hardware.nix b/hosts/javelin/hardware.nix new file mode 100644 index 0000000..44f263f --- /dev/null +++ b/hosts/javelin/hardware.nix @@ -0,0 +1,70 @@ +{ + config, + lib, + modulesPath, + ... +}: +{ + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot = { + initrd = { + availableKernelModules = [ + "nvme" + "xhci_pci" + "ahci" + "usbhid" + "usb_storage" + "sd_mod" + ]; + kernelModules = [ ]; + luks.devices."cryptroot".device = "/dev/disk/by-uuid/16331fde-6c45-417c-8a8b-efaf2c195a88"; + }; + kernelModules = [ "kvm-amd" ]; + extraModulePackages = [ ]; + }; + + fileSystems = { + "/" = { + device = "/dev/mapper/cryptroot"; + fsType = "btrfs"; + options = [ + "subvol=@" + "noatime" + "compress=zstd:1" + ]; + }; + "/home" = { + device = "/dev/mapper/cryptroot"; + fsType = "btrfs"; + options = [ + "subvol=@home" + "noatime" + "compress=zstd:1" + ]; + }; + "/nix" = { + device = "/dev/mapper/cryptroot"; + fsType = "btrfs"; + options = [ + "subvol=@nix" + "noatime" + "compress=zstd:1" + ]; + }; + "/boot" = { + device = "/dev/disk/by-uuid/8C10-7D2F"; + fsType = "vfat"; + options = [ + "fmask=0022" + "dmask=0022" + ]; + }; + }; + + swapDevices = [ ]; + + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/wopr/default.nix b/hosts/wopr/default.nix index c5f424e..e1fe7a7 100644 --- a/hosts/wopr/default.nix +++ b/hosts/wopr/default.nix @@ -28,8 +28,7 @@ scale = 1.25; }; - nvidiaGpu.enable = true; - cpu = "amd"; + gpu = "nvidia"; gaming.enable = true; }; diff --git a/modules/amd.nix b/modules/amd.nix new file mode 100644 index 0000000..38af6bc --- /dev/null +++ b/modules/amd.nix @@ -0,0 +1,20 @@ +{ + config, + lib, + ... +}: +let + inherit (config.host) gpu; +in +{ + config = lib.mkIf (gpu == "amd") { + hardware = { + graphics = { + enable = true; + enable32Bit = true; + }; + amdgpu.opencl.enable = true; + }; + nixpkgs.config.rocmSupport = true; + }; +} diff --git a/modules/common.nix b/modules/common.nix index 2abab67..ab68391 100644 --- a/modules/common.nix +++ b/modules/common.nix @@ -74,6 +74,7 @@ in power-profiles-daemon.enable = true; upower.enable = true; udisks2.enable = true; + hardware.openrgb.enable = true; resolved = { enable = true; settings.Resolve = { @@ -103,6 +104,7 @@ in obs-pipewire-audio-capture ]; }; + coolercontrol.enable = true; }; virtualisation.docker.enable = true; diff --git a/modules/gaming.nix b/modules/gaming.nix index e23f0a5..c1e167f 100644 --- a/modules/gaming.nix +++ b/modules/gaming.nix @@ -26,6 +26,7 @@ in protonup-ng winetricks heroic + mangohud ]; }; }; diff --git a/modules/hyprland/default.nix b/modules/hyprland/default.nix index 00d0983..ffb8ef8 100644 --- a/modules/hyprland/default.nix +++ b/modules/hyprland/default.nix @@ -9,7 +9,7 @@ let inherit (config.host) owner - nvidiaGpu + gpu launcher primaryMonitor secondaryMonitor @@ -100,7 +100,7 @@ in ELECTRON_OZONE_PLATFORM_HINT = "auto"; QT_QPA_PLATFORM = "wayland"; } - // lib.optionalAttrs nvidiaGpu.enable { + // lib.optionalAttrs (gpu == "nvidia") { LIBVA_DRIVER_NAME = "nvidia"; __GLX_VENDOR_LIBRARY_NAME = "nvidia"; NVD_BACKEND = "direct"; diff --git a/modules/nix.nix b/modules/nix.nix index a392ff0..2755820 100644 --- a/modules/nix.nix +++ b/modules/nix.nix @@ -1,10 +1,11 @@ { config, pkgs, + lib, ... }: let - inherit (config.host) owner; + inherit (config.host) owner gpu; in { nixpkgs.config.allowUnfree = true; @@ -24,7 +25,10 @@ in settings = { builders-use-substitutes = true; - trusted-users = [ owner ]; + trusted-users = [ + "root" + "@wheel" + ]; download-buffer-size = 500000000; experimental-features = [ @@ -37,6 +41,8 @@ in "https://cache.nixos.org" "https://nix-community.cachix.org" "https://hyprland.cachix.org" + ] + ++ lib.optionals (gpu == "nvidia") [ "https://cache.nixos-cuda.org" ]; @@ -44,6 +50,8 @@ in "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" + ] + ++ lib.optionals (gpu == "nvidia") [ "cache.nixos-cuda.org:74DUi4Ye579gUqzH4ziL9IyiJBlDpMRn9MBN8oNan9M=" ]; }; diff --git a/modules/nvidia.nix b/modules/nvidia.nix index 2166e69..4448d10 100644 --- a/modules/nvidia.nix +++ b/modules/nvidia.nix @@ -4,10 +4,10 @@ ... }: let - inherit (config.host) nvidiaGpu; + inherit (config.host) gpu; in { - config = lib.mkIf nvidiaGpu.enable { + config = lib.mkIf (gpu == "nvidia") { services.xserver.videoDrivers = [ "nvidia" ]; hardware.nvidia = { open = true; diff --git a/modules/options.nix b/modules/options.nix index 29ce5fc..e7361fa 100644 --- a/modules/options.nix +++ b/modules/options.nix @@ -36,16 +36,11 @@ in gaming.enable = lib.mkEnableOption "gaming capabilities"; - nvidiaGpu.enable = lib.mkEnableOption "NVIDIA GPU"; - - cpu = lib.mkOption { - type = lib.types.nullOr ( - lib.types.enum [ - "amd" - "intel" - ] - ); - default = null; + gpu = lib.mkOption { + type = lib.types.enum [ + "nvidia" + "amd" + ]; }; primaryMonitor = lib.mkOption { From 374ae8049914400a58eeea00eceb0ca7ef3adb04 Mon Sep 17 00:00:00 2001 From: Nuno David Date: Sat, 19 Sep 2026 20:50:51 +0100 Subject: [PATCH 2/2] feat: add option to toggle laptop capabilities --- hosts/javelin/default.nix | 1 - hosts/wopr/default.nix | 2 +- modules/common.nix | 11 ++++++++--- modules/options.nix | 2 ++ modules/quickshell/config/Config.qml | 2 ++ modules/quickshell/config/StatusBar.qml | 9 +++++++-- modules/quickshell/default.nix | 13 +++++++++---- 7 files changed, 29 insertions(+), 11 deletions(-) diff --git a/hosts/javelin/default.nix b/hosts/javelin/default.nix index ef4a312..087b445 100644 --- a/hosts/javelin/default.nix +++ b/hosts/javelin/default.nix @@ -26,7 +26,6 @@ }; gpu = "amd"; - gaming.enable = true; }; } diff --git a/hosts/wopr/default.nix b/hosts/wopr/default.nix index e1fe7a7..e870867 100644 --- a/hosts/wopr/default.nix +++ b/hosts/wopr/default.nix @@ -29,7 +29,7 @@ }; gpu = "nvidia"; - gaming.enable = true; + laptop.enable = true; }; } diff --git a/modules/common.nix b/modules/common.nix index ab68391..b60daa8 100644 --- a/modules/common.nix +++ b/modules/common.nix @@ -6,7 +6,12 @@ ... }: let - inherit (config.host) owner name browser; + inherit (config.host) + owner + name + browser + laptop + ; in { imports = [ @@ -71,8 +76,8 @@ in }; services = { - power-profiles-daemon.enable = true; - upower.enable = true; + power-profiles-daemon.enable = laptop.enable; + upower.enable = laptop.enable; udisks2.enable = true; hardware.openrgb.enable = true; resolved = { diff --git a/modules/options.nix b/modules/options.nix index e7361fa..413d1f8 100644 --- a/modules/options.nix +++ b/modules/options.nix @@ -34,6 +34,8 @@ in type = lib.types.nonEmptyStr; }; + laptop.enable = lib.mkEnableOption "laptop capabilities"; + gaming.enable = lib.mkEnableOption "gaming capabilities"; gpu = lib.mkOption { diff --git a/modules/quickshell/config/Config.qml b/modules/quickshell/config/Config.qml index fa7a526..d0690af 100644 --- a/modules/quickshell/config/Config.qml +++ b/modules/quickshell/config/Config.qml @@ -19,4 +19,6 @@ Singleton { readonly property int rightSideSpacing: 12 readonly property int kibPerGib: 1048576 + + readonly property bool hasStatusBarBattery: Quickshell.env("QS_STATUSBAR_BATTERY") !== "0" } diff --git a/modules/quickshell/config/StatusBar.qml b/modules/quickshell/config/StatusBar.qml index b2d5608..cd8f277 100644 --- a/modules/quickshell/config/StatusBar.qml +++ b/modules/quickshell/config/StatusBar.qml @@ -1,3 +1,4 @@ +pragma ComponentBehavior: Bound import QtQuick import QtQuick.Layouts import Quickshell @@ -57,8 +58,12 @@ PanelWindow { rootWindow: root } - Battery { - rootWindow: root + Loader { + active: Config.hasStatusBarBattery + visible: active + sourceComponent: Battery { + rootWindow: root + } } Clock { diff --git a/modules/quickshell/default.nix b/modules/quickshell/default.nix index a5cf0c4..6426854 100644 --- a/modules/quickshell/default.nix +++ b/modules/quickshell/default.nix @@ -4,12 +4,17 @@ ... }: let - inherit (config.host) owner; + inherit (config.host) owner laptop; in { - environment.systemPackages = with pkgs; [ - quickshell - ]; + environment = { + systemPackages = with pkgs; [ + quickshell + ]; + sessionVariables = { + QS_STATUSBAR_BATTERY = if laptop.enable then "1" else "0"; + }; + }; hjem.users.${owner}.xdg.config.files."quickshell".source = ./config; }