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 settings =
env = __GLX_VENDOR_LIBRARY_NAME,nvidia {
env = WLR_NO_HARDWARE_CURSORS,1 inherit (cfgHypr.settings) cursor input misc monitor;
'')
+ (concatStringsSep "\n" (map (x: "monitor=${x}") monitors)) envd =
+ "\n" (optionals (config.nvidia.enable) [
+ "LIBVA_DRIVER_NAME, nvidia"
# hyprlang "NVD_BACKEND, direct"
'' "XDG_SESSION_TYPE, wayland"
misc { "GBM_BACKEND, nvidia-drm"
${mkHyprBlock misc} "__GLX_VENDOR_LIBRARY_NAME, nvidia"
])
++ [
"XCURSOR_SIZE,24"
];
general.border_size = 0;
decoration = {
blur.enabled = false;
drop_shadow = false;
};
exec-once = [
"hyprctl setcursor Dracula-cursors 24"
setupMonitors
"astal -b greeter &> /tmp/astal.log; hyprctl dispatch exit"
];
} }
// devices;
# Devices };
${mkHyprBlock devices} };
input {
${mkHyprBlock inputs}
}
''
+
# hyprlang
''
#
env = XCURSOR_SIZE,24
exec-once = hyprctl setcursor Dracula-cursors 24
general {
border_size = 0
}
decoration {
blur {
enabled = false
}
drop_shadow = false
}
exec-once = ${setupMonitors}
exec-once = astal -b greeter &> /tmp/astal.log; hyprctl dispatch exit
''
);
} }

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;
} }