[Nix] Some steps towards cross-compilation support

This commit is contained in:
Zahary Karadjov 2019-02-20 01:22:52 +02:00
parent c722f34ef3
commit 8b3b1f4c57
3 changed files with 66 additions and 16 deletions

View File

@ -1,10 +1,60 @@
let
pkgs = import (fetchTarball {
nixpkgsFn = import (fetchTarball {
url = https://github.com/NixOS/nixpkgs/archive/642499faefb17c3d36e074cf35b189f75ba43ee2.tar.gz;
sha256 = "16j7gl3gg839fy54z5v4aap8lgf1ffih5swmfk62zskk30nwzfbi";
}) {};
});
# nixcrpkgs = import (fetchTarball {
# url = https://github.com/DavidEGrayson/nixcrpkgs/archive/606e5fac74204643c8ca48dd73ce239b2f821d69.tar.gz;
# sha256 = "19dn7i200xsv8s92kxymv3nd87jncmp3ki8pw77v2rxfvn8ldg34";
# }) {};
nixpkgs = nixpkgsFn {};
targets = {
windows = {
config = "x86_64-pc-mingw32";
libc = "msvcrt";
platform = {};
openssl.system = "mingw";
};
iphone = {
config = "aarch64-apple-ios";
# config = "aarch64-apple-darwin14";
sdkVer = "10.2";
xcodeVer = "8.2";
xcodePlatform = "iPhoneOS";
useiOSPrebuilt = true;
platform = {};
};
android = {
config = "armv7a-unknown-linux-androideabi";
sdkVer = "24";
ndkVer = "18b";
platform = nixpkgs.platforms.armv7a-android;
useAndroidPrebuilt = true;
};
raspberryPi = rec {
config = "armv6l-unknown-linux-gnueabihf";
platform = nixpkgs.platforms.raspberrypi;
};
raspberryPi2 = {
config = "armv7l-unknown-linux-gnueabihf";
platform = nixpkgs.platforms.armv7l-hf-multiplatform;
};
};
nimbus = pkgs: pkgs.callPackage ./nix/nimbus.nix {};
mapAttrs = nixpkgs.lib.attrsets.mapAttrs;
crossPackages = mapAttrs (target: conf: nixpkgsFn { crossSystem = conf; }) targets;
crossBulds = mapAttrs (target: packages: nimbus packages) crossPackages;
in
import ./nix/nimbus.nix { inherit pkgs; }
(nimbus nixpkgs) // crossBulds

View File

@ -1,4 +1,5 @@
{ stdenv, lib, makeWrapper, git, nodejs, openssl, pcre, readline, sqlite }:
{ stdenv, lib, makeWrapper, git, clang, nodejs, openssl, pcre, readline, sqlite }:
let
csources = fetchTarball {
url = https://github.com/nim-lang/csources/archive/b56e49bbedf62db22eb26388f98262e2948b2cbc.tar.gz;
@ -44,23 +45,23 @@ in stdenv.mkDerivation rec {
# used for bootstrapping, but koch insists on moving the nim compiler around
# as part of building it, so it cannot be read-only
buildInputs = [
buildInputs = [
makeWrapper nodejs
openssl pcre readline sqlite git
clang openssl pcre readline sqlite git
];
buildPhase = ''
buildPhase = ''
export HOME=$TMP
mkdir -p dist
cp -r ${nimble} dist/nimble
cp -r ${csources} csources
chmod 755 $(find csources dist/nimble -type d)
cd csources
sh build.sh
CC="clang" LD="clang" sh build.sh
cd ..
bin/nim c -d:release koch.nim
./koch boot -d:release
./koch tools -d:release
bin/nim c --cc:clang -d:release koch.nim
./koch boot --cc:clang -d:release
./koch tools --cc:clang -d:release
'';
installPhase = ''

View File

@ -1,8 +1,7 @@
{ pkgs ? import <nixpkgs> { } }:
{ stdenv, callPackage, sqlite, clang, rocksdb }:
let
stdenv = pkgs.stdenv;
nim = pkgs.callPackage ./nim.nix {};
nim = callPackage ./nim.nix {};
makeLibraryPath = stdenv.lib.makeLibraryPath;
in
@ -15,11 +14,11 @@ stdenv.mkDerivation rec {
description = "An Ethereum 2.0 Sharding Client for Resource-Restricted Devices";
homepage = https://github.com/status-im/nimbus;
license = [licenses.asl20];
platforms = platforms.unix;
platforms = platforms.unix ++ platforms.windows;
};
src = ./.;
buildInputs = [pkgs.clang nim pkgs.rocksdb pkgs.sqlite];
buildInputs = [clang nim rocksdb sqlite];
LD_LIBRARY_PATH = "${makeLibraryPath buildInputs}";
}