Run unpatched binaries on Nix/NixOS

Overview

nix-alien

ci

Introduction

You are running nix/NixOS and have ever encountered the following problem?

$ ./bb
bash: ./bb: No such file or directory

Fear not, now there is nix-alien which will download necessary dependencies for you.

$ ./nix-alien bb            --> Run the binary inside a FHS shell with all needed shared dependencies to execute the binary
$ ./nix-alien-ld bb         --> Spawns you inside a shell with NIX_LD_LIBRARY_PATH set to the needed dependencies, to be used with nix-ld
$ ./nix-alien-find-libs bb  --> Lists all libs needed for the binary

Usage (Flakes)

Assuming you have nix already installed:

$ nix-shell -p nixUnstable nix-index
$ nix-index # this will take a long time
$ nix run --experimental-features 'nix-command flakes' "github:thiagokokada/nix-alien" -- ~/myapp

This will run nix-alien on ~/myapp binary with a FHSUserEnv including all shared library dependencies. The resulting default.nix file will be saved to $XDG_CACHE_HOME/nix-alien/ /default.nix , making the next evaluation faster. You can also pass --recreate flag to force the recreation of default.nix file

You can edit your /etc/nix/nix.conf or ~/.config/nix/nix.conf file and add the following line to avoid having to pass --experimental-features flag every time:

experimental-features = nix-command flakes

From here on this guide will assume the above configuration is done for brevity.

In case you're using nix-ld, there is also nix-alien-ld:

$ nix run "github:thiagokokada/nix-alien#nix-alien-ld" -- ~/myapp 

This will spawn a mkShell instead with NIX_LD_LIBRARY_PATH and NIX_LD setup. The resulting shell.nix file will be saved to $XDG_CACHE_HOME/nix-alien/ /shell.nix , making the next evaluation faster. You can also pass --recreate flag to force the recreation of shell.nix file

If you want to use the fzf based menu to find the libraries for scripting purposes, you can run:

$ nix run "github:thiagokokada/nix-alien#nix-alien-find-libs" -- ~/myapp 

This will print the found libraries on the stdout. The informational messages are printed to stderr, so you can easily redirect them to /dev/null if needed.

To avoid the slow startup of nix-index, you can also download a pre-computed index from nix-index-database:

$ nix run "github:thiagokokada/nix-alien#nix-index-update"

Usage (non-Flakes)

$ $(nix-build default.nix --no-out-link)/bin/nix-alien
$ $(nix-build default.nix --no-out-link)/bin/nix-alien-ld
$ $(nix-build default.nix --no-out-link)/bin/nix-alien-find-libs
$ $(nix-build nix-index-update.nix --no-out-link)/bin/nix-index-update

Limitations

Binaries loading shared libraries dynamically (e.g.: with dlopen) will probably not work with this script. However, this script can still be useful to create an initial default.nix or shell.nix, that can be populated later with the runtime dependencies of the program.

Technical Description

This Python program allows you to download ELF binaries and use them right away! This is achieved by enumerating the shared library dependencies from the ELF header and then searching for the equivalent library in nixpkgs. This is done by querying nix-locate locally.

To be able to use nix-locate, first, the index has to be build. This is done by running nix-index and waiting 10-15 minutes. To speed-up this process, this repo also includes nix-index-update script, that downloads the index from nix-index-database.

Credits

Owner
Thiago Kenji Okada
Software Engineer at @nubank, Linux enthusiast, Anime fan and geek.
Thiago Kenji Okada
AIST++ API This repo contains starter code for using the AIST++ dataset.

Explainability for Vision Transformers (in PyTorch) This repository implements methods for explainability in Vision Transformers

Google 260 Dec 30, 2022
A water drinking notification every hour to keep you healthy while coding :)

Water_Notification A water drinking notification every hour to keep you healthy while coding. 💧 💧 Stay Hydrated Stay Healthy 💧 💧 Authors @CrazyCat

Arghya Banerjee 1 Dec 22, 2021
Notebook researcher - Notebook researcher with python

notebook_researcher To run the server, you must follow these instructions: At th

4 Sep 02, 2022
A project to find out all the words in a crossword.

A project to find out all the words in a crossword.

Kalpesh Dhoundiyal 1 Feb 06, 2022
fast_bss_eval is a fast implementation of the bss_eval metrics for the evaluation of blind source separation.

fast_bss_eval Do you have a zillion BSS audio files to process and it is taking days ? Is your simulation never ending ? Fear no more! fast_bss_eval i

Robin Scheibler 99 Dec 13, 2022
Minos-python - A framework which helps you create reactive microservices in Python

minos-python Summary [TODO] Packages minos-microservice-aggregate minos-microser

Minos Framework 380 Jan 04, 2023
The presented desktop application was made to solve 1d schrodinger eqation

schrodinger_equation_1d_solver The presented desktop application was made to solve 1d schrodinger eqation. It implements Numerov's algorithm (step by

Artem Kashapov 2 Dec 29, 2021
Certipy is a Python tool to enumerate and abuse misconfigurations in Active Directory Certificate Services (AD CS).

Certipy Certipy is a Python tool to enumerate and abuse misconfigurations in Active Directory Certificate Services (AD CS). Based on the C# variant Ce

ollypwn 1.3k Jan 01, 2023
A patch and keygen tools for typora.

A patch and keygen tools for typora.

Mason Shi 1.4k Apr 12, 2022
Simple AoC helper program you can use to develop your own solutions in python.

AoC-Compabion Simple AoC helper program you can use to develop your own solutions in python. Simply install it in your python environment using pip fr

Alexander Vollmer 1 Dec 20, 2021
A python program to detect rickrolls with just the youtube link.

rickroll_detector A python program to detect rickrolls with just the youtube link. Usage: clone this repo or download zip run the main.py file with py

Tricky 4 Nov 06, 2022
Yet another Airflow plugin using CLI command as RESTful api, supports Airflow v2.X.

中文版文档 Airflow Extended API Plugin Airflow Extended API, which export airflow CLI command as REST-ful API to extend the ability of airflow official API

Eric Cao 106 Nov 09, 2022
Sublime Text 2/3 style auto completion for ST4

Hippie Autocompletion Sublime Text 2/3 style auto completion for ST4: cycle through words, do not show popup. Simply hit Tab to insert completion, hit

Alexander Schepanovski 20 May 19, 2022
solsim is the Solana complex systems simulator. It simulates behavior of dynamical systems—DeFi protocols, DAO governance, cryptocurrencies, and more—built on the Solana blockchain

solsim is the Solana complex systems simulator. It simulates behavior of dynamical systems—DeFi protocols, DAO governance, cryptocurrencies, and more—built on the Solana blockchain

William Wolf 12 Jul 13, 2022
Find Transposon Element insertions using long reads (nanopore), by alignment directly. (minimap2)

find_te_ins find_te_ins is designed to find Transposon Element (TE) insertions using long reads (nanopore), by alignment directly. (minimap2) Install

Ming Wang 1 Feb 09, 2022
Percolation simulation using python

PythonPercolation Percolation simulation using python Exemple de percolation : Etude statistique sur le pourcentage de remplissage jusqu'à percolation

Tony Chouteau 1 Sep 08, 2022
Identify and annotate mutations from genome editing assays.

CRISPR-detector Here we propose our CRISPR-detector to facilitate the CRISPR-edited amplicon and whole genome sequencing data analysis, with functions

hlcas 2 Feb 20, 2022
Singularity Containers on Apple M1 (ARM64)

Singularity Containers on Apple M1 (ARM64) This is a repository containing a ready-to-use environment for singularity in arm64 (M1). It has been prepa

Manuel Parra 4 Nov 14, 2022
This is friendlist update tools & old idz clon & follower idz clon etc

This is friendlist update tools & old idz clon & follower idz clon etc

MAHADI HASAN AFRIDI 1 Jan 15, 2022
An easy way to access to your EPITECH subjects based on the Roslyn's database.

An easy way to access to your EPITECH subjects based on the Roslyn's database.

Mathias 1 Feb 09, 2022