Discover/GNOME Software list nothing: nix backend provides no AppStream catalog #3
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-up to #2. The get_repo_list/repo_enable gap is closed (fork b39054e, flake pin
564bba0, lock 898e63d, CI switch 597 success); polkit sources-refresh now grants and refresh-cache succeeds. But Discover still shows "not found in the available sources" / empty Installed list. The remaining root cause is AppStream metadata, NOT a PackageKit entry-point problem.Root cause (confirmed from Discover 6.8.2 source): libdiscover's PackageKit plugin builds its searchable/listable set entirely from an on-disk AppStream pool (AppStream::ConcurrentPool), not from PackageKit transactions. Search calls m_appdata->search(); Installed/All iterate m_appdata->components() keeping only components with packageNames(). Only the Updates view uses PackageKit (getUpdates), which is why get-updates is the ONLY PackageKit transaction Discover ever issues for a nix backend. So Discover never calls get-packages/search-name for a search: that path is AppStream-gated. get_repo_list was necessary (the sources gate) but not sufficient.
Live evidence (zero AppStream): /run/current-system/share/applications = 0 desktop files; *.metainfo.xml / *.appdata.xml in the closure = 0; /var/cache/app-info, /var/cache/appstream, share/app-info, ~/.cache/appstream all empty/absent. The nix backend refresh_cache only runs the evaluator refresh; it never emits an AppStream catalog.
Cross-cutting: AppStream is the common metadata layer for GNOME Software, Discover, fwupd, appstreamctl, etc. None can list/search/browse-by-category nixpkgs packages unless an AppStream catalog for the package set exists at a libappstream-scanned origin. Any PackageKit backend on NixOS hits this same wall; the fix belongs at the packaging/distribution layer, not inside an individual backend.
Approaches:
Recommended: (1), with (2) as a sub-step (collect existing metainfo) plus a synthesizer that emits at least component/id/pkgname/summary/metadata_license/project_license per attrset so arbitrary search terms match.
Status of pieces already shipped: get_repo_list/repo_enable implemented + deployed (b39054e) - necessary, not sufficient; polkit 50-packagekit.rules works when the requesting process is in the user's active logind session cgroup; Discover packagekit-qt overlay in pk-managed.nix is correct.
Related: #1 (per-method entry points), #2 (get_repo_list).
Root cause found + proven end-to-end
The AppStream pool was reading our YAML catalog files as 0 components for one non-obvious reason: libappstream 1.1.3 globs YAML metadata as
*.yml*(and*.yml.gzwhen compressed-only) — seesrc/as-pool.c, both the loader and the status printer useas_utils_find_files_matching(loc, "*.yml*", ...).A file named
nixpkgs.yamldoes not match that glob (it has no.ymlsubstring), so it was silently never enumerated. The DEP-11 schema (with thePackage:component key fromas-tag-yaml.gperf->AS_TAG_PKGNAME) and theOrigin:document header were both fine; only the filename extension was wrong.Verification
Dropping the same catalog as
/var/lib/swcatalog/yaml/nixpkgs.yml:appstreamcli status-> "We have information on 2 software components" (YAML: 1 file, 2 comps)appstreamcli search firefox-> returnsorg.nixpkgs.firefoxwithPackage: firefox--search firefox --backends packagekit) now renders a real result card (screenshot observed): "Search: firefox - 1 item" -> Mozilla Firefox / Web browser.Required catalog format (confirmed)
/var/lib/swcatalog/yaml/(os-catalog scan root/var/lib/swcatalog, subdiryaml).yml(e.g.nixpkgs.yml) or.yml.gz(compressed)Origin: <id>, components useID,Package,Name,Summary,MetadataLicense,ProjectLicense,CategoriesloadAllPackages()keeps only components with non-emptypackageNames()-> thePackage:field is mandatory per component.Next: generate this catalog over the real nixpkgs set and ship it at
/var/lib/swcatalog/yaml/nixpkgs.ymlfrom the flake (issue scope covers GNOME Software/fwupd too, since AppStream is the common layer).Real nixpkgs-wide DEP-11 catalog: generated + observed serving results
Built a full metadata walker over the pinned nixpkgs set and emitted a real DEP-11 catalog (no existing nixpkgs tool does this: appstream-generator, nix-remote-appstream, nix-remote-appstream3 are all absent at the pinned rev). Result: 90,917 components from 113,418 derivations (filtered to those with a non-empty description and available = true).
Deployed to /var/lib/swcatalog/yaml/nixpkgs.yml, appstreamcli refresh-cache --force then status reports: We have information on 90917 software components.
Observed in Plasma Discover against the real catalog:
The PackageKit daemon logs get-updates plus per-component resolve transactions finishing with success against these attr-paths, confirming the catalog Package value (dot-joined nix attribute path, e.g. gnome.gvfs) is what the backend install/resolve path expects.
Two additional format gotchas found (beyond the .yml glob root cause)
Quote every scalar value. Many nixpkgs descriptions contain a colon-space (e.g. Summary: Virtual Filesystem: support library). In a plain YAML scalar this makes libyaml throw mapping values are not allowed, which aborts the ENTIRE document stream - the pool then reports YAML: 1 file but 0 components. Double-quote all scalar values (escaping backslash, quote, tabs).
Name and Summary are LOCALIZED DEP-11 fields and must be emitted as a locale map, not a flat scalar. A flat Name: firefox is silently dropped by libappstream (the pool stores Package but no Name/Summary, so Discover renders blank cards). The correct form:
Type: generic
ID: org.nixpkgs.firefox
Package: firefox
Name:
C: firefox
Summary:
C: Web browser built from Firefox source tree
ProjectLicense: MPL-2.0
MetadataLicense: CC0-1.0
With a document header of Origin: nixpkgs, Description: Nix packages, File: DEP-11, Version: 1.0, Origin-is-opensource: true, DefaultLocale: C.
The catalog itself still needs to be wired into the flake as a reproducible build artifact (pure-Nix string emitter installed to /var/lib/swcatalog/yaml/nixpkgs.yml via the module). Tracking that next.
Catalog wired into the flake - fully reproducible, no manual steps
The DEP-11 generator now lives in the flake as pk-catalog.nix: a pure-Nix function of the system's own package set (no builtins.getFlake, no JSON round-trip, no python). It walks legacyPackages., recursing on recurseForDerivations, guards every attr/meta access with builtins.tryEval (catching EvalError from throw-stubs) and filters out non-string licenses and the internal tests.* namespace. It emits the locale-map Name/Summary + quoted scalars described above.
Installed via nixosModules.default (so consuming configs need only a flake.lock bump):
The catalog is generated from the SAME pkgs the backend resolves against, so Package values always match installable attr-paths (that is why the deployed count 91,817 differs from a standalone nixpkgs eval: it includes system overlays).
Verified: CI rebuild switch succeeded, the tmpfiles symlink resolves to /nix/store/xh1wnsggw5zalpczz5r6mkpvj0cbzkhj-nixpkgs-appstream-catalog, the refresh oneshot exited SUCCESS, appstreamcli status = 91817 components, and Plasma Discover (backends packagekit) shows Search: firefox - 53 items with named cards firefox / Web browser built from Firefox source tree and an install button. Same fix path serves GNOME Software since both read the libappstream pool.
Categories added to DEP-11 catalog (pure Nix)
Added a deterministic keyword classifier in
pk-catalog.nixthat emits an AppStreamCategories:list per component, so Discover's left-hand category tree populates. Nixpkgs has no native AppStream categories, so the classifier mapspname + meta.description(lowercased,.-> space, whitespace-padded for word-boundary matching) against the fixed freedesktop/AppStream vocabulary Discover understands:Internet(.Browsers/.Email/.Chat/.FileTransfer/.News),Game,AudioVideo(.Audio/.Video),Graphics(.Photography/.Vector/.3D),Development(.VersionControl/.BuildSystem/.Debugger/.IDE),Office,Utility(.Compression),System(.Hardware/.Security),Science,Education.Rules are substring-based and tuned against the real 91k-row catalog. Spot-checks (validated via direct pure-Nix eval of the pinned package set):
Emitted per component as:
appstreamcli list-categoriesconfirms Discover's tree is driven directly by these values.Eval against the pinned system package set: 21,574
Categories:blocks emitted (consistent with the Python prototype's ~21k assigned; ~39% coverage — dev libraries without a clear GUI category legitimately stay uncategorized).Deploy status: BLOCKED by external cache outage (NOT a regression)
Commit
5b18b16(flake) + lock bump05e2e21(nixos-config) pushed. CIrebuild.ymlswitch run 599 fails, but only because the configured third-party substitutercache.lantian.pubis returning HTTP 502 for every path (root, nix-cache-info, and the required narinfog139w43rwhrkk5cz6a96ldj0k7k5rval, which is NOT in the local store). The cachyos kernel each generation needs is served only from that mirror. Nix treats a 5xx narinfo as fatal and does not fall back to cache.nixos.org.Host
/etc/nix/nix.confalso lists it asextra-substituters, so the outage blocks any rebuild, not just CI. Once the mirror recovers, rerun the switch and I will verify the category tree via screenshot. No deploy claim until that screenshot is taken.Categories verified live in Discover (Deploy 4 complete)
The third-party substituter
cache.lantian.pubwas returning HTTP 502 on every path during the first CI switch (run 599), which Nix treats as a fatal narinfo error with no fallback to cache.nixos.org. The mirror has since recovered (root + nix-cache-info now 200; the one needed narinfo returns a graceful 404, which Nix handles by falling back). Rerun of 599 => success.2adr8rc7yffrka3163dh2v898kj9gi7j-nixos-system-nixos-26.11.20261103.1d06008Categories:entries (91,817 components total)appstreamcli refresh-cache --force=> successappstreamcli list-categories 'Internet.Browsers'=> firefox-esr-unwrapped;list-categories 'Graphics'=> 271 componentsIn Plasma Discover (
--backends packagekit), the left-hand category browse tree is fully populated: All Applications, Accessibility, Development, Education, Games, Graphics, Internet, Multimedia, Office, Science & Math, System, Utilities, Fonts. Discover builds this tree solely from the catalogCategories:field, so a populated tree is conclusive proof the classifier output is consumed.Note (separate, tracked in Issue #4): an "Update Issue" popup still appears at launch from the packagekit system-sources-refresh auth failure (uid 1000 failed to obtain auth, only_trusted:0). It is non-blocking for browsing/categories and stays deferred under Issue #4.