TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Nixpacks takes a source directory and produces an OCI compliant image

152 pointsby ghuntleyalmost 3 years ago

14 comments

chriswarboalmost 3 years ago
Looks like this requires Docker to be available?<p>Personally I&#x27;ve been making OCI images using Nix, just by running tar, sha256sum and jq:<p>- We can get a Nix derivation&#x27;s dependencies using `writeDependenciesToFile`<p>- We can put these dependencies (alongside anything else we like) into an OCI &quot;layer&quot; using GNU tar: the `--hard-dereference` and `--mode=755` options work well, and we can include directories using `-C &#x2F;foo --filesFrom=foo.txt` where foo.txt comes from `cd &#x2F;foo &amp;&amp; find . -maxdepth 1`, with the leading `.&#x2F;` removed.<p>- A &quot;digest&quot; is just a JSON file like `{size: 123, digest: &quot;abc&quot;}`, e.g. generated using `stat` and `sha256sum`<p>- Those sha256sums can be referenced in a config.json, like `{&quot;rootfs&quot;: {&quot;type&quot;: &quot;layers&quot;, &quot;diff_ids&quot;: [...]}}`; along with the application-specific config (EntryPoint, WorkingDir, etc.)<p>- Finally, a &quot;manifest&quot; is just another JSON file; with `{&quot;mediaType&quot;: &quot;application&#x2F;vnd.oci.image.config.v1+json&quot;}` for the config digest, and `{&quot;mediaType&quot;: &quot;application&#x2F;vnd.oci.image.layer.v1.tar+gzip&quot;}` for each layer digest.<p>Unlike Docker, these commands can all be run directly (from the &quot;host&quot;, although it&#x27;s not really hosting anything, since we don&#x27;t need any containers or VMs to run the above); their contents are completely declarative (since we&#x27;re just zipping up pre-existing files, e.g. built&#x2F;fetched by Nix; rather than mutating a filesystem in-place); we can do it on any OS (e.g. no need for a Linux VM on macOS); etc.
评论 #32503092 未加载
评论 #32505294 未加载
评论 #32502688 未加载
评论 #32523173 未加载
评论 #32507009 未加载
mrkurtalmost 3 years ago
We added experimental support to Nixpacks for Fly.io (it&#x27;s baked into our CLI). I&#x27;m very excited about it, buildpacks have been a nightmare.
评论 #32503243 未加载
justjakealmost 3 years ago
Oh neat. We&#x27;ve been meaning to post this on HN!<p>We&#x27;re the people behind nixpacks; happy to answer any questions just holler
评论 #32502043 未加载
aliasxneoalmost 3 years ago
I&#x27;ve been using nix2container[1] for awhile now. It looks like this depends on Docker, have you guys considered removing that dependency? It shouldn&#x27;t be necessary to create an OCI compliant image with Nix.<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;nlewo&#x2F;nix2container" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;nlewo&#x2F;nix2container</a>
jbboehralmost 3 years ago
Do builds use sandboxing? It appears not[0], is this in the roadmap? Based on my experiences with node2nix, composer2nix, carnix, etc, I don&#x27;t blame you for not going that route. Not to knock on the developers of those tools - it&#x27;s a difficult problem. I apologize if my interpretation is incorrect.<p>[0]: <a href="https:&#x2F;&#x2F;github.com&#x2F;railwayapp&#x2F;nixpacks&#x2F;blob&#x2F;60ab563fdc9bf4fb5540388680a2f368e0436db2&#x2F;src&#x2F;providers&#x2F;php.rs#L82" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;railwayapp&#x2F;nixpacks&#x2F;blob&#x2F;60ab563fdc9bf4fb...</a>
xelxebaralmost 3 years ago
Somewhat tangential, but I&#x27;m curious how big the bootstrap seed for Nix is. That is, if you wanted to build the entire world, what&#x27;s a minimum set of binaries you&#x27;d need?<p>Guix has put quite a bit of work into this, AFAIU, and it&#x27;s getting close to being bootstrappable all the way from stage0 [0]. Curious if some group is also working on similar things for Nix.<p>[0]:<a href="https:&#x2F;&#x2F;github.com&#x2F;oriansj&#x2F;stage0" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;oriansj&#x2F;stage0</a>
评论 #32503372 未加载
pxcalmost 3 years ago
This is really cool, and reminds me of some parts of Domen Kozar&#x27;s recent talk titled &#x27;Nix is going mainstream&#x27;¹. The crucial work of putting together this kind of really simple frontend seems like what he&#x27;s talking about when he says we need &#x27;our Docker&#x27;, like how Docker built upon old tech (chroots, jails, LXC) to make it radically more usable.<p>--<p>1: <a href="https:&#x2F;&#x2F;youtu.be&#x2F;WuWZqSSoLxY" rel="nofollow">https:&#x2F;&#x2F;youtu.be&#x2F;WuWZqSSoLxY</a>
0x69420almost 3 years ago
name is eerily similar to `nixpkgs`, i.e. the monorepo that defines all packages and one of the underlying technologies here. i get the play on buildpacks, but still, as a nix user it makes me do a double take reading the name<p>this is neat though, and in political terms, the elevator pitch mentions nix itself as an implementation detail in passing. hopefully, if this catches on, it&#x27;ll function as a non-threatening gateway drug to nix itself, when users inevitably go digging into the weeds<p>for anyone interested, prior art on the nix container front: <a href="https:&#x2F;&#x2F;nixery.dev" rel="nofollow">https:&#x2F;&#x2F;nixery.dev</a>
评论 #32502256 未加载
risalmost 3 years ago
It&#x27;s interesting&#x2F;neat, but it doesn&#x27;t make use of e.g. nixpkgs&#x27; beautifully maintained python package distribution, leaving you with all the same pitfalls of pip&#x2F;pypi as any other buildpack. And I don&#x27;t imagine the end result will be a &quot;pure&quot; artefact, and so I can&#x27;t see how they&#x27;d be able to safely remove the build-time packages from the final image.
评论 #32502858 未加载
gavinrayalmost 3 years ago
Neato -- so basically Buildpacks[0] redone with Nix?<p>[0]: <a href="https:&#x2F;&#x2F;buildpacks.io&#x2F;" rel="nofollow">https:&#x2F;&#x2F;buildpacks.io&#x2F;</a>
评论 #32502203 未加载
0xferruccioalmost 3 years ago
Loved this! Tried this on a rails app for a side project and it worked out of the box
mathfailurealmost 3 years ago
I don&#x27;t like the docs &#x2F; project description. Everything is made &#x27;so simple&#x27; that important parts are now gone and everything is now pure magic, I guess.<p>&gt; We want to make it more trivial to build OCI compliant images without all the knowledge required to understand how Dockerfiles&#x2F;Container Filesystem&#x2F;BuildLayers&#x2F;etc work<p>As someone who understands how the above mentioned stuff works - I feel like I&#x27;m being forcefully excluded from the tool&#x27;s target audience as I need explanations and the docs are written with such an idea in mind that it is something I shouldn&#x27;t know.<p><a href="https:&#x2F;&#x2F;nixpacks.com&#x2F;docs&#x2F;how-it-works" rel="nofollow">https:&#x2F;&#x2F;nixpacks.com&#x2F;docs&#x2F;how-it-works</a><p>&gt; Nixpacks works in two steps<p>&gt; Plan<p>&gt; Analyze the app source directory and generates a reproducible build plan. This plan can be saved (in JSON format) and re-used at a later date to build the image in the exact same way every time.<p>How about an example of how a simple plan for a few projects would look like?<p>Plus, the tool seems to assume too much:<p>&gt; To create the plan, language providers are matched against the app source directory and suggest Nix packages<p>I don&#x27;t need no Nix in my images, no thanks.
jonringer117almost 3 years ago
Nice, really interesting usage of nixpkgs :). Almost a command line friendly version of docker build.<p>I like it.
评论 #32502031 未加载
ev0xmusicalmost 3 years ago
I&#x27;ve just published a feedback article on Nixpacks since I experimented it 2 months ago. <a href="https:&#x2F;&#x2F;www.qovery.com&#x2F;blog&#x2F;my-feedback-about-nixpacks-an-alternative-to-buildpacks" rel="nofollow">https:&#x2F;&#x2F;www.qovery.com&#x2F;blog&#x2F;my-feedback-about-nixpacks-an-al...</a><p>TLDR; it&#x27;s promising