diff options
author | Ambroz Bizjak <ambrop7@gmail.com> | 2016-05-15 18:30:49 +0300 |
---|---|---|
committer | Ambroz Bizjak <ambrop7@gmail.com> | 2016-05-15 18:30:49 +0300 |
commit | aecd4bd4195f61b25bc3916af682d48a0ba9732e (patch) | |
tree | 726889eb949301a71acaf798a34161797bb87f00 | |
parent | 3897cdf4aa7deb1fc863cb198fb7381b224ff793 (diff) |
Add Nix expressions for cross-compiling to Windows.
Currently needs patched NixPkgs with fixed cross-compile of NSPR+NSS.
-rw-r--r-- | badvpn-win32.nix | 30 | ||||
-rw-r--r-- | build-win32.nix | 32 |
2 files changed, 62 insertions, 0 deletions
diff --git a/badvpn-win32.nix b/badvpn-win32.nix new file mode 100644 index 0000000..b6719f7 --- /dev/null +++ b/badvpn-win32.nix @@ -0,0 +1,30 @@ +{ stdenv, cmake, pkgconfig, openssl, nspr, nss, debug ? false }: +let + compileFlags = "-O3 ${stdenv.lib.optionalString (!debug) "-DNDEBUG"}"; +in +stdenv.mkDerivation { + name = "badvpn"; + + src = stdenv.lib.cleanSource ./.; + + nativeBuildInputs = [ cmake pkgconfig ]; + buildInputs = [ openssl nspr nss ]; + + NIX_CFLAGS_COMPILE = "-I${nspr.crossDrv}/include/nspr -I${nss.crossDrv}/include/nss"; + + preConfigure = '' + cmakeFlagsArray=( "-DCMAKE_BUILD_TYPE=" "-DCMAKE_C_FLAGS=${compileFlags}" "-DCMAKE_SYSTEM_NAME=Windows" ); + ''; + + postInstall = '' + for lib in eay32; do + cp ${openssl.crossDrv}/bin/lib$lib.dll $out/bin/ + done + for lib in nspr4 plc4 plds4; do + cp ${nspr.crossDrv}/lib/lib$lib.dll $out/bin/ + done + for lib in nss3 nssutil3 smime3 ssl3; do + cp ${nss.crossDrv}/lib/$lib.dll $out/bin/ + done + ''; +} diff --git a/build-win32.nix b/build-win32.nix new file mode 100644 index 0000000..e701fe1 --- /dev/null +++ b/build-win32.nix @@ -0,0 +1,32 @@ +# NOTE: Must be used with patched nixpkgs: +# https://github.com/ambrop72/nixpkgs/tree/cross-mingw-nss + +let + pkgsFun = import <nixpkgs>; + + crossSystem = { + config = "i686-w64-mingw32"; + arch = "x86"; + libc = "msvcrt"; + platform = {}; + openssl.system = "mingw"; + is64bit = false; + }; + + pkgs = pkgsFun { + inherit crossSystem; + }; + +in +rec { + inherit pkgs; + + drvs = rec { + badvpnFunc = import ./badvpn-win32.nix; + badvpn = pkgs.callPackage badvpnFunc {}; + badvpnDebug = pkgs.callPackage badvpnFunc { debug = true; }; + }; + + badvpn = drvs.badvpn.crossDrv; + badvpnDebug = drvs.badvpnDebug.crossDrv; +} |