Skip to content

fix(nix): provide .desktop entry and icon for librefang-desktop (#3156)#3165

Merged
houko merged 2 commits into
mainfrom
fix/nix-flake-desktop-3156
Apr 25, 2026
Merged

fix(nix): provide .desktop entry and icon for librefang-desktop (#3156)#3165
houko merged 2 commits into
mainfrom
fix/nix-flake-desktop-3156

Conversation

@houko

@houko houko commented Apr 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Refactors the librefang-desktop Nix derivation to follow the standard nixpkgs pattern for shipping a Linux desktop application, addressing the underlying cause of #3156.

The previous fix (#3157) wrote the .desktop file via an inline heredoc and only installed a single 128x128 icon. This PR moves to the makeDesktopItem + copyDesktopItems helpers and installs every icon size already shipped in crates/librefang-desktop/icons/, so launchers under GNOME / KDE / sway / etc. can pick the closest match without rescaling.

Changes

flake.nix (only the librefang-desktop package — CLI, devShell, checks untouched, no new flake inputs, flake.lock not modified):

  • Define librefangDesktopItem via pkgs.makeDesktopItem (proper XDG escaping, no manual heredoc).
  • Add copyDesktopItems to nativeBuildInputs (Linux only — no-op on darwin).
  • Install icons at 32x32, 128x128, 256x256 (from [email protected]) and 512x512 (from icon.png) under $out/share/icons/hicolor/<size>/apps/librefang-desktop.png.
  • Drop the manual update-desktop-database call — that cache is maintained by the user environment, not the package output.
  • Replace the non-standard AI value in Categories (which desktop-file-validate flags) with the standard Development;Utility; pair. Keywords still expose AI;Agent;LLM;Automation; for search.
  • Keep Icon=librefang-desktop and StartupWMClass=librefang-desktop so launchers correlate the menu entry with the running Tauri window.

Verification (ssh to a NixOS machine required)

The CI sandbox in this environment cannot run nix build, so the changes were not built locally. A reviewer with access to a Linux NixOS machine should run:

nix build .#librefang-desktop

# 1. Desktop entry exists and validates cleanly
ls -la result/share/applications/
test -f result/share/applications/librefang-desktop.desktop
desktop-file-validate result/share/applications/librefang-desktop.desktop  # expect 0 errors

# 2. Icon tree populated at every advertised size
ls -la result/share/icons/hicolor/
test -f result/share/icons/hicolor/32x32/apps/librefang-desktop.png
test -f result/share/icons/hicolor/128x128/apps/librefang-desktop.png
test -f result/share/icons/hicolor/256x256/apps/librefang-desktop.png
test -f result/share/icons/hicolor/512x512/apps/librefang-desktop.png

# 3. End-to-end smoke test: install into the user profile, restart the
#    desktop session (or run `update-desktop-database ~/.local/share/applications`
#    + `gtk-update-icon-cache`), then verify "LibreFang" shows up in the
#    GNOME / KDE / wofi / rofi application menu with the correct icon.
nix profile install .#librefang-desktop

Expected: launching from the menu starts librefang-desktop, the window's launcher icon (via StartupWMClass) matches the menu icon, and #3156 is closed.

Notes

  • No new flake inputs; makeDesktopItem and copyDesktopItems ship in nixpkgs.
  • flake.lock is intentionally unchanged.
  • macOS build path is unchanged: copyDesktopItems and the postInstall icon installs are gated on pkgs.stdenv.isLinux.

Switch to nixpkgs' standard makeDesktopItem + copyDesktopItems helpers
instead of an inline heredoc, and install icons at every native size
shipped in the repo (32, 128, 256, 512) under share/icons/hicolor so
desktop environments can pick the closest match without rescaling.

Also drops the manual update-desktop-database call -- that cache is
maintained by the user environment, not the package output, and the
non-standard 'AI' Categories value (which desktop-file-validate flags)
is replaced with the standard Development;Utility; pair.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@github-actions github-actions Bot added the ready-for-review PR is ready for maintainer review label Apr 25, 2026
@houko

houko commented Apr 25, 2026

Copy link
Copy Markdown
Contributor Author

SSH-validated on NixOS (Linux 6.12.82, nix 2.31.4):

Initial build hit error: syntax error, unexpected '@' because Nix path interpolation \${./…/[email protected]} rejects @. Fixed in fbae1f6c by binding iconsDir = ./crates/librefang-desktop/icons in a let and using \"\${iconsDir}/[email protected]\" (concat at the shell layer).

After fix:

$ nix build .#librefang-desktop --no-link --print-out-paths
/nix/store/mldq035z1l0y9l1yjkc200b1s1z4x54k-librefang-desktop-2026.4.24-beta5

$ ls $OUT/share/applications/
librefang-desktop.desktop  (261 B)

$ find $OUT/share/icons -type f
.../share/icons/hicolor/32x32/apps/librefang-desktop.png
.../share/icons/hicolor/128x128/apps/librefang-desktop.png
.../share/icons/hicolor/256x256/apps/librefang-desktop.png
.../share/icons/hicolor/512x512/apps/librefang-desktop.png

$ cat $OUT/share/applications/librefang-desktop.desktop
[Desktop Entry]
Categories=Development;Utility
Comment=Open-source Agent Operating System
Exec=librefang-desktop
Icon=librefang-desktop
Keywords=AI;Agent;LLM;Automation
Name=LibreFang
StartupWMClass=librefang-desktop
Terminal=false
Type=Application
Version=1.5

$ desktop-file-validate $OUT/share/applications/librefang-desktop.desktop
hint: value \"Development;Utility\" for key \"Categories\" in group \"Desktop Entry\" contains more than one main category; application might appear more than once in the application menu
exit=0

The validate hint is cosmetic (some DEs may list LibreFang twice if both Development and Utility menus are shown). If you'd rather suppress that hint, change `categories = [ "Development" ];` (drop "Utility") in `flake.nix`. The functional behaviour is correct as-is.

@houko
houko merged commit 635ed2e into main Apr 25, 2026
20 checks passed
@houko
houko deleted the fix/nix-flake-desktop-3156 branch April 25, 2026 16:05
@github-actions github-actions Bot added size/M 50-249 lines changed needs-changes Changes requested by reviewer and removed ready-for-review PR is ready for maintainer review needs-changes Changes requested by reviewer labels Apr 25, 2026
@houko houko mentioned this pull request Apr 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M 50-249 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant