Skip to content

feat(lua): resolve system runtime tiers so distro packages work - #407

Merged
Kohei-Wada merged 1 commit into
mainfrom
feat/system-runtime-tier
Sep 13, 2026
Merged

Kohei-Wada merged 1 commit into
mainfrom
feat/system-runtime-tier

Conversation

@Kohei-Wada

Copy link
Copy Markdown
Owner

Refs #375 — the groundwork for an AUR package. Does not publish anything to the AUR.

Why

runtimepath.rs only knew $TTYMAP_RUNTIME, the baked CARGO_MANIFEST_DIR and the two XDG dirs. A distro package installs to /usr/bin + /usr/share, so a packaged ttymap would have failed at startup with runtime not found ... Did you make install? for every user. That — not the PKGBUILD — was the real blocker.

What

  • New lowest-priority tiers: /usr/local/share/ttymap, then /usr/share/ttymap. Ranked below $XDG_DATA_HOME/ttymap so a per-user make install always shadows a packaged copy, and non-existent on a machine that has never installed a package, where is_valid filters them out exactly as before.
  • candidate_layers split out of resolve_runtime_path, so the priority order is unit-testable without staging real directories.
  • make install-system stages $DESTDIR$PREFIX/{bin/ttymap,share/ttymap/} for packagers. make install is untouched — same command, same output, still no sudo anywhere in the Makefile. The old "system-wide installs are intentionally unsupported" comment becomes "don't do it by hand; go through a packager".
  • packaging/PKGBUILD as the in-tree reference. Marked not-yet-publishable: install-system landed after v0.3.0, so it needs a newer tag (bump pkgver + updpkgsums) before it can go to aur.archlinux.org/ttymap.git.
  • Doc sync: README install section, docs/lua-architecture.md layer list, CLAUDE.md tree + resolution summary.

Verification

  • cargo clippy --all-targets -- -D warnings clean, cargo fmt --check clean, cargo test green (2 new runtimepath tests covering tier ordering and the no-XDG case).
  • Per-user install is byte-identical. Hashed ~/.local/share/ttymap before and after re-running make install-runtime on this branch — same sha256.
  • A packaged layout actually boots. Staged make install-system DESTDIR=… PREFIX=/usr, then in a user namespace overlaid that tree at the real /usr/share and bind-mounted an empty dir over the repo's runtime/ so the dev tier was gone, with HOME pointed at an empty dir so neither XDG tier existed. Ran the staged binary on a 160×50 pty for 20 s: 6481 Braille cells painted, 6226 non-blank. /usr/share/ttymap was the only runtime layer in play.

Follow-up (not in this PR)

Publishing to the AUR needs a tagged release containing install-system, and the actual git push to aur.archlinux.org needs your SSH key.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GFGFsYeFLqRaWUAzXonwd3

AUR (#375) installs to /usr/bin + /usr/share, but runtimepath only
knew $TTYMAP_RUNTIME, the baked manifest dir and the two XDG dirs —
a packaged ttymap would fail at startup with "runtime not found" for
every user.

- add /usr/local/share/ttymap then /usr/share/ttymap as the lowest-
  priority tiers, so a per-user `make install` always shadows a
  packaged copy and machines without a package see no change
- split candidate enumeration out of resolve_runtime_path so the
  ordering is unit-testable without staging directories
- Makefile: `install-system` stages $DESTDIR$PREFIX/{bin,share/ttymap}
  for packagers. `make install` keeps its exact per-user behaviour
  and still never needs sudo; the Makefile itself never calls it
- packaging/PKGBUILD as the in-tree reference for the AUR copy

Refs #375

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GFGFsYeFLqRaWUAzXonwd3

@amazon-q-developer amazon-q-developer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

This PR successfully implements system runtime tier support for distro packages. The implementation is well-designed, properly tested, and ready to merge.

Key Achievements

Core Implementation:

  • Adds /usr/local/share/ttymap and /usr/share/ttymap as lowest-priority runtime tiers
  • Ensures per-user make install always shadows packaged copies through correct priority ordering
  • Refactors resolve_runtime_path to extract candidate_layers, improving testability
  • Handles the no-XDG-dirs case gracefully (important for minimal environments)

Build & Packaging:

  • New make install-system target stages $DESTDIR$PREFIX/{bin,share/ttymap} for packagers
  • Reference PKGBUILD demonstrates the complete AUR packaging workflow
  • Uses proper install flags (-Dm755 for binary, -Dm644 for data files)
  • Builds with --locked for reproducibility

Testing:

  • Two new tests verify tier ordering and the no-XDG-dirs case
  • Existing tests remain green
  • Manual verification confirmed packaged layout boots correctly

Documentation:

  • README, Makefile, CLAUDE.md, and lua-architecture.md all updated consistently
  • Clear distinction between per-user (make install) and packager (make install-system) workflows

No Issues Found

All code functions correctly with no defects blocking merge. The verification included testing a packaged layout with proper isolation, confirming runtime resolution works as expected.


You can now have the agent implement changes and create commits directly on your pull request's source branch. Simply comment with /q followed by your request in natural language to ask the agent to make changes.

@Kohei-Wada
Kohei-Wada merged commit 2911795 into main Sep 13, 2026
5 checks passed
@Kohei-Wada
Kohei-Wada deleted the feat/system-runtime-tier branch September 13, 2026 03:53
@Kohei-Wada Kohei-Wada mentioned this pull request Sep 13, 2026
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant