From 7d2190a8f0e28e5e9f7992131029947fbd7ef471 Mon Sep 17 00:00:00 2001 From: Myned Date: Tue, 24 Dec 2024 09:26:54 -0500 Subject: [PATCH] desktops: add main desktop option for use with module conditions Signed-off-by: Myned --- options/custom/desktops/default.nix | 23 ++++++++++++++++------- options/custom/services/hypridle.nix | 8 +++++++- profiles/console/default.nix | 6 +++--- profiles/laptop/default.nix | 2 +- 4 files changed, 27 insertions(+), 12 deletions(-) diff --git a/options/custom/desktops/default.nix b/options/custom/desktops/default.nix index fa34f7f..c929931 100644 --- a/options/custom/desktops/default.nix +++ b/options/custom/desktops/default.nix @@ -3,12 +3,21 @@ lib, ... }: -with lib; { - config.custom.desktops = mkIf config.custom.full { - #// gnome.enable = true; - #// hyprland.enable = true; - #// kde.enable = true; - niri.enable = true; - #// sway.enable = true; +with lib; let + cfg = config.custom.desktops; +in { + options.custom.desktops = { + enable = mkOption {default = config.custom.minimal;}; + desktop = mkOption {default = "niri";}; + }; + + config = mkIf cfg.enable { + custom.desktops = { + gnome.enable = cfg.desktop == "gnome"; + hyprland.enable = cfg.desktop == "hyprland"; + kde.enable = cfg.desktop == "kde"; + niri.enable = cfg.desktop == "niri"; + sway.enable = cfg.desktop == "sway"; + }; }; } diff --git a/options/custom/services/hypridle.nix b/options/custom/services/hypridle.nix index ddd100e..2b288d0 100644 --- a/options/custom/services/hypridle.nix +++ b/options/custom/services/hypridle.nix @@ -9,6 +9,7 @@ with lib; let hyprctl = "${config.programs.hyprland.package}/bin/hyprctl"; hyprlock = "${config.home-manager.users.${config.custom.username}.programs.hyprlock.package}/bin/hyprlock"; loginctl = "${pkgs.systemd}/bin/loginctl"; + niri = "${config.programs.niri.package}/bin/niri"; pgrep = "${pkgs.procps}/bin/pgrep"; pw-cli = "${pkgs.pipewire}/bin/pw-cli"; systemctl = "${pkgs.systemd}/bin/systemctl"; @@ -37,7 +38,12 @@ in { { timeout = 20 * 60; # Seconds - on-timeout = "${hyprctl} dispatch dpms off"; + on-timeout = + if config.custom.desktops.desktop == "hyprland" + then "${hyprctl} dispatch dpms off" + else if config.custom.desktops.desktop == "niri" + then "${niri} msg action power-off-monitors" + else ""; } { diff --git a/profiles/console/default.nix b/profiles/console/default.nix index b1ab081..94aefce 100644 --- a/profiles/console/default.nix +++ b/profiles/console/default.nix @@ -12,9 +12,9 @@ minimal = true; profile = "console"; - desktops.gnome = { - enable = true; - gdm = false; + desktops = { + desktop = "gnome"; + gnome.gdm = false; }; programs = { diff --git a/profiles/laptop/default.nix b/profiles/laptop/default.nix index d66479b..be0031b 100644 --- a/profiles/laptop/default.nix +++ b/profiles/laptop/default.nix @@ -1,7 +1,7 @@ { custom = { full = true; - profile = "desktop"; # Inherit desktop + profile = "desktop"; # Inherit desktop profile }; #!! Rebuild offline - drastically increases initial download and resulting closure size