refactor(modules): make sure nothing is added without setting enable

This commit is contained in:
matt1432 2025-01-04 19:02:30 -05:00
parent 4a2ad39114
commit 49dc072b81
56 changed files with 684 additions and 506 deletions
modules/desktop/manager/hyprland

View file

@ -0,0 +1,77 @@
self: {
config,
lib,
pkgs,
...
}: let
inherit (self.lib.hypr) mkAnimation;
inherit (lib) mkIf optionals;
inherit (import ./setupMonitors.nix {inherit config pkgs;}) setupMonitors;
cfg = config.roles.desktop;
cfgHypr =
config
.home-manager
.users
.${cfg.user}
.wayland
.windowManager
.hyprland;
in {
config = mkIf cfg.enable {
home-manager.users.greeter = {
imports = [
(import ../../theme self)
];
wayland.windowManager.hyprland = {
enable = true;
systemd.enable = false;
package = cfgHypr.finalPackage;
settings = {
inherit (cfgHypr.settings) cursor device input misc monitor;
envd = optionals (config.nvidia.enable) [
"LIBVA_DRIVER_NAME, nvidia"
"NVD_BACKEND, direct"
"XDG_SESSION_TYPE, wayland"
"GBM_BACKEND, nvidia-drm"
"__GLX_VENDOR_LIBRARY_NAME, nvidia"
];
general.border_size = 0;
decoration = {
blur.enabled = false;
shadow.enabled = false;
};
animation = map mkAnimation [
{
name = "fadeLayersIn";
enable = false;
}
{
name = "layers";
duration = 4;
style = "popin";
}
];
exec-once = [
setupMonitors
"agsGreeter &> /tmp/ags-greetd.log; hyprctl dispatch exit"
];
};
};
};
};
# For accurate stack trace
_file = ./default.nix;
}

View file

@ -0,0 +1,53 @@
{
config,
pkgs,
...
}: let
inherit (pkgs.lib) getExe;
cfg = config.roles.desktop;
hyprland =
config
.home-manager
.users
.${cfg.user}
.wayland
.windowManager
.hyprland
.finalPackage;
# Show Regreet on all monitors
dupeMonitors = pkgs.writeShellApplication {
name = "dupeMonitors";
runtimeInputs = [hyprland pkgs.jq];
text = ''
main="${cfg.mainMonitor}"
names="($(hyprctl -j monitors | jq -r '.[] .description'))"
if [[ "$main" == "null" ]]; then
main="''${names[0]}"
fi
for (( i=0; i<''${#names[@]}; i++ )); do
# shellcheck disable=SC2001
name=$(echo "''${names[$i]}" | sed 's/.*(\(.*\))/\1/')
# shellcheck disable=SC2001
desc=$(echo "''${names[$i]}" | sed 's/ (.*//')
if [[ "$name" != "$main" && "desc:$desc" != "$main" ]]; then
hyprctl keyword monitor "$name",preferred,auto,1,mirror,"$main"
fi
done
hyprctl dispatch focusmonitor "$main"
'';
};
# Check if user wants the greeter only on main monitor
in {
setupMonitors =
if (cfg.mainMonitor != "null" && !cfg.displayManager.duplicateScreen)
then "hyprctl dispatch focusmonitor ${cfg.mainMonitor}"
else getExe dupeMonitors;
}