From f622009e8722f7f8df093df676711f3261cadd17 Mon Sep 17 00:00:00 2001 From: Jurn Wubben Date: Wed, 9 Jul 2025 19:48:10 +0200 Subject: [PATCH] Option: added active desktop option which allows kde to be primary desktop environment. --- home/services/udiskie.nix | 4 ++-- home/shell/default.nix | 1 - home/wayland/default.nix | 2 +- home/wayland/fuzzel.nix | 2 +- home/wayland/hyprland/default.nix | 2 +- home/wayland/hyprlock.nix | 2 +- home/wayland/mako.nix | 6 +++-- system/desktop/default.nix | 12 ++++++++++ system/desktop/greetd.nix | 16 ++----------- system/desktop/hyprland.nix | 33 ++++++++++++++++++++++----- system/desktop/plasma6.nix | 37 +++++++++++++++++-------------- system/desktop/polkit.nix | 6 ++--- system/desktop/xdg.nix | 6 ++--- system/hardware/fingerprint.nix | 7 +++--- system/hardware/graphics.nix | 2 +- system/hardware/joycond.nix | 2 +- system/hardware/power.nix | 2 +- 17 files changed, 82 insertions(+), 60 deletions(-) diff --git a/home/services/udiskie.nix b/home/services/udiskie.nix index 04c0522..21ee6fc 100644 --- a/home/services/udiskie.nix +++ b/home/services/udiskie.nix @@ -1,6 +1,6 @@ -{ +{osConfig, ...}: { services.udiskie = { - enable = true; + inherit (osConfig.services.udisks2) enable; tray = "never"; #NOTE: Don't have a bar (yet?) }; } diff --git a/home/shell/default.nix b/home/shell/default.nix index 4c4c4f6..20baf04 100644 --- a/home/shell/default.nix +++ b/home/shell/default.nix @@ -6,7 +6,6 @@ ./other.nix ./repl ./starship.nix - ./transfer.nix ./yazi.nix ./zoxide.nix ]; diff --git a/home/wayland/default.nix b/home/wayland/default.nix index f6d8900..e74aded 100644 --- a/home/wayland/default.nix +++ b/home/wayland/default.nix @@ -5,7 +5,7 @@ ... }: let inherit (lib) mkIf; - cfg = osConfig.niksos.desktop.hyprland; + cfg = osConfig.programs.hyprland.enable; in { imports = [ ./fuzzel.nix diff --git a/home/wayland/fuzzel.nix b/home/wayland/fuzzel.nix index 0b8649c..33eb17c 100644 --- a/home/wayland/fuzzel.nix +++ b/home/wayland/fuzzel.nix @@ -5,7 +5,7 @@ ... }: { programs.fuzzel = { - enable = osConfig.niksos.desktop.hyprland; + inherit (osConfig.programs.hyprland) enable; settings.main = { launch-prefix = "${lib.getExe pkgs.uwsm} app --"; }; diff --git a/home/wayland/hyprland/default.nix b/home/wayland/hyprland/default.nix index dfb5a44..2481fad 100644 --- a/home/wayland/hyprland/default.nix +++ b/home/wayland/hyprland/default.nix @@ -15,7 +15,7 @@ in { ]; wayland.windowManager.hyprland = { - enable = osConfig.niksos.desktop.hyprland; + inherit (osConfig.programs.hyprland) enable; settings = { env = [ "QT_WAYLAND_DISABLE_WINDOWDECORATION,1" diff --git a/home/wayland/hyprlock.nix b/home/wayland/hyprlock.nix index 411ca37..0ffacaf 100644 --- a/home/wayland/hyprlock.nix +++ b/home/wayland/hyprlock.nix @@ -6,7 +6,7 @@ inherit (config.lib.stylix.colors) base05; in { programs.hyprlock = { - enable = osConfig.niksos.desktop.hyprland; + inherit (osConfig.programs.hyprland) enable; settings = { general = { diff --git a/home/wayland/mako.nix b/home/wayland/mako.nix index 57343b9..7ccbfd9 100644 --- a/home/wayland/mako.nix +++ b/home/wayland/mako.nix @@ -1,6 +1,8 @@ -{osConfig, ...}: { +{osConfig, ...}: let + inherit (osConfig.niksos) desktop; +in { services.mako = { - enable = osConfig.niksos.desktop.hyprland; + inherit (osConfig.programs.hyprland) enable; settings.defaultTimeout = 5000; }; } diff --git a/system/desktop/default.nix b/system/desktop/default.nix index 2fe689e..d8d9a7f 100644 --- a/system/desktop/default.nix +++ b/system/desktop/default.nix @@ -21,8 +21,20 @@ in { enable = mkEO "enable desktop related programs (+home manager)."; apps = mkEO "extra bloat."; games = mkEO "gaming related programs"; + hyprland = mkEO "enable hyprland related programs."; kde = mkEO "enable kde specialisation."; + activeDesktop = lib.mkOption { + type = lib.types.enum ["hyprland" "kde"]; + description = "What desktop should be the default, other enabled desktops will be specialized."; + default = + if cfg.hyprland + then "hyprland" + else if cfg.kde + then "kde" + else "hyprland"; + example = "hyprland"; + }; }; config.assertions = mkIf (cfg.hyprland diff --git a/system/desktop/greetd.nix b/system/desktop/greetd.nix index 5cb4982..943ce8a 100644 --- a/system/desktop/greetd.nix +++ b/system/desktop/greetd.nix @@ -5,21 +5,9 @@ }: { config = lib.mkIf config.niksos.desktop.enable { # greetd display manager - services.greetd = let - session = { - command = lib.mkDefault "${lib.getExe config.programs.uwsm.package} start hyprland-uwsm.desktop"; - user = "jsw"; - }; - in { + services.greetd = { enable = true; - - settings = { - terminal.vt = 1; - default_session = session; - initial_session = session; - }; + settings.terminal.vt = 1; }; - - programs.uwsm.enable = config.niksos.desktop.hyprland; }; } diff --git a/system/desktop/hyprland.nix b/system/desktop/hyprland.nix index 4ea2a18..12b0c29 100644 --- a/system/desktop/hyprland.nix +++ b/system/desktop/hyprland.nix @@ -1,16 +1,37 @@ { - config, - pkgs, lib, + pkgs, + config, ... }: let - cfg = config.niksos.desktop.enable && config.niksos.desktop.hyprland; + inherit (config.niksos) desktop; + cfg = desktop.enable && desktop.hyprland; + active = cfg && desktop.activeDesktop == "hyprland"; + ifActive = x: lib.mkIf active x; in { - config = lib.mkIf cfg { - programs.hyprland = { + specialisation.hyprland.configuration = + lib.mkIf cfg + && !active { + niksos.desktop.activeDesktop = lib.mkForce "hyprland"; + }; + + programs = ifActive { + hyprland = { enable = true; withUWSM = true; }; - environment.sessionVariables.NIXOS_OZONE_WL = "1"; # Makes electron apps use wayland. + uwsm.enable = true; }; + + services.greetd.settings = let + session = { + command = "${lib.getExe config.programs.uwsm.package} start hyprland-uwsm.desktop"; + user = "jsw"; + }; + in + ifActive { + default_session = session; + initial_session = session; + }; + environment.sessionVariables.NIXOS_OZONE_WL = ifActive "1"; # Makes electron apps use wayland. } diff --git a/system/desktop/plasma6.nix b/system/desktop/plasma6.nix index cca4cce..c524bbb 100644 --- a/system/desktop/plasma6.nix +++ b/system/desktop/plasma6.nix @@ -4,25 +4,28 @@ config, ... }: let - cfg = config.niksos.desktop.enable && config.niksos.desktop.kde; + inherit (config.niksos) desktop; + cfg = desktop.enable && desktop.kde; + active = cfg && desktop.activeDesktop == "kde"; + ifActive = x: lib.mkIf active x; in { - specialisation.de.configuration = lib.mkIf cfg { - niksos.desktop.hyprland = lib.mkForce false; - services = { - greetd = let - session.command = "${pkgs.kdePackages.plasma-workspace}/bin/startplasma-wayland"; - in { - enable = true; - settings = { - terminal.vt = 1; - default_session = session; - initial_session = session; - }; - }; - - desktopManager.plasma6.enable = true; + specialisation.kde.configuration = + lib.mkIf cfg + && !active { + niksos.desktop.activeDesktop = lib.mkForce "kde"; }; - home-manager.users.jsw.stylix.autoEnable = false; + services = ifActive { + greetd.settings = let + session.command = "${pkgs.kdePackages.plasma-workspace}/bin/startplasma-wayland"; + in { + default_session = session; + initial_session = session; + }; + + desktopManager.plasma6.enable = true; + }; + home-manager.users = ifActive { + jsw.stylix.autoEnable = false; }; } diff --git a/system/desktop/polkit.nix b/system/desktop/polkit.nix index eedb594..83e4f34 100644 --- a/system/desktop/polkit.nix +++ b/system/desktop/polkit.nix @@ -3,10 +3,8 @@ lib, pkgs, ... -}: let - cfg = config.niksos.desktop.enable && config.niksos.desktop.hyprland; -in { - systemd.user.services.polkit-gnome-authentication-agent-1 = lib.mkIf cfg { +}: { + systemd.user.services.polkit-gnome-authentication-agent-1 = lib.mkIf config.programs.hyprland.enable { description = "polkit-gnome-authentication-agent-1"; wantedBy = ["graphical-session.target"]; wants = ["graphical-session.target"]; diff --git a/system/desktop/xdg.nix b/system/desktop/xdg.nix index 75f243e..077224d 100644 --- a/system/desktop/xdg.nix +++ b/system/desktop/xdg.nix @@ -3,10 +3,8 @@ config, lib, ... -}: let - cfg = config.niksos.desktop.enable && config.niksos.desktop.hyprland; -in { - xdg.portal = lib.mkIf cfg { +}: { + xdg.portal = lib.mkIf config.programs.hyprland.enable { enable = true; xdgOpenUsePortal = true; config = { diff --git a/system/hardware/fingerprint.nix b/system/hardware/fingerprint.nix index f84f6f7..a506268 100644 --- a/system/hardware/fingerprint.nix +++ b/system/hardware/fingerprint.nix @@ -5,20 +5,21 @@ ... }: let inherit (config.niksos) hardware desktop; - inherit (lib) mkIf mkEnableOption; + inherit (lib) mkIf; uwsm = lib.getExe pkgs.uwsm; foot = lib.getExe pkgs.foot; + hypr = config.programs.hyprland.enable; in { config = mkIf hardware.fingerprint { services = { fprintd.enable = true; - logind.extraConfig = mkIf desktop.hyprland '' + logind.extraConfig = mkIf hypr '' # don’t shutdown when power button is short-pressed HandlePowerKey=ignore ''; }; - home-manager.users.jsw.wayland.windowManager.hyprland.settings = mkIf desktop.hyprland { + home-manager.users.jsw.wayland.windowManager.hyprland.settings = mkIf hypr { bind = [ ", XF86PowerOff, exec, ${uwsm} app -- pgrep fprintd-verify && exit 0 || ${foot} -a 'foot-fprintd' sh -c 'fprintd-verify && systemctl sleep'" ]; diff --git a/system/hardware/graphics.nix b/system/hardware/graphics.nix index 3134ff9..af4fc1d 100644 --- a/system/hardware/graphics.nix +++ b/system/hardware/graphics.nix @@ -4,7 +4,7 @@ lib, ... }: let - inherit (lib) optionals mkEnableOption mkDefault; + inherit (lib) optionals mkDefault; inherit (config.niksos.hardware) graphics; inherit (graphics) enable nvidia intel; diff --git a/system/hardware/joycond.nix b/system/hardware/joycond.nix index 919487b..a228daf 100644 --- a/system/hardware/joycond.nix +++ b/system/hardware/joycond.nix @@ -3,7 +3,7 @@ lib, ... }: { - config.services = lib.mkIf config.niksos.hardware.joycond { + services = lib.mkIf config.niksos.hardware.joycond { usbmuxd.enable = true; joycond.enable = true; }; diff --git a/system/hardware/power.nix b/system/hardware/power.nix index b5522a6..114c9dc 100644 --- a/system/hardware/power.nix +++ b/system/hardware/power.nix @@ -17,7 +17,7 @@ in { power-profiles-daemon.enable = true; }; - environment.systemPackages = lib.mkIf niksos.desktop.hyprland [ + environment.systemPackages = lib.mkIf config.programs.hyprland.enable [ (pkgs.writeScriptBin "powermode" '' #!/usr/bin/env bash