3noch / nix-bundle-exe

Simple Nix derivations to bundle executables
MIT License
39 stars 3 forks source link

would this work for Shell scripts (and are they in-scope?) #19

Closed abathur closed 2 years ago

abathur commented 2 years ago

Low-priority curiosity. I suspect from the README and from the example below that doing so (bundling all dependencies, potentially transitively) would entail more complexity than you intend to hold, here?

~/work/nix-bundle-exe $ echo heh | xargs
heh

~/work/nix-bundle-exe $ echo heh | /nix/store/d1gbpqynqiwmsxzmdflbmap9rmcnhgn3-bundle-findutils-4.9.0/bin/xargs
xargs: /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-coreutils-9.0/bin/echo: No such file or directory

Nix patches the echo here: https://github.com/NixOS/nixpkgs/blob/95af2245a32f8e1310ad4e3bf50b76d86ddbbc0a/pkgs/tools/misc/findutils/default.nix#L20


If the answer's more of a yes/maybe, here's what I have in mind With resholve + Nix, we can do a fairly good job of requiring all of a Shell script's dependencies to be present and substituting their absolute paths into the script. I'm not sure if it would actually sway many Shell projects to adopt Nix, but _in theory_, a lot of them projects could shed some complexity (code for things like prerequisite testing, selecting alternate prerequisites such as `wget || curl` and `awk || sed`, finding the project's library files, etc.) if they weren't worried about targeting systems without Nix. That probably won't be true often, but there might be _some_ on the bubble who could be swayed by the prospect of trading some of their dependency-related support load for a set of larger download-and-run bundles? (probably the same set that would be tempted by just making a dockerfile?)
3noch commented 2 years ago

@abathur Great question! I would say shell scripts are out of scope for this project. But I'd be very interested in contributing toward a more ambitious project that tries to handle more than just executables with shared libraries. I would be happy to have nix-bundle-exe be a smaller part of a bigger plan, if that made any sense. I think nix-bundle leaves a lot to be desired so I'm all for this kind of project.

3noch commented 2 years ago

Thank you for sharing some of year ideas. I'd never heard of resholve but it looks awesome.

abathur commented 2 years ago

But I'd be very interested in contributing toward a more ambitious project that tries to handle more than just executables with shared libraries. I would be happy to have nix-bundle-exe be a smaller part of a bigger plan, if that made any sense.

It does. Thanks :)

I don't imagine I'll be directly focusing on it anytime soon (I've still got a lot of work to do to improve resholve for Nix targets), but I may open a help-wanted issue in resholve and talk up a better bundling approach any time I get a chance. I imagine it would have value outside of resholve's case, so it might make a good independent project for someone.

I'll close this since you answered my question, but feel free to reopen it if you think having it visible here might be of value.