From 207b5165a3e259be98e1b5aa23110b2c84627d8c Mon Sep 17 00:00:00 2001 From: DashieTM Date: Wed, 7 May 2025 13:01:54 +0200 Subject: [PATCH 1/3] Hyprland hardware cursor fix --- modules/programs/hyprland/hyprland.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/programs/hyprland/hyprland.nix b/modules/programs/hyprland/hyprland.nix index ff13a4c..9ba4c3e 100644 --- a/modules/programs/hyprland/hyprland.nix +++ b/modules/programs/hyprland/hyprland.nix @@ -27,7 +27,6 @@ in { # main monitor "${config.conf.defaultMonitor},${config.conf.defaultMonitorMode},0x0,${config.conf.defaultMonitorScale}" # all others - ",highrr,auto,1" ]; example = ["DP-1,3440x1440@180,2560x0,1,vrr,0"]; type = with lib.types; listOf str; @@ -298,7 +297,7 @@ in { cursor = { enable_hyprcursor = true; - no_hardware_cursors = lib.mkIf config.mods.gpu.nvidia.enable true; + no_hardware_cursors = lib.mkDefault config.mods.gpu.nvidia.enable; # done with nix, this would break the current setup otherwise sync_gsettings_theme = false; }; -- 2.51.2 From 0c24809f25762af10f5a6deaf25b14c0e14cdc9b Mon Sep 17 00:00:00 2001 From: DashieTM Date: Fri, 9 May 2025 12:02:51 +0200 Subject: [PATCH 2/3] Add lib.mkDefault for non configurable defaults --- base/common_hardware.nix | 83 ++++++++++++++++++++-------------------- base/env.nix | 21 +++++----- base/xkb_layout.nix | 8 +++- home/common.nix | 25 ++++++------ home/default.nix | 10 +++-- lib/default.nix | 1 + lib/override.nix | 1 + modules/programs/gpu.nix | 3 +- 8 files changed, 82 insertions(+), 70 deletions(-) create mode 100644 lib/override.nix diff --git a/base/common_hardware.nix b/base/common_hardware.nix index e5b9029..8eb4e78 100644 --- a/base/common_hardware.nix +++ b/base/common_hardware.nix @@ -1,4 +1,5 @@ { + mkDashDefault, pkgs, config, lib, @@ -10,19 +11,18 @@ in { imports = [ (modulesPath + "/installer/scan/not-detected.nix") - #(modulesPath + "/misc/nixpkgs/read-only.nix") ]; - wsl.enable = config.conf.wsl; + wsl.enable = mkDashDefault config.conf.wsl; # Bootloader. boot = lib.mkIf (!config.conf.wsl) { - consoleLogLevel = 0; + consoleLogLevel = mkDashDefault 0; lanzaboote = lib.mkIf config.conf.secureBoot { - enable = true; - pkiBundle = "/var/lib/sbctl"; - settings.reboot-for-bitlocker = true; + enable = mkDashDefault true; + pkiBundle = mkDashDefault "/var/lib/sbctl"; + settings.reboot-for-bitlocker = mkDashDefault true; }; loader = { @@ -32,15 +32,15 @@ in { then lib.mkForce false else if config.conf.useSystemdBootloader then true - else false; + else mkDashDefault false; configurationLimit = 5; }; - efi.canTouchEfiVariables = true; + efi.canTouchEfiVariables = mkDashDefault true; }; - kernelPackages = lib.mkDefault pkgs.linuxPackages_latest; + kernelPackages = mkDashDefault pkgs.linuxPackages_latest; initrd = { - verbose = false; + verbose = mkDashDefault false; availableKernelModules = [ "nvme" "xhci_pci" @@ -60,46 +60,46 @@ in { }; networking = { - useDHCP = lib.mkDefault true; - networkmanager.enable = true; - hostName = hostName; + useDHCP = mkDashDefault true; + networkmanager.enable = mkDashDefault true; + hostName = mkDashDefault hostName; }; time = { - timeZone = config.conf.timezone; - hardwareClockInLocalTime = config.conf.systemLocalTime; + timeZone = mkDashDefault config.conf.timezone; + hardwareClockInLocalTime = mkDashDefault config.conf.systemLocalTime; }; - i18n.defaultLocale = config.conf.locale; + i18n.defaultLocale = mkDashDefault config.conf.locale; services = { - lorri.enable = true; - xserver.enable = true; - fstrim.enable = lib.mkDefault true; - pulseaudio.enable = false; + lorri.enable = mkDashDefault true; + xserver.enable = mkDashDefault true; + fstrim.enable = mkDashDefault true; + pulseaudio.enable = mkDashDefault false; pipewire = { - enable = true; + enable = mkDashDefault true; alsa = { - enable = true; - support32Bit = true; + enable = mkDashDefault true; + support32Bit = mkDashDefault true; }; - jack.enable = true; - pulse.enable = true; + jack.enable = mkDashDefault true; + pulse.enable = mkDashDefault true; }; }; - nixpkgs.hostPlatform = lib.mkDefault config.conf.system; + nixpkgs.hostPlatform = mkDashDefault config.conf.system; nix = { gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 7d --delete-generations +5"; + automatic = mkDashDefault true; + dates = mkDashDefault "weekly"; + options = mkDashDefault "--delete-older-than 7d --delete-generations +5"; }; settings = { trusted-users = [username]; - auto-optimise-store = true; + auto-optimise-store = mkDashDefault true; - builders-use-substitutes = true; + builders-use-substitutes = mkDashDefault true; substituters = [ "https://hyprland.cachix.org" @@ -129,29 +129,30 @@ in { "chaotic-nyx.cachix.org-1:HfnXSw4pj95iI/n17rIDy40agHj12WfF+Gqk6SonIT8=" ]; - experimental-features = "nix-command flakes pipe-operators"; + experimental-features = mkDashDefault "nix-command flakes pipe-operators"; }; }; hardware = { cpu.${config.conf.cpu}.updateMicrocode = - lib.mkDefault config.hardware.enableRedistributableFirmware; + mkDashDefault + config.hardware.enableRedistributableFirmware; }; - security.rtkit.enable = true; + security.rtkit.enable = mkDashDefault true; environment.variables = { - XDG_CACHE_HOME = "$HOME/.cache"; - DIRENV_LOG_FORMAT = ""; - QT_QPA_PLATFORMTHEME = "qt5ct"; + XDG_CACHE_HOME = mkDashDefault "$HOME/.cache"; + DIRENV_LOG_FORMAT = mkDashDefault ""; + QT_QPA_PLATFORMTHEME = mkDashDefault "qt5ct"; }; # allows user change later on users = { - mutableUsers = true; + mutableUsers = mkDashDefault true; users.${username} = { - isNormalUser = true; - description = username; + isNormalUser = mkDashDefault true; + description = mkDashDefault username; extraGroups = [ "networkmanager" "wheel" @@ -167,7 +168,7 @@ in { ]; # this password will only last for the first login # e.g. login, then change to whatever else, this also ensures no public hash is available - password = "firstlogin"; + password = mkDashDefault "firstlogin"; }; }; } diff --git a/base/env.nix b/base/env.nix index c85a06e..95248dc 100644 --- a/base/env.nix +++ b/base/env.nix @@ -1,22 +1,23 @@ { + mkDashDefault, pkgs, config, ... }: { environment = { variables = { - GSETTINGS_SCHEMA_DIR = "${pkgs.glib.getSchemaPath pkgs.gsettings-desktop-schemas}"; - NEOVIDE_MAXIMIZED = "0"; - GPG_TTY = "$(tty)"; - EDITOR = "neovide --no-fork"; - SUDO_EDITOR = "neovide --no-fork"; - SCRIPTS = "$HOME/.config/scripts"; + GSETTINGS_SCHEMA_DIR = mkDashDefault "${pkgs.glib.getSchemaPath pkgs.gsettings-desktop-schemas}"; + NEOVIDE_MAXIMIZED = mkDashDefault "0"; + GPG_TTY = mkDashDefault "$(tty)"; + EDITOR = mkDashDefault "neovide --no-fork"; + SUDO_EDITOR = mkDashDefault "neovide --no-fork"; + SCRIPTS = mkDashDefault "$HOME/.config/scripts"; }; sessionVariables = { - NIXOS_OZONE_WL = "1"; - GOPATH = "$HOME/.go"; - FLAKE = config.conf.nixosConfigPath; - NH_FLAKE = config.conf.nixosConfigPath; + NIXOS_OZONE_WL = mkDashDefault "1"; + GOPATH = mkDashDefault "$HOME/.go"; + FLAKE = mkDashDefault config.conf.nixosConfigPath; + NH_FLAKE = mkDashDefault config.conf.nixosConfigPath; }; }; } diff --git a/base/xkb_layout.nix b/base/xkb_layout.nix index 0324c99..db4fa60 100644 --- a/base/xkb_layout.nix +++ b/base/xkb_layout.nix @@ -1,4 +1,8 @@ -{pkgs, ...}: let +{ + mkDashDefault, + pkgs, + ... +}: let layout = pkgs.writeText "dashie" '' xkb_symbols "dashie" { @@ -10,7 +14,7 @@ }; ''; in { - environment.systemPackages = [pkgs.xorg.xkbcomp]; + environment.systemPackages = mkDashDefault [pkgs.xorg.xkbcomp]; services.xserver.xkb.extraLayouts.dashie = { description = "US layout with 'umlaut'"; languages = ["eng"]; diff --git a/home/common.nix b/home/common.nix index 31d67b9..1a3ccf3 100644 --- a/home/common.nix +++ b/home/common.nix @@ -1,4 +1,5 @@ { + mkDashDefault, config, lib, ... @@ -6,30 +7,30 @@ username = config.conf.username; in { manual = { - html.enable = false; - json.enable = false; - manpages.enable = false; + html.enable = mkDashDefault false; + json.enable = mkDashDefault false; + manpages.enable = mkDashDefault false; }; - fonts.fontconfig.enable = true; + fonts.fontconfig.enable = mkDashDefault true; home = { - username = username; - homeDirectory = "/home/${username}"; + username = mkDashDefault username; + homeDirectory = mkDashDefault "/home/${username}"; sessionPath = ["$HOME/.cargo/bin"]; - enableNixpkgsReleaseCheck = false; + enableNixpkgsReleaseCheck = mkDashDefault false; sessionVariables = { - GOROOT = "$HOME/.go"; - QT_QPA_PLATFORMTHEME = "qt5ct"; + GOROOT = mkDashDefault "$HOME/.go"; + QT_QPA_PLATFORMTHEME = mkDashDefault "qt5ct"; }; - keyboard = null; + keyboard = mkDashDefault null; }; programs.nix-index = { - enable = true; - enableFishIntegration = true; + enable = mkDashDefault true; + enableFishIntegration = mkDashDefault true; }; nix = { diff --git a/home/default.nix b/home/default.nix index 03c25f9..c459466 100644 --- a/home/default.nix +++ b/home/default.nix @@ -1,4 +1,5 @@ { + mkDashDefault, additionalHomeConfig, additionalHomeMods, additionalInputs, @@ -16,17 +17,18 @@ ... }: { xdg = { - portal.config.common.default = "*"; + portal.config.common.default = mkDashDefault "*"; portal = { - enable = true; + enable = mkDashDefault true; extraPortals = [pkgs.xdg-desktop-portal-gtk]; }; }; home-manager = { - useGlobalPkgs = true; - useUserPackages = true; + useGlobalPkgs = mkDashDefault true; + useUserPackages = mkDashDefault true; extraSpecialArgs = { inherit inputs root additionalInputs alternativePkgs system stable unstable; + mkDashDefault = import ../lib/override.nix {inherit lib;}; }; users.${config.conf.username} = { diff --git a/lib/default.nix b/lib/default.nix index 2ad1719..9e0d75a 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -105,6 +105,7 @@ homeMods = mods.home; additionalHomeMods = additionalMods.home; additionalInputs = additionalInputs; + mkDashDefault = import ./override.nix {inherit lib;}; }; in inputs.unstable.lib.nixosSystem { diff --git a/lib/override.nix b/lib/override.nix new file mode 100644 index 0000000..4d222f8 --- /dev/null +++ b/lib/override.nix @@ -0,0 +1 @@ +{lib, ...}: value: lib.mkOverride 999 value diff --git a/modules/programs/gpu.nix b/modules/programs/gpu.nix index 339b694..9bc2a4a 100644 --- a/modules/programs/gpu.nix +++ b/modules/programs/gpu.nix @@ -1,4 +1,5 @@ { + mkDashDefault, lib, config, options, @@ -100,7 +101,7 @@ ]; in { enable = true; - enable32Bit = lib.mkDefault true; + enable32Bit = mkDashDefault true; extraPackages = amdPackages ++ (lib.lists.optionals (config.mods.gpu.vapi.rocm.enable && config.mods.gpu.amdgpu.enable) rocmPackages); -- 2.51.2 From a8579cc4f46e9e3b5a008672a23b83e47fa468e7 Mon Sep 17 00:00:00 2001 From: DashieTM Date: Fri, 9 May 2025 14:48:00 +0200 Subject: [PATCH 3/3] Add fancontrol --- flake.nix | 3 +++ lib/default.nix | 1 + modules/programs/default.nix | 1 + modules/programs/fancontrol.nix | 36 +++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 modules/programs/fancontrol.nix diff --git a/flake.nix b/flake.nix index e7e7c44..bbddc3a 100644 --- a/flake.nix +++ b/flake.nix @@ -32,6 +32,9 @@ zen-browser.url = "github:youwen5/zen-browser-flake"; + # TODO move to upstream repository after merged nix flake pr + fancontrol.url = "git+https://github.com/DashieTM/fancontrol-gui?ref=nix-flake"; + stylix.url = "github:danth/stylix"; base16.url = "github:SenchoPens/base16.nix"; disko.url = "github:nix-community/disko/latest"; diff --git a/lib/default.nix b/lib/default.nix index 9e0d75a..3ee4fc8 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -66,6 +66,7 @@ inputs.reset.homeManagerModules.default inputs.sops-nix.homeManagerModules.sops inputs.dashvim.homeManagerModules.dashvim + inputs.fancontrol.homeManagerModules.default ../modules ]; }, diff --git a/modules/programs/default.nix b/modules/programs/default.nix index f454717..17be977 100644 --- a/modules/programs/default.nix +++ b/modules/programs/default.nix @@ -7,6 +7,7 @@ ./coding.nix ./containers.nix ./drives.nix + ./fancontrol.nix ./fastfetch.nix ./fish.nix ./flatpak.nix diff --git a/modules/programs/fancontrol.nix b/modules/programs/fancontrol.nix new file mode 100644 index 0000000..87be9af --- /dev/null +++ b/modules/programs/fancontrol.nix @@ -0,0 +1,36 @@ +{ + lib, + config, + options, + ... +}: { + options.mods.fancontrol = { + enable = lib.mkOption { + default = false; + example = true; + type = lib.types.bool; + description = "Enables fancontrol-gui with needed drivers"; + }; + forceId = lib.mkOption { + default = null; + example = "force_id=0x8628"; + type = with lib.types; nullOr str; + description = "Modprobe options for the it87 driver. Information at: https://wiki.archlinux.org/title/Lm_sensors#Gigabyte_B250/Z370/B450M/B560M/B660M/Z690/B550_motherboards"; + }; + }; + config = lib.mkIf config.mods.fancontrol.enable ( + lib.optionalAttrs (options ? home.packages) { + programs.fancontrol-gui.enable = true; + } + // (lib.optionalAttrs (options ? boot.kernelModules) { + boot = { + kernelParams = ["acpi_enforce_resources=lax"]; + extraModulePackages = with config.boot.kernelPackages; [liquidtux it87]; + kernelModules = ["v4l2loopback" "it87"]; + extraModprobeConfig = lib.mkIf (config.mods.fancontrol.forceId != null) '' + options it87 ${config.mods.fancontrol.forceId} + ''; + }; + }) + ); +} -- 2.51.2