feat(desktop): viewers (zathura+imv) + xdg-mime defaults (item 8)
All checks were successful
Check / eval (push) Successful in 2m52s

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>
This commit is contained in:
Bernardo Magri
2026-07-04 20:06:45 +01:00
parent e05e3647e6
commit 774bdad6e4
10 changed files with 105 additions and 18 deletions

View File

@@ -23,6 +23,8 @@
./shell.nix # zsh + starship + bat/eza/zoxide, themed
./keys.nix # gpg-agent (fronts SSH) + pinentry-qt
./fastfetch.nix # system info with the themed Nomarchy logo
./viewers.nix # zathura (Stylix-themed) + imv — PDF/image viewing
./mime.nix # default applications (mimeapps.list), degrades with the suite
];
# Clipboard history (wl-paste watcher); browsed via the SUPER+CTRL+V

48
modules/home/mime.nix Normal file
View File

@@ -0,0 +1,48 @@
# Default applications (xdg mimeapps.list) — without this, "open a
# PDF/photo" falls to whatever GTK guesses first (GIMP for images).
# Every association is mkDefault AND degrades gracefully by design: an
# entry whose .desktop file isn't installed is skipped by GIO/xdg-open,
# which then falls through to whatever else claims the type — so
# deleting an app from the template suite (or never uncommenting the
# browser) leaves no broken "open" behaviour, just the old guessing.
{ config, lib, ... }:
lib.mkIf config.nomarchy.mime.enable {
xdg.mimeApps = {
enable = lib.mkDefault true;
defaultApplications = lib.mapAttrs (_: v: lib.mkDefault v) {
"application/pdf" = "org.pwmt.zathura.desktop";
"image/png" = "imv.desktop";
"image/jpeg" = "imv.desktop";
"image/gif" = "imv.desktop";
"image/webp" = "imv.desktop";
"image/avif" = "imv.desktop";
"image/bmp" = "imv.desktop";
"image/tiff" = "imv.desktop";
"image/svg+xml" = "imv.desktop";
"video/mp4" = "mpv.desktop";
"video/webm" = "mpv.desktop";
"video/x-matroska" = "mpv.desktop";
"video/quicktime" = "mpv.desktop";
"audio/mpeg" = "mpv.desktop";
"audio/flac" = "mpv.desktop";
"audio/ogg" = "mpv.desktop";
# The template's active editor; degrades if you drop vscode.
"text/plain" = "code.desktop";
# The system-side Thunar (nomarchy.system.fileManager).
"inode/directory" = "thunar.desktop";
# The template ships no browser by default (open Decision) — these
# are inert until one is installed; firefox is the template's first
# suggestion. A different browser registers its own handler and
# wins once these entries stay dead.
"text/html" = "firefox.desktop";
"x-scheme-handler/http" = "firefox.desktop";
"x-scheme-handler/https" = "firefox.desktop";
};
};
}

View File

@@ -252,6 +252,8 @@ in
btop.enable = lib.mkEnableOption "btop with the per-theme nomarchy theme" // { default = true; };
stylix.enable = lib.mkEnableOption "Stylix theming for the long tail of apps (GTK, Qt, cursors)" // { default = true; };
displays.enable = lib.mkEnableOption "the nwg-displays interactive monitor arranger (a helper to find nomarchy.monitors values; the declarative config stays the source of truth)" // { default = true; };
viewers.enable = lib.mkEnableOption "the document/image viewers (zathura, Stylix-themed, + imv)" // { default = true; };
mime.enable = lib.mkEnableOption "default file associations (xdg mimeapps.list: PDF/image/video/text/browser/directory); entries for absent apps are skipped, so it degrades with the package suite" // { default = true; };
# ── Computed (read-only) ───────────────────────────────────────
theme = lib.mkOption {

View File

@@ -47,6 +47,8 @@ in
targets = {
gtk.enable = true;
qt.enable = true;
# No-op unless programs.zathura is on (viewers.nix enables it).
zathura.enable = true;
};
cursor = {

15
modules/home/viewers.nix Normal file
View File

@@ -0,0 +1,15 @@
# Document & image viewers — the "open a PDF / open a photo" half of a
# complete workstation. zathura goes through its HM module (not a bare
# package) because Stylix themes it via programs.zathura.options — the
# reason it's a component toggle here rather than a template package
# line. imv rides along: wayland-native, and an image viewer is a
# borderless dark surface — nothing to theme. The heavier editors
# (GIMP, Inkscape) stay template packages; mime.nix points the default
# associations at these viewers.
{ config, lib, pkgs, ... }:
lib.mkIf config.nomarchy.viewers.enable {
programs.zathura.enable = lib.mkDefault true;
home.packages = [ pkgs.imv ];
}