@@ -110,77 +110,89 @@
110110 cp ${fishConfig} "$out/root/.config/fish/config.fish"
111111 '';
112112
113− image = n2c.buildImage {
114− name = imageName;
115− tag = imageTag;
116− inherit arch;
117−
118− # A plain, single-process root filesystem. No NixOS, no systemd.
119− copyToRoot = pkgsLinux.buildEnv {
120− name = "root";
121− paths = with pkgsLinux; [
122− bashInteractive
123− fish
124− fishRoot
125− openssh
126− coreutils-full
127− btop
128− jujutsu
129− zellij
130− micro
131− helix
132− nurPkgs.repos.charmbracelet.crush
133−
134− # LLM tools
135− git
136− ripgrep
137− fd
138− jq
139− curl
140− wget
141− gnused
142− gnugrep
143− gawk
144− findutils
145− gnutar
146− gzip
147− unzip
148− less
149− which
150− tree
151− nodejs
152− python3
153−
154− # rust
155− rustc
156− cargo
157− rustfmt
158− clippy
159−
160− # C toolchain — rustc links final binaries through `cc`/`ld`.
161− gcc # provides cc/gcc; pulls in binutils (ld) via its closure
162− ];
163− pathsToLink = [
164− "/bin"
165− "/root"
166− ];
113+ # The curated tool set baked into the image. Drop a `nix-container.nix`
114+ # (`pkgs: [ ... ]`) next to where you run `c init` to replace this with
115+ # your own list — see README.
116+ defaultPackages =
117+ pkgs: with pkgs; [
118+ bashInteractive
119+ fish
120+ openssh
121+ coreutils-full
122+ btop
123+ jujutsu
124+ zellij
125+ micro
126+ helix
127+ nurPkgs.repos.charmbracelet.crush
128+
129+ # LLM tools
130+ git
131+ ripgrep
132+ fd
133+ jq
134+ curl
135+ wget
136+ gnused
137+ gnugrep
138+ gawk
139+ findutils
140+ gnutar
141+ gzip
142+ unzip
143+ less
144+ which
145+ tree
146+ nodejs
147+ python3
148+
149+ # rust
150+ rustc
151+ cargo
152+ rustfmt
153+ clippy
154+
155+ # C toolchain — rustc links final binaries through `cc`/`ld`.
156+ gcc # provides cc/gcc; pulls in binutils (ld) via its closure
157+ ];
158+
159+ # Build the OCI image from a `pkgs: [ ... ]` package function. The fish
160+ # prompt config is always added; the default `cmd` is /bin/fish, so a
161+ # custom package set should include `fish` (or change `config.cmd`).
162+ mkImage =
163+ packages:
164+ n2c.buildImage {
165+ name = imageName;
166+ tag = imageTag;
167+ inherit arch;
168+
169+ # A plain, single-process root filesystem. No NixOS, no systemd.
170+ copyToRoot = pkgsLinux.buildEnv {
171+ name = "root";
172+ paths = packages pkgsLinux ++ [ fishRoot ];
173+ pathsToLink = [
174+ "/bin"
175+ "/root"
176+ ];
177+ };
178+
179+ initializeNixDatabase = true;
180+
181+ config = {
182+ # `cmd` (not `entrypoint`): it's the default command and is
183+ # *replaced* by `container run … -- <cmd>`. An entrypoint would
184+ # be prepended instead, so `run … -- /bin/sh` would become
185+ # `/bin/bash /bin/sh` and fail with "cannot execute binary file".
186+ cmd = [ "/bin/fish" ];
187+ env = [
188+ "PATH=/bin"
189+ # fish reads its prompt from $HOME/.config/fish/config.fish.
190+ "HOME=/root"
191+ ];
192+ };
167193 };
168194
169− initializeNixDatabase = true;
170−
171− config = {
172− # `cmd` (not `entrypoint`): it's the default command and is
173− # *replaced* by `container run … -- <cmd>`. An entrypoint would be
174− # prepended instead, so `run … -- /bin/sh` would become
175− # `/bin/bash /bin/sh` and fail with "cannot execute binary file".
176− cmd = [ "/bin/fish" ];
177− env = [
178− "PATH=/bin"
179− # fish reads its prompt from $HOME/.config/fish/config.fish.
180− "HOME=/root"
181− ];
182− };
183− };
195+ image = mkImage defaultPackages;
184196
185197 # `nix run . -- init|start` runs the bundled `c` manager script. Its
186198 # build step shells back to `nix run .#image`; the script finds the
@@ -202,6 +214,17 @@
202214 # the destination, so spell out the tag to avoid an `untagged` load.
203215 image = flake-utils.lib.mkApp { drv = image.copyTo; };
204216 };
217+
218+ # Build helpers. `c init` uses `copyWith` to honour a per-project
219+ # `nix-container.nix`:
220+ # (builtins.getFlake "github:…/nix-container")
221+ # .lib.<system>.copyWith (import ./nix-container.nix)
222+ lib = {
223+ inherit mkImage;
224+ # skopeo copy app (`skopeo copy nix:<image> "$@"`) for an image built
225+ # from a `pkgs: [ ... ]` function.
226+ copyWith = packages: (mkImage packages).copyTo;
227+ };
205228 }
206229 );
207230}