Add mise tasks, desktop entry, and app icon
mise run install builds a release binary and installs it into ~/.local with a desktop entry and a hicolor icon. Two wrinkles specific to a Nix-built GTK app installed outside the dev shell: the launcher is a generated script rather than a symlink, because a desktop launcher provides a minimal environment and GTK still needs to be pointed at its GSettings schemas and icon themes; and install registers Nix GC roots for every store path in the binary's RPATH, so nix-collect-garbage cannot delete GTK out from under the installed app. The runtime paths are exported from the flake's shellHook and read back at install time, so they cannot drift from what the binary was built against.
This commit is contained in:
@@ -16,6 +16,31 @@ zig build run
|
||||
|
||||
Everything is pinned by `flake.nix`; nothing needs to be installed on the host.
|
||||
|
||||
## Installing
|
||||
|
||||
```sh
|
||||
mise run install # builds release, installs into ~/.local
|
||||
mise run uninstall
|
||||
```
|
||||
|
||||
That puts the binary in `~/.local/libexec/vtabs`, a launcher on `~/.local/bin`,
|
||||
a desktop entry in `~/.local/share/applications`, and the icon in the hicolor
|
||||
theme, then refreshes the desktop and icon caches. `mise tasks` lists the rest
|
||||
(`build`, `run`, `fmt`, `screenshot`).
|
||||
|
||||
Two things the installer has to handle that a normal `install` wouldn't:
|
||||
|
||||
- **A launcher, not a symlink.** The binary links against GTK in the Nix store
|
||||
and has an RPATH, so it runs anywhere — but it still needs to be pointed at
|
||||
GTK's GSettings schemas and icon themes, or it aborts on a missing schema.
|
||||
A desktop launcher starts the app with a minimal environment, so those paths
|
||||
are baked into the launcher script. They are read out of the dev shell at
|
||||
install time rather than hardcoded, so they can't drift from the flake.
|
||||
- **Nix GC roots.** The installed app depends on store paths that
|
||||
`nix-collect-garbage` would otherwise be free to delete, which would break it
|
||||
later with no obvious connection to the command that did it. Install pins
|
||||
every store path in the binary's RPATH; uninstall releases them.
|
||||
|
||||
## Which "libghostty" this uses, and why
|
||||
|
||||
Ghostty ships two different C APIs, and only one of them is usable here:
|
||||
@@ -116,8 +141,8 @@ This is a proof of concept, and the following are deliberately absent:
|
||||
`./b.sh` wraps `nix develop --command zig build` and strips the enormous
|
||||
command line Zig prints on failure.
|
||||
|
||||
`./shot.sh out.png "text to type"` runs the app inside a throwaway **headless
|
||||
Sway** and screenshots it. This keeps UI checks entirely out of your real
|
||||
`mise run screenshot out.png "text to type"` (or `./shot.sh` directly) runs the
|
||||
app inside a throwaway **headless Sway** and screenshots it. This keeps UI checks entirely out of your real
|
||||
Wayland session — nothing appears on screen, and it works while the session is
|
||||
locked.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user