@@ -28,7 +28,7 @@ switch $argv[1]
2828 end
2929
3030 # Host login shell (by name): added to the image automatically and baked
31− # in as the cmd + default $SHELL (what zellij panes etc. spawn), so it
31+ # in as the cmd + default $SHELL (what herdr panes etc. spawn), so it
3232 # needn't be listed in container.nix. Falls back to bash.
3333 set -l shell bash
3434 test -n "$SHELL"; and set shell (path basename $SHELL)
@@ -37,8 +37,8 @@ switch $argv[1]
3737 # temp dir, load it, then clean up.
3838 set -l tmp (mktemp -d)
3939 set -l archive $tmp/image.tar.gz
40− set -lx NIX_CONTAINER_PKGS (path resolve $config)
41− set -l expr "(builtins.getFlake \"$flake\").lib.\${builtins.currentSystem}.copyWithShell \"nix-container-$name\" \"$shell\" (import (/. + builtins.getEnv \"NIX_CONTAINER_PKGS\")).packages"
40+ set -lx NIX_CONTAINER_CONFIG (path resolve $config)
41+ set -l expr "(builtins.getFlake \"$flake\").lib.\${builtins.currentSystem}.copyWithShell \"nix-container-$name\" \"$shell\" (import (/. + builtins.getEnv \"NIX_CONTAINER_CONFIG\")).packages"
4242 set -l copyer (nix build --impure --no-link --print-out-paths --expr "$expr")
4343 set -l rc $status
4444 if test $rc -eq 0
@@ -57,7 +57,7 @@ switch $argv[1]
5757 # mounts from the config (`mounts = [ "host:container" … ]`). A leading
5858 # ~/ in the host path expands to $HOME (nix leaves it literal).
5959 set -l mounts -v "$PWD:/workspace"
60− for m in (nix eval --impure --raw --expr "builtins.concatStringsSep \"\n\" ((import (/. + builtins.getEnv \"NIX_CONTAINER_PKGS\")).mounts or [])")
60+ for m in (nix eval --impure --raw --expr "builtins.concatStringsSep \"\n\" ((import (/. + builtins.getEnv \"NIX_CONTAINER_CONFIG\")).mounts or [])")
6161 set -a mounts -v (string replace -r '^~/' "$HOME/" -- $m)
6262 end
6363
@@ -73,18 +73,20 @@ switch $argv[1]
7373 set term $TERM
7474 end
7575
76− # Replace any existing container of the same name. The image's cmd is
77− # zellij (`c start` attaches to it), so no command is passed here.
76+ # Replace any existing container of the same name, then create it running
77+ # herdr in a session named after the project (`<dir>-container`). This
78+ # overrides the image's default plain-herdr cmd; `c start` attaches to it.
7879 container rm --force $name 2>/dev/null
7980 # The image only lays down /bin and /etc, so /tmp and /run don't exist;
80− # without them anything that writes temp files (zellij, build tools, …)
81+ # without them anything that writes temp files (herdr, build tools, …)
8182 # fails with ENOENT. Mount writable tmpfs at both.
8283 container create --name $name --ssh -it -e "TERM=$term" \
83− --tmpfs /tmp --tmpfs /run --memory 8g --cwd /workspace $mounts $argv $image
84+ --tmpfs /tmp --tmpfs /run --memory 8g --cwd /workspace $mounts $argv \
85+ $image /bin/herdr session attach "$name-container"
8486 case start
85− # Start the container and attach to its cmd (zellij). TERM was baked into
87+ # Start the container and attach to its cmd (herdr). TERM was baked into
8688 # the container env at create time (`-e TERM`), which survives this path.
87− # Exiting zellij (PID1) stops the container; `c start` boots it again.
89+ # Exiting herdr (PID1) stops the container; `c start` boots it again.
8890 container start -ai $name
8991 case '*'
9092 echo "usage: c init [-c FILE] [create args] | start" >&2