@@ -112,43 +112,50 @@
112112
113113 # Build the OCI image from a `{ pkgs, nur }: [ ... ]` package function.
114114 # The fish prompt config is always added; the default `cmd` is
115− # /bin/fish, so a custom package set should include `fish` (or change
116− # `config.cmd`).
115+ # /bin/fish, so the package set should include `fish` (warned about
116+ # below if missing) or override `config.cmd`.
117117 mkImage =
118118 packages:
119− n2c.buildImage {
120− name = imageName;
121− tag = imageTag;
122− inherit arch;
123−
124− # A plain, single-process root filesystem. No NixOS, no systemd.
125− copyToRoot = pkgsLinux.buildEnv {
126− name = "root";
127− paths = packages {
128− pkgs = pkgsLinux;
129− nur = nurPkgs;
130− } ++ [ fishRoot ];
131− pathsToLink = [
132− "/bin"
133− "/root"
134− ];
119+ let
120+ pkgList = packages {
121+ pkgs = pkgsLinux;
122+ nur = nurPkgs;
135123 };
136−
137− initializeNixDatabase = true;
138−
139− config = {
140− # `cmd` (not `entrypoint`): it's the default command and is
141− # *replaced* by `container run … -- <cmd>`. An entrypoint would
142− # be prepended instead, so `run … -- /bin/sh` would become
143− # `/bin/bash /bin/sh` and fail with "cannot execute binary file".
144− cmd = [ "/bin/fish" ];
145− env = [
146− "PATH=/bin"
147− # fish reads its prompt from $HOME/.config/fish/config.fish.
148− "HOME=/root"
149− ];
150− };
151− };
124+ in
125+ pkgsLinux.lib.warnIf (!builtins.any (p: (p.pname or "") == "fish") pkgList)
126+ "nix-container: config.cmd is /bin/fish but the package set has no `fish` — the container will fail to start unless something provides /bin/fish (or change config.cmd)."
127+ (
128+ n2c.buildImage {
129+ name = imageName;
130+ tag = imageTag;
131+ inherit arch;
132+
133+ # A plain, single-process root filesystem. No NixOS, no systemd.
134+ copyToRoot = pkgsLinux.buildEnv {
135+ name = "root";
136+ paths = pkgList ++ [ fishRoot ];
137+ pathsToLink = [
138+ "/bin"
139+ "/root"
140+ ];
141+ };
142+
143+ initializeNixDatabase = true;
144+
145+ config = {
146+ # `cmd` (not `entrypoint`): it's the default command and is
147+ # *replaced* by `container run … -- <cmd>`. An entrypoint would
148+ # be prepended instead, so `run … -- /bin/sh` would become
149+ # `/bin/bash /bin/sh` and fail with "cannot execute binary file".
150+ cmd = [ "/bin/fish" ];
151+ env = [
152+ "PATH=/bin"
153+ # fish reads its prompt from $HOME/.config/fish/config.fish.
154+ "HOME=/root"
155+ ];
156+ };
157+ }
158+ );
152159
153160 # `nix run . -- init|start` runs the bundled `c` manager script. Its
154161 # `init` builds the image from the project's `container.nix` (via