README.md

foyer #

foyer create <name> runs jj workspace add, then runs the new workspace's .foyer/setup.sh if it has one. Meant to canonicalize standard setup for things so automated tooling and agents can get going without having to encode a skill or some other terrible solution.

If you like jj workspaces and work in neovim, try open-floorplan.nvim. Foyer support coming soon.

Try it in your browser #

Run foyer in your browser

The link opens trynix.dev, which boots a small Linux VM in the browser tab — QEMU compiled to WebAssembly. At the shell prompt, run:

foyer-demo

That seeds a jj repo with a committed .foyer/setup.sh, runs foyer create feature-x, and shows the furnished workspace. foyer and jj are already on PATH, so you can keep going by hand afterwards.

Use #

foyer create <name> [options]
foyer remove <name> [--to <dir>]

create options:

option effect
--to <dir> destination (default: sibling <repo>-<name>)
--rev <revset> parent revision(s) for the new working copy
--branch <name> base on bookmark <name>@<remote> (excludes --rev)
--remote <r> remote for --branch (default: origin)
-m <message> description for the new working-copy commit
--no-furnish create the workspace, skip .foyer/setup.sh

Run either directly, or as jj foyer create <name> — the home-manager module installs that alias.

foyer requires jj on PATH.

The setup script #

If the new workspace contains an executable .foyer/setup.sh, foyer runs it there with JJ_WORKSPACE_ROOT pointing at the workspace root. A typical one activates the environment:

#!/usr/bin/env bash
# .foyer/setup.sh
direnv allow

The script has to be committed.

The teardown script #

foyer remove <name> is the reverse of create. It runs jj workspace forget <name> first, then, if the directory holds an executable .foyer/teardown.sh, runs it there with JJ_WORKSPACE_ROOT set.

Because we forget the workspace first, A teardown script can clean up freely, including deleting its own directory:

#!/usr/bin/env bash
# .foyer/teardown.sh
rm -rf "$JJ_WORKSPACE_ROOT"    # self-removal, if you want it

foyer itself never deletes files.

User-global hooks #

The setup and teardown scripts are committed to a repo, so everyone who uses that repo shares them. Hooks are the reverse: per-user scripts that run on every workspace, whatever the project. Drop executable scripts in

$XDG_CONFIG_HOME/foyer/hooks/create/    # run on every `foyer create`
$XDG_CONFIG_HOME/foyer/hooks/remove/    # run on every `foyer remove`

foyer runs every executable in the relevant directory, in file-name order, with cwd set to the workspace and JJ_WORKSPACE_ROOT exported — the same environment the project script gets. Order relative to the project script:

  • create — project .foyer/setup.sh first, then the create hooks.
  • remove — the remove hooks first, then project .foyer/teardown.sh.

The remove order is deliberate: a teardown may delete its own directory, so the hooks run first, while the directory still exists. A failing hook is reported as a warning; it never fails the command.

With home-manager, configure them in Nix instead of writing files by hand:

programs.foyer.hooks.create = [
  { text = "direnv allow"; }              # a bash snippet; shebang added for you
  { source = ./my-hook.sh; }              # a file you already keep on disk
  { name = "notify"; text = ''
      #!/usr/bin/env bash
      notify-send "furnished $(basename "$JJ_WORKSPACE_ROOT")"
    ''; }
];
programs.foyer.hooks.remove = [
  { text = "my-cleanup"; }
];

Each entry becomes a numbered executable under foyer/hooks/<event>/ (10-…, 20-…, in list order). name fixes the file-name suffix; omit it and the list index is used.

A hook is either text (an inline body — a #!/usr/bin/env bash shebang is added when absent) or source (a path to an existing script, installed verbatim). source takes any Nix path: a file in your config, or one another expression produces (for example pkgs.writeShellScript). Setting both, or neither, is a build-time error.

Install #

Home-manager (Nix) #

{
  imports = [ inputs.foyer.homeModules.foyer ];
  programs.foyer.enable = true;   # installs the CLI + `jj foyer` alias
}

programs.foyer.aliasName renames the jj alias (default "foyer"). programs.foyer.installJjAlias = false installs the CLI without touching your jj config. programs.foyer.hooks.{create,remove} install user-global hook scripts (see User-global hooks).

Download a binary #

Each release attaches self-contained binaries for Linux (x86_64, aarch64) and macOS (Apple Silicon).

curl -LO https://github.com/ducharmemp/foyer/releases/latest/download/foyer-linux_amd64
chmod +x foyer-linux_amd64
./foyer-linux_amd64 help

Verify against the release's SHA256SUMS with sha256sum -c.

Nix (without home-manager) #

nix profile install github:ducharmemp/foyer   # escript; needs Erlang at runtime

Develop #

nix develop        # elixir, erlang, elixir-ls, jj, zig, xz
mix test
nix build .#foyer  # the escript
nix flake check    # tests in the sandbox

Release binaries are built by scripts/build-release.sh if needed. It needs Elixir/Erlang, Zig and xz. The Erlang OTP version must be one Burrito publishes precompiled ERTS for (the CI workflow pins it); see scripts/build-release.sh and .github/workflows/release.yml.