Skip to content

feat: nix buildpack#206

Draft
olevski wants to merge 5 commits into
mainfrom
feat-nix-buildpack
Draft

feat: nix buildpack#206
olevski wants to merge 5 commits into
mainfrom
feat-nix-buildpack

Conversation

@olevski
Copy link
Copy Markdown
Member

@olevski olevski commented Apr 8, 2026

This works. The only thing left to do is that there is an order and grouping to image extensions. And by adding the 2nd one that installs nix in a build image if I flip the image extension order things break. I will check if you can have 2 groups of image extensions, rather than 1.

The buildpack works by:

  • installing nix in the build image (via an image extension)
  • running nix build .... which places a bunch of symlinks to /nix/store in the buildpack layer
  • follows the symlinks from above and copies the real files in the buildpack layer
  • the image extension makes the run image have a symlink that makes /nix/store point to the buildpack layer with all the real files

So usually when you run nix it produces stuff that symlinks to /nix/store but in this case we flip that around. /nix/store in the run image is a symlink to the layer that contains the full store created from the buildpack. We cannot avoid /nix/store and symlinks because the exectuables from nix are hardcoded to expect stuff exclusively in /nix/store.

@olevski olevski marked this pull request as draft April 8, 2026 07:50
Comment on lines +14 to +17
while IFS= read -r path; do
echo "---> Copying $path"
cp -rL "$path" "$nix_layer/nix/store/"
done < <(nix path-info --no-sandbox --recursive .#)
Copy link
Copy Markdown

@gabyx gabyx Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion:
I would use nix copy to only copy the derivation you build

  1. build with nix build --json --print-out-paths ".#default" --json | jq ".[].outputs.out" or nix build --print-out-paths ".#my-package"
  2. Then you copy the closure to a new location with nix copy /nix/store/... --to "$nix_layer/nix/store

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

future: Also the attrset path in the installable .#default could be customized maybe ...: <flake-path>#<attribute>

  • ./tools/nix#my-stuff or so...

maybe not so important....

@olevski olevski changed the title Feat nix buildpack feat: nix buildpack Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants