|
2 | 2 |
|
3 | 3 | Flatpak package for [xonsh](https://xon.sh/). |
4 | 4 |
|
5 | | -## Build and Run |
6 | | - |
7 | | -```bash |
8 | | -sudo apt-get install -y flatpak flatpak-builder |
9 | | -pip install . |
10 | | -xonsh build.xsh |
11 | | - |
| 5 | +## Install and Run |
| 6 | +```xsh |
| 7 | +# Install flatpak e.g. `sudo apt-get install -y flatpak` |
| 8 | +# Download xonsh flatpak |
| 9 | +wget https://github.com/xonsh/xonsh-flatpak/releases/latest/download/xonsh.flatpak |
12 | 10 | flatpak install --user xonsh.flatpak |
13 | 11 | flatpak run io.github.xonsh.xonsh |
14 | 12 | ``` |
15 | 13 |
|
16 | | -## Build Options |
| 14 | +## Usage |
17 | 15 |
|
18 | | -```bash |
19 | | -# Default: xonsh/xonsh @ main |
20 | | -xonsh build.xsh |
21 | | - |
22 | | -# Custom repo and branch |
23 | | -xonsh build.xsh --git-url https://github.com/anki-code/xonsh/tree/anki_new_start |
24 | | -``` |
25 | | - |
26 | | -The `--git-url` flag accepts GitHub, GitLab, Codeberg URLs with branch in the path, |
27 | | -SSH URLs (`git@github.com:owner/repo.git`), or shorthand (`owner/repo`). |
28 | | - |
29 | | -## Host Command Forwarding |
| 16 | +### `host` alias |
30 | 17 |
|
31 | 18 | The Freedesktop runtime includes ~728 standard Unix commands (`ls`, `cat`, |
32 | 19 | `grep`, `curl`, etc.), but system-specific tools like `git`, `docker`, `ssh` |
33 | 20 | are not available inside the Flatpak sandbox. |
34 | 21 |
|
35 | | -### How it works |
36 | | - |
37 | | -``` |
38 | | -User types "git status" |
39 | | - → xonsh finds /app/libexec/host-cmds/git (symlink → host-spawn) |
40 | | - → host-spawn runs: flatpak-spawn --host --env=TERM=... git status |
41 | | - → flatpak-spawn executes "git status" on the host system |
42 | | - → output flows back to xonsh inside the sandbox |
43 | | -``` |
44 | | - |
45 | | -**`host-spawn`** is a single 2-line shell script: |
| 22 | +To solve this we have `host` alias in xonsh RC `flatpak.xsh`. It executes |
| 23 | +the command on the host system e.g. |
46 | 24 |
|
47 | | -```sh |
48 | | -#!/bin/sh |
49 | | -exec flatpak-spawn --host --env=TERM="${TERM:-xterm-256color}" "$(basename "$0")" "$@" |
| 25 | +```xsh |
| 26 | +host git status # `flatpak-spawn --host git status` |
50 | 27 | ``` |
51 | 28 |
|
52 | | -It uses `basename "$0"` to determine which command to run — so the same script |
53 | | -works for every command via symlinks. `$TERM` is forwarded so that ncurses |
54 | | -applications (`htop`, `vim`, `nano`, etc.) work correctly on the host. |
55 | | - |
56 | | -During the Flatpak build, symlinks are created for common host commands: |
| 29 | +### Symlinks to popular tools |
57 | 30 |
|
58 | | -``` |
59 | | -/app/libexec/host-cmds/git → /app/libexec/host-spawn |
60 | | -/app/libexec/host-cmds/* → /app/libexec/host-spawn |
61 | | -``` |
| 31 | +In `io.github.xonsh.xonsh.yml` we have a list of popular commands |
| 32 | +(`git`, `docker`, `ssh`, `vim`, `htop`, etc). During the Flatpak build, |
| 33 | +symlinks are created for popular host commands e.g. |
| 34 | +`/app/libexec/host-cmds/git` will be the symlink to `/app/libexec/host-spawn`. |
62 | 35 |
|
63 | | -The directory `/app/libexec/host-cmds` is **appended** to `$PATH` (not |
64 | | -prepended), so sandbox binaries in `/app/bin` and `/usr/bin` always take |
65 | | -priority over host-forwarded ones. |
| 36 | +The directory `/app/libexec/host-cmds` is appended to `$PATH` with low priority. |
66 | 37 |
|
67 | | -### Pre-configured commands |
68 | 38 |
|
69 | | -`git`, `docker`, `ssh`, `vim`, `htop`, and many more (~45 total). |
70 | | -To see the full list or add more, edit the `for cmd in ...` loop in |
71 | | -`io.github.xonsh.xonsh.yml`. |
72 | | - |
73 | | -### Running other host commands |
74 | | - |
75 | | -For commands without a symlink, use `flatpak-spawn` directly: |
| 39 | +## Build |
76 | 40 |
|
77 | 41 | ```bash |
78 | | -flatpak-spawn --host mycommand --flag |
79 | | -``` |
80 | | - |
81 | | -Or copy `flatpak-xonshrc.py` to `~/.config/xonsh/rc.d/` for the `host` alias: |
82 | | - |
83 | | -```xonsh |
84 | | -host mycommand --flag |
| 42 | +sudo apt-get install -y flatpak flatpak-builder |
| 43 | +pip install . |
| 44 | +xonsh build.xsh # or with GitHub/GitLab/Codeberg URL: `--git-url https://github.com/xonsh/xonsh/tree/another_branch_name` |
| 45 | +flatpak install --user xonsh.flatpak |
| 46 | +flatpak run io.github.xonsh.xonsh |
85 | 47 | ``` |
86 | 48 |
|
87 | 49 | ## Links |
|
0 commit comments