I can envision some applications for distributing packages for non-nix systems while still relying on nix to build them.
I can envision some applications for distributing packages for non-nix systems while still relying on nix to build them.
Neither supports non-absolute paths which is the crux of the issue.
That being said I've long suspected there is a happy middle ground where you hack at the problem from both sides. On one side you provide F(x) -> x' where x is an absolute path closure and x' is a relative path closure, for any supported subgraphs in the build graph. Then, for the rest, you rebuild from source using any transformed inputs you can. In other words, when you're evaluating x', if you have x in a cache already, and you can rewrite it, do so. If not, just build it from scratch.
The problem is at some point you have to prove that both methods of producing x' result in the same exact output. This is not easy! However you can possibly prove it for any arbitrary closure by simply round tripping. For example, assuming the transform F(x) -> x' is cheap, and at some point you build x, which is almost guaranteed, then allow x'' == x and when you build x just try and retarget it anywhere, and then back again.
This doesn't prove it actually works, but might prove that it's correct, which is acceptable to me. I haven't got far enough to try this out yet, of course. Be my guest!
The flake schema has a "bundler" output that can point to an executable like this to bundle a flake's outputs for any supported target. Not sure about the state of the art, though.
https://github.com/3noch/nix-bundle-exe
I've never tried it out though.