-
Notifications
You must be signed in to change notification settings - Fork 1
Run dynamically linked non‐nix binaries on Red‐Flake
You can use nix-alien
to run dynamically linked binaries on Red-Flake.
When trying to run dynamically linked executables on NixOS, you might encounter errors like these:
$ ./httpx
Could not start dynamically linked executable: ./httpx
NixOS cannot run dynamically linked executables intended for generic
linux environments out of the box. For more information, see:
https://nix.dev/permalink/stub-ld
or
$ ./httpx
bash: ./httpx: No such file or directory
or
$ ./tor-browser/Browser/updater
./tor-browser/Browser/updater: error while loading shared libraries: libgtk-3.so.0: cannot open shared object file: No such file or directory
NixOS does not support running dynamically linked binaries intended for other Linux distributions out of the box. This is where nix-alien comes in handy.
nix-alien
creates a Foreign Host System (FHS) shell with all necessary shared dependencies to execute the binary.
Usage:
❯ nix-alien <binary>
Example:
❯ nix-alien ./httpx
__ __ __ _ __
/ /_ / /_/ /_____ | |/ /
/ __ \/ __/ __/ __ \| /
/ / / / /_/ /_/ /_/ / |
/_/ /_/\__/\__/ .___/_/|_|
/_/
projectdiscovery.io
[INF] Current httpx version v1.3.3 (outdated)
To pass arguments to the application:
nix-alien ./httpx -- --foo bar
Alternatively, you can use nix-alien-ld
to run the binary. This method spawns a wrapped binary with NIX_LD_LIBRARY_PATH
and NIX_LD
properly set up.
❯ nix-alien-ld ./httpx
__ __ __ _ __
/ /_ / /_/ /_____ | |/ /
/ __ \/ __/ __/ __ \| /
/ / / / /_/ /_/ /_/ / |
/_/ /_/\__/\__/ .___/_/|_|
/_/
projectdiscovery.io
[INF] Current httpx version v1.3.3 (outdated)
This will generate a default.nix
file saved to $XDG_CACHE_HOME/nix-alien/<path-uuid>/nix-ld/default.nix
, speeding up future evaluations. The cache is based on the binary's absolute path.
Additional Flags:
-
--recreate
: Forces the recreation of thedefault.nix
file. -
--destination
: Changes where thedefault.nix
file will be saved.