on master help sign in
Load the bundled fish prompt via --no-config so ~/.config can't override it
commitb65e1e6e3ec5c769dc3ff313eb1b77d1667943df authoriko <mail@iko.soy> dateSat 27 Jun 2026, 22:13 (3 months ago) parentc35a6f5
3 files changed+23−16
README.md+2−1 c+1−1 flake.nix+20−14
README.md+2−1
@@ -66,7 +66,8 @@ nix run github:ilyakooo0/nix-container -- start
6666- `init` builds the OCI archive in a temp dir, loads it into `container`,
6767 deletes the temp file, then (re)creates the container. It mounts the current
6868 directory at `/workspace` (the container's working directory) and your
69− `~/.config` at `/root/.config`.
69+ `~/.config` at `/root/.config` (fish runs with `--no-config`, so this won't
70+ override its bundled prompt; other tools still read it).
7071- `--ssh` forwards your host SSH agent socket into the container (so `git` over
7172 SSH works with your keys).
7273- Add more mounts by passing them through (mounts can only be set at creation):
c+1−1
@@ -48,7 +48,7 @@ switch $argv[1]
4848 test $rc -eq 0; or exit $rc
4949
5050 # Mount the project at /workspace (the default cwd) and host ~/.config.
51− # (Mounting ~/.config shadows the image's bundled fish prompt config.)
51+ # (fish runs with --no-config, so the mount can't shadow the prompt.)
5252 set -l mounts -v "$PWD:/workspace"
5353 test -d $HOME/.config; and set -a mounts -v "$HOME/.config:/root/.config"
5454
flake.nix+20−14
@@ -76,10 +76,11 @@
7676 imageName = "nix-container";
7777 imageTag = "latest";
7878
79− # Fish prompt config, installed at /root/.config/fish/config.fish
80− # (fish reads $HOME/.config/fish). Built on the host arch — it's just a
81− # text file, so no Linux builder is needed.
82− fishConfig = pkgsHost.writeText "config.fish" ''
79+ # Fish prompt config. Installed at /etc/fish/prompt.fish and loaded via
80+ # `fish --no-config --init-command` (see `cmd` below), NOT from
81+ # $HOME/.config/fish — so the `~/.config` mount can't shadow it. Built
82+ # on the host arch (just a text file), so no Linux builder is needed.
83+ fishConfig = pkgsHost.writeText "prompt.fish" ''
8384 # No welcome banner.
8485 set -g fish_greeting
8586
@@ -105,10 +106,10 @@
105106 end
106107 '';
107108
108− # Lay the config out at the path fish reads.
109− fishRoot = pkgsHost.runCommand "fish-config-root" { } ''
110− mkdir -p "$out/root/.config/fish"
111− cp ${fishConfig} "$out/root/.config/fish/config.fish"
109+ # Lay the prompt out at the path the cmd sources.
110+ fishRoot = pkgsHost.runCommand "fish-prompt" { } ''
111+ mkdir -p "$out/etc/fish"
112+ cp ${fishConfig} "$out/etc/fish/prompt.fish"
112113 '';
113114
114115 # Build the OCI image from a `{ pkgs, nur }: [ ... ]` package function.
@@ -144,7 +145,7 @@
144145 ];
145146 pathsToLink = [
146147 "/bin"
147− "/root"
148+ "/etc/fish"
148149 "/etc/ssl"
149150 ];
150151 };
@@ -152,11 +153,16 @@
152153 initializeNixDatabase = true;
153154
154155 config = {
155− # `cmd` (not `entrypoint`): it's the default command and is
156− # *replaced* by `container run … -- <cmd>`. An entrypoint would be
157− # prepended instead, so `run … -- /bin/sh` would become
158− # `/bin/bash /bin/sh` and fail with "cannot execute binary file".
159− cmd = [ "/bin/fish" ];
156+ # `cmd` (not `entrypoint`): the default command, *replaced* by any
157+ # command passed to `container run/create`. `--no-config` skips
158+ # $HOME/.config/fish (so a mounted ~/.config can't override the
159+ # prompt); `--init-command` loads the bundled prompt instead.
160+ cmd = [
161+ "/bin/fish"
162+ "--no-config"
163+ "--init-command"
164+ "source /etc/fish/prompt.fish"
165+ ];
160166 env = [
161167 "PATH=/bin"
162168 "HOME=/root"