-
-
Save exarkun/8b901aef53ca3698aecc16baf239a0fd to your computer and use it in GitHub Desktop.
wiringPi cross compile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ nix-build --keep-failed --expr 'let pkgs = import <nixpkgs> { localSystem = { system = "x86_64-linux"; }; crossSystem = { system = "armv7l-linux"; }; }; in pkgs.callPackage ./dht11reader/wiringPi { }' | |
these derivations will be built: | |
/nix/store/3kazdq4yfy04assx9vi367aza5xn0bfs-wiringPi-armv7l-unknown-linux-gnueabihf.drv | |
building '/nix/store/3kazdq4yfy04assx9vi367aza5xn0bfs-wiringPi-armv7l-unknown-linux-gnueabihf.drv'... | |
unpacking sources | |
unpacking source archive /nix/store/jrv8znqnippqs5bnd9557n126x4dnpgd-source | |
/nix/store/7k43g2ix6s9dhnccv975iq802f0bis18-stdenv-linux/setup: line 794: /nix/store/9rsxnjbzxhrg1ij8knlxzffpgh0vglc0-coreutils-8.29-armv7l-unknown-linux-gnueabihf/bin/basename: cannot execute binary file: Exec format error | |
/nix/store/7k43g2ix6s9dhnccv975iq802f0bis18-stdenv-linux/setup: line 812: /nix/store/9rsxnjbzxhrg1ij8knlxzffpgh0vglc0-coreutils-8.29-armv7l-unknown-linux-gnueabihf/bin/cp: cannot execute binary file: Exec format error | |
do not know how to unpack source archive /nix/store/jrv8znqnippqs5bnd9557n126x4dnpgd-source | |
note: keeping build directory '/tmp/nix-build-wiringPi-armv7l-unknown-linux-gnueabihf.drv-12' | |
builder for '/nix/store/3kazdq4yfy04assx9vi367aza5xn0bfs-wiringPi-armv7l-unknown-linux-gnueabihf.drv' failed with exit code 1 | |
error: build of '/nix/store/3kazdq4yfy04assx9vi367aza5xn0bfs-wiringPi-armv7l-unknown-linux-gnueabihf.drv' failed | |
$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs, mkDerivation, fetchFromGitHub, ... }: | |
mkDerivation rec { | |
name = "wiringPi"; | |
version = "2.46"; | |
src = fetchFromGitHub { | |
owner = "WiringPi"; | |
repo = "WiringPi"; | |
rev = "093e0a17a40e064260c1f3233b1ccdf7e4c66690"; | |
sha256 = "137fnav3yzr2w0sm0c2k2g1fzdgvj77dkxgn61nsg32jw3b3z7gj"; | |
}; | |
buildInputs = [ ]; | |
nativeBuildInputs = [ pkgs.gcc ]; | |
patchPhase = '' | |
sed -i -e 's,-I$(DESTDIR)$(PREFIX)/include,-I../wiringPi -I../devLib,' gpio/Makefile | |
sed -i -e 's,-L$(DESTDIR)$(PREFIX)/lib,-L../wiringPi -L../devLib,' gpio/Makefile | |
sed -i -e 's,-I\.,-I. -I../wiringPi,' devLib/Makefile | |
''; | |
buildPhase = '' | |
(pushd wiringPi; make libwiringPi.so.${version} && mv libwiringPi.so.${version} libwiringPi.so; popd) && | |
(pushd devLib; make libwiringPiDev.so.${version} && mv libwiringPiDev.so.${version} libwiringPiDev.so; popd) && | |
(pushd gpio; make; popd) | |
''; | |
installPhase = '' | |
mkdir -p $out/lib | |
mv wiringPi/libwiringPi.so $out/lib/ | |
mkdir -p $out/include | |
mv wiringPi/wiringPi.h $out/include/ | |
''; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment