Files
Nomarchy/modules/home/stylix.nix
Bernardo Magri 774bdad6e4
All checks were successful
Check / eval (push) Successful in 2m52s
feat(desktop): viewers (zathura+imv) + xdg-mime defaults (item 8)
The complete-workstation gap: no PDF/image viewer shipped and nothing
set mime defaults, so 'open a photo' fell to GIMP. Two new default-on
toggles: nomarchy.viewers (programs.zathura — Stylix themes it, target
added to the explicit list — plus imv) and nomarchy.mime (mkDefault
xdg.mimeApps: pdf→zathura, image→imv, av→mpv, text→code, dir→thunar;
html/http(s)→firefox as inert entries that only activate when a
browser is installed — the ship-a-browser Decision stays open, now
smaller). Associations for absent apps are skipped by GIO, so the
whole thing degrades as the user curates the suite. Deviation from
the backlog text: viewers are a module toggle, not template package
lines — zathura's theming needs its HM module (the real-config
boundary of the toggle discipline).

V1: template-home generation asserted — mimeapps.list rendered, themed
zathurarc, binaries in home-path. V3 open-a-file smoke queued.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-04 20:06:45 +01:00

102 lines
3.5 KiB
Nix

# Stylix — themes the long tail of applications (GTK, Qt, cursors,
# fonts) from the same theme-state.json that drives the live engine.
#
# Division of labour: the hot-reload trio (Hyprland, Waybar, Ghostty)
# is owned by the Nomarchy engine and updates instantly; everything
# Stylix touches updates on the next home-manager switch. That is why
# autoEnable is off and the trio's Stylix targets stay disabled.
#
# Note: the stylix home module itself is imported by homeModules.nomarchy
# in flake.nix (it needs the stylix flake input).
{ config, lib, pkgs, ... }:
let
cfg = config.nomarchy;
t = cfg.theme;
c = t.colors;
hex = lib.removePrefix "#";
# Map the Nomarchy palette onto base16 roles.
base16 = {
base00 = hex c.base; # default background
base01 = hex c.mantle; # darker background (status bars)
base02 = hex c.surface; # selection background
base03 = hex c.muted; # comments
base04 = hex c.subtext; # dark foreground
base05 = hex c.text; # default foreground
base06 = hex c.text; # light foreground
base07 = hex c.text; # lightest foreground
base08 = hex c.bad; # red
base09 = hex c.warn; # orange
base0A = hex c.warn; # yellow
base0B = hex c.good; # green
base0C = hex (builtins.elemAt t.ansi 6); # cyan
base0D = hex c.accent; # blue
base0E = hex c.accentAlt;# magenta
base0F = hex c.bad; # brown/deprecated
};
in
{
config = lib.mkIf cfg.stylix.enable {
stylix = {
enable = true;
autoEnable = false; # explicit targets only — the engine owns the rest
polarity = if t.mode == "light" then "light" else "dark";
base16Scheme = base16;
targets = {
gtk.enable = true;
qt.enable = true;
# No-op unless programs.zathura is on (viewers.nix enables it).
zathura.enable = true;
};
cursor = {
name = lib.mkDefault "Bibata-Modern-Classic";
package = lib.mkDefault pkgs.bibata-cursors;
size = lib.mkDefault 24;
};
# GTK/file-manager/rofi icon theme, resolved from the JSON in
# theme.nix (per-theme `icons`, else Papirus-Dark/Light by mode).
# Stylix sets gtk.iconTheme from this; both dark/light point at the
# already-mode-resolved name.
icons = {
enable = true;
package = lib.mkDefault pkgs.papirus-icon-theme;
dark = t.iconTheme;
light = t.iconTheme;
};
fonts = {
monospace = {
name = t.fonts.mono;
package = lib.mkDefault pkgs.nerd-fonts.jetbrains-mono;
};
sansSerif = {
name = t.fonts.ui;
package = lib.mkDefault pkgs.inter;
};
serif = {
name = t.fonts.ui;
package = lib.mkDefault pkgs.inter;
};
emoji = {
name = "Noto Color Emoji";
package = lib.mkDefault pkgs.noto-fonts-color-emoji;
};
sizes.terminal = t.fonts.size;
};
};
# GTK4/libadwaita and Qt6 apps decide dark vs light from the XDG
# portal's color-scheme (org.freedesktop.appearance), which
# xdg-desktop-portal-gtk sources from this gsettings key. Stylix sets
# the GTK theme and `polarity` but not this, so a light theme still
# rendered libadwaita/Qt apps dark (and vice-versa). Drive it from the
# palette mode. (programs.dconf.enable is already on system-side.)
dconf.settings."org/gnome/desktop/interface".color-scheme =
if t.mode == "light" then "prefer-light" else "prefer-dark";
};
}