feat-deviant(os): embed a configurable resource directory
Relocating a Cargo-installed binary loses executable-relative resource lookup even when themes and shell integration exist under /usr/share. Allow packagers to set GHOSTTY_BUILD_RESOURCES_DIR when compiling. Absolute paths are used directly; relative paths resolve against the running executable's directory for relocatable installations. Explicit paths do not require terminfo sentinels. A nonempty runtime override wins in every profile when the build option is configured. Unset or empty build options preserve existing discovery, including debug precedence. Cargo watches the build option so changing or unsetting it recompiles lookup. Resource files still need to be installed separately. Document this requested upstream deviation and the build option in the README, architecture overview, and deviation register. Test Plan: - Eight resource lookup unit tests pass. - Nightly formatting and ghostty-os Clippy with -D warnings pass. - Production build with /usr/share/ghostty succeeds; a copied executable lists all 463 themes with no runtime override. - Compiled probes verify absolute, relative, unset, and empty options, Cargo rebuilds, relocation, runtime overrides, and unrelated cwd. Deviation-Register: docs/rewrite/DEVIANT_FIXES.md
This commit is contained in:
1 parent
4cfeee71cc
commit
85489a164e
5 files changed
+142
-15
No files matched your search
@@ -61,6 +61,32 @@ just install /usr/local # binary, share/ghostty, terminfo, desktop file
|
||||
just install /usr false true # system-package layout (lib/systemd/user)
|
||||
```
|
||||
|
||||
### Build-time resource directory
|
||||
|
||||
Set `GHOSTTY_BUILD_RESOURCES_DIR` while building or installing to embed an
|
||||
explicit resource directory:
|
||||
|
||||
```sh
|
||||
GHOSTTY_BUILD_RESOURCES_DIR=/usr/share/ghostty cargo build --profile production
|
||||
GHOSTTY_BUILD_RESOURCES_DIR=/usr/share/ghostty cargo install --path . --profile production
|
||||
GHOSTTY_BUILD_RESOURCES_DIR=../share/ghostty cargo build --profile production
|
||||
```
|
||||
|
||||
Absolute paths are used directly. Relative paths resolve from the running
|
||||
executable's directory, not the current working directory; `../share/ghostty`
|
||||
allows moving an installed `bin/` and `share/` tree together. The directory
|
||||
contains `themes/` and `shell-integration/`; these files still need to be installed
|
||||
separately (`cargo install` only installs the executable).
|
||||
|
||||
A nonempty runtime `GHOSTTY_RESOURCES_DIR` overrides the embedded path in every
|
||||
profile. The embedded path takes precedence over automatic resource discovery
|
||||
and does not require a terminfo sentinel. An unset or empty build option keeps
|
||||
the existing discovery rules, including the debug profile's preference for
|
||||
installed resources over the runtime override. Changing or unsetting the build
|
||||
option causes Cargo to rebuild resource lookup. Paths are literal: `~` and shell
|
||||
variables are not expanded by Ghostty. Flatpak's sandbox resource layout remains
|
||||
managed by its runtime integration.
|
||||
|
||||
## Testing
|
||||
|
||||
```sh
|
||||
|
||||
Reference in new issue
Block a user