Skip to content

Instantly share code, notes, and snippets.

@Pamplemousse
Created July 31, 2020 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pamplemousse/0a57a4712698da172243889c886fee2a to your computer and use it in GitHub Desktop.
Save Pamplemousse/0a57a4712698da172243889c886fee2a to your computer and use it in GitHub Desktop.
with import <nixpkgs> { };
let
armhfDependencies = [
pkgsCross.armv7l-hf-multiplatform.buildPackages.targetPackages.glibc
pkgsCross.armv7l-hf-multiplatform.buildPackages.targetPackages.ncurses5
pkgsCross.armv7l-hf-multiplatform.buildPackages.targetPackages.readline5
];
in stdenv.mkDerivation {
name = "cross-environment";
buildInputs = [
qemu
] ++ armhfDependencies;
shellHook = ''
# Set the right interpreters for the binaries.
patchelf --set-interpreter "${pkgsCross.armv7l-hf-multiplatform.buildPackages.targetPackages.glibc}/lib/ld-linux-armhf.so.3" BINARY
# Copy the libraries so they are handy for `qemu`.
mkdir -p ./libs
ln -sf ${pkgsCross.armv7l-hf-multiplatform.buildPackages.targetPackages.ncurses5}/lib/libncurses.so.5 ./libs/libncurses.so.5
ln -sf ${pkgsCross.armv7l-hf-multiplatform.buildPackages.targetPackages.readline5}/lib/libreadline.so.5 ./libs/libreadline.so.5
'';
}
$ sed -i 's/BINARY/<PATH OF THE BINARY>/' shell.nix
$ nix-shell
[nix-shell:]$ qemu-arm <PATH OF THE BINARY>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment