hyprland: fix Lua config errors caused by stylix's Hyprland target

Stylix's Hyprland target injects settings.{general,decoration,group,misc}
as top-level keys.  In hyprlang mode these render as section blocks, but
in Lua mode (configType = "lua") they become hl.general(), hl.decoration(),
etc. — functions that don't exist, causing an emergency-mode config error.

Disable stylix.targets.hyprland and absorb all its colours into
settings.config.{general,decoration,group,misc} where they are correctly
rendered inside the single hl.config({}) call.

Also add a home.activation script that removes any stale hyprland.conf
(auto-generated by Hyprland before hyprland.lua was first placed) so the
autogenerated-config warning banner can never persist across restarts.
Keep services.hyprpaper.enable = true since it was previously set by the
now-disabled Hyprland target.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
rope 2026-05-17 22:24:12 +01:00
parent 62a1f9a38c
commit f4b45c8bda

View file

@ -94,7 +94,21 @@ in
polkit_gnome
];
home-manager.users.fred = { config, lib, pkgs, inputs, ... }: {
home-manager.users.fred = { config, lib, pkgs, inputs, ... }:
let
c = config.lib.stylix.colors;
rgb = hex: "rgb(${hex})";
rgba = hex: a: "rgba(${hex}${a})";
in {
# Stylix's Hyprland target injects settings.{general,decoration,group,misc}
# as top-level keys, which render as hl.general()/hl.decoration()/… in Lua
# mode — functions that don't exist. Disable it and absorb the colours
# into settings.config below.
stylix.targets.hyprland.enable = false;
# Hyprpaper was previously started by stylix's Hyprland target; keep it.
services.hyprpaper.enable = true;
wayland.windowManager.hyprland = {
enable = true;
configType = "lua";
@ -111,6 +125,8 @@ in
border_size = 2;
layout = "dwindle";
resize_on_border = true;
"col.active_border" = rgb c.base0D;
"col.inactive_border" = rgb c.base03;
};
decoration = {
@ -118,6 +134,18 @@ in
blur = {
enabled = true;
};
shadow.color = rgba c.base00 "99";
};
group = {
"col.border_active" = rgb c.base0D;
"col.border_inactive" = rgb c.base03;
"col.border_locked_active" = rgb c.base0C;
groupbar = {
text_color = rgb c.base05;
"col.active" = rgb c.base0D;
"col.inactive" = rgb c.base03;
};
};
render = {
@ -157,6 +185,7 @@ in
# show as urgent in the bar instead.
focus_on_activate = false;
vrr = 2;
background_color = rgb c.base00;
};
# vfr moved from misc: to debug: in 0.55.0
@ -560,6 +589,14 @@ in
#battery.critical { color: @base08; }
'';
};
# The old hyprlang hyprland.conf (with `# autogenerated = 1`) is not
# managed by HM after switching to configType = "lua", so Hyprland still
# finds it and shows the "autogenerated config" banner. Remove it once on
# every activation so it can never linger.
home.activation.removeOldHyprlandConf = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
rm -f "${config.xdg.configHome}/hypr/hyprland.conf"
'';
};
};
}