refactor(dm): use home-manager for greeter hyprland config
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-07-10 16:56:19 -04:00
parent f793e546f6
commit 13abafb1b2
3 changed files with 42 additions and 82 deletions

View file

@ -1,11 +1,4 @@
{ {config, ...}: let
config,
lib,
pkgs,
...
}: let
inherit (import ./hyprland.nix {inherit config lib pkgs;}) hyprConf;
cfg = config.roles.desktop; cfg = config.roles.desktop;
hyprland = hyprland =
@ -20,6 +13,7 @@
in { in {
imports = [ imports = [
./astal.nix ./astal.nix
./hyprland.nix
]; ];
services = { services = {
@ -29,7 +23,7 @@ in {
enable = true; enable = true;
settings = { settings = {
default_session = { default_session = {
command = "Hyprland --config ${hyprConf}"; command = "Hyprland";
user = "greeter"; user = "greeter";
}; };

View file

@ -4,17 +4,7 @@
pkgs, pkgs,
... ...
}: let }: let
inherit inherit (lib) filterAttrs hasPrefix optionals;
(lib)
boolToString
concatStringsSep
filterAttrs
hasPrefix
isAttrs
isBool
mapAttrsToList
optionalString
;
inherit (import ./setupMonitors.nix {inherit config pkgs;}) setupMonitors; inherit (import ./setupMonitors.nix {inherit config pkgs;}) setupMonitors;
@ -31,72 +21,44 @@
.hyprland; .hyprland;
devices = filterAttrs (n: v: hasPrefix "device:" n) cfgHypr.settings; devices = filterAttrs (n: v: hasPrefix "device:" n) cfgHypr.settings;
monitors = cfgHypr.settings.monitor;
inputs = cfgHypr.settings.input;
misc = cfgHypr.settings.misc;
mkHyprBlock = attrs:
concatStringsSep "\n" (mapAttrsToList (
n: v:
if (isAttrs v)
then ''
${n} {
${mkHyprBlock v}
}
''
else if (isBool v)
then " ${n}=${boolToString v}"
else " ${n}=${toString v}"
)
attrs);
in { in {
hyprConf = pkgs.writeText "greetd-hypr-config" ( home-manager.users.greeter = {
(optionalString config.nvidia.enable wayland.windowManager.hyprland = {
# hyprlang enable = true;
'' package = cfgHypr.finalPackage;
env = LIBVA_DRIVER_NAME,nvidia systemd.enable = false;
env = XDG_SESSION_TYPE,wayland
env = GBM_BACKEND,nvidia-drm
env = __GLX_VENDOR_LIBRARY_NAME,nvidia
env = WLR_NO_HARDWARE_CURSORS,1
'')
+ (concatStringsSep "\n" (map (x: "monitor=${x}") monitors))
+ "\n"
+
# hyprlang
''
misc {
${mkHyprBlock misc}
}
# Devices settings =
${mkHyprBlock devices} {
inherit (cfgHypr.settings) cursor input misc monitor;
input { envd =
${mkHyprBlock inputs} (optionals (config.nvidia.enable) [
} "LIBVA_DRIVER_NAME, nvidia"
"NVD_BACKEND, direct"
"XDG_SESSION_TYPE, wayland"
"GBM_BACKEND, nvidia-drm"
"__GLX_VENDOR_LIBRARY_NAME, nvidia"
])
++ [
"XCURSOR_SIZE,24"
];
'' general.border_size = 0;
+
# hyprlang
''
#
env = XCURSOR_SIZE,24
exec-once = hyprctl setcursor Dracula-cursors 24
general { decoration = {
border_size = 0 blur.enabled = false;
} drop_shadow = false;
};
decoration { exec-once = [
blur { "hyprctl setcursor Dracula-cursors 24"
enabled = false
}
drop_shadow = false
}
exec-once = ${setupMonitors} setupMonitors
exec-once = astal -b greeter &> /tmp/astal.log; hyprctl dispatch exit "astal -b greeter &> /tmp/astal.log; hyprctl dispatch exit"
'' ];
); }
// devices;
};
};
} }

View file

@ -3,6 +3,8 @@
pkgs, pkgs,
... ...
}: let }: let
inherit (pkgs.lib) getExe;
cfg = config.roles.desktop; cfg = config.roles.desktop;
hyprland = hyprland =
@ -38,6 +40,8 @@
hyprctl keyword monitor "$name",preferred,auto,1,mirror,"$main" hyprctl keyword monitor "$name",preferred,auto,1,mirror,"$main"
fi fi
done done
hyprctl dispatch focusmonitor "$main"
''; '';
}; };
# Check if user wants the greeter only on main monitor # Check if user wants the greeter only on main monitor
@ -45,5 +49,5 @@ in {
setupMonitors = setupMonitors =
if (cfg.mainMonitor != "null" && !cfg.displayManager.duplicateScreen) if (cfg.mainMonitor != "null" && !cfg.displayManager.duplicateScreen)
then "hyprctl dispatch focusmonitor ${cfg.mainMonitor}" then "hyprctl dispatch focusmonitor ${cfg.mainMonitor}"
else "${dupeMonitors}/bin/dupeMonitors"; else getExe dupeMonitors;
} }