Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/3noch/nix-bundle-exe
Simple Nix derivations to bundle executables
https://github.com/3noch/nix-bundle-exe
Last synced: 23 days ago
JSON representation
Simple Nix derivations to bundle executables
- Host: GitHub
- URL: https://github.com/3noch/nix-bundle-exe
- Owner: 3noch
- License: mit
- Created: 2022-03-29T19:59:53.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-27T01:51:34.000Z (about 2 months ago)
- Last Synced: 2024-10-11T23:42:29.427Z (about 1 month ago)
- Language: Shell
- Size: 29.3 KB
- Stars: 38
- Watchers: 3
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# nix-bundle-exe
This is a simple [Nix](https://nixos.org/) derivation to bundle Mach-O (macOS) and ELF (Linux) executables into a relocatable directory structure. That is to say, given a Nix package containing executables, this derivation will produce a package with those same executables, but with all their shared libraries copied into a new directory structure and reconfigured to work without any dependency on Nix.
If you are able to build your executable with full static linking, that would be better than using this derivation. For cases where that is too difficult, you can use this.
This tool has a very similar goal to [nix-bundle](https://github.com/matthewbauer/nix-bundle) with some key differences:
1. `nix-bundle` works on arbitrary derivations and can bundle any resource, not just shared libraries. This tool only works on executables and their shared libraries.
2. `nix-bundle` does not work on macOS. This tool does.
3. `nix-bundle` requires target systems to have certain Linux kernel features. This tool requires Linux target systems to be POSIX only. macOS targets have no requirements.
4. `nix-bundle` has some large build-time dependencies which may make it hard to use in CI in some cases. This tool has no additional build-time dependencies.You may also want to check out [shrinkrap](https://github.com/fzakaria/shrinkwrap).
## Examples
This will make a bundle of `opencv` where all of its binaries can be run on a system where Nix is not installed.
```shell
nix-build -E 'with import {}; callPackage ./. {} opencv'
```This will bundle `gzip` only, and not any of its accompanying scripts:
```shell
nix-build -E 'with import {}; callPackage ./. {} "${gzip}/bin/gzip"'
```(Avoiding the accompanying scripts makes the resulting closure extremely small and does not depend on the original `gzip` closure in any way.)