diff options
author | Ambroz Bizjak <ambrop7@gmail.com> | 2016-11-18 21:58:02 +0300 |
---|---|---|
committer | Ambroz Bizjak <ambrop7@gmail.com> | 2016-11-18 21:58:02 +0300 |
commit | d72d798d6674fed1763b216023030fa5a49c5414 (patch) | |
tree | 7ece4c3b803b33b316386e692a253568a802add2 | |
parent | 3940ed01b4c611485977bad4da38283e0cf48ec2 (diff) |
Finishing Nix build method for Windows.
-rw-r--r-- | BUILD-WINDOWS-old.txt (renamed from INSTALL) | 3 | ||||
-rw-r--r-- | BUILD-WINDOWS.txt | 17 | ||||
-rw-r--r-- | badvpn-win32.nix | 77 | ||||
-rw-r--r-- | build-win32.nix | 10 |
4 files changed, 72 insertions, 35 deletions
diff --git a/INSTALL b/BUILD-WINDOWS-old.txt index 3605f4e..77af485 100644 --- a/INSTALL +++ b/BUILD-WINDOWS-old.txt @@ -1,3 +1,6 @@ +NOTE: These instructions are out of date! +The supported method for building Windows binaries is described in BUILD-WINDOWS.txt. + 1 Requirements 1.1 Operating system diff --git a/BUILD-WINDOWS.txt b/BUILD-WINDOWS.txt new file mode 100644 index 0000000..cba1a6f --- /dev/null +++ b/BUILD-WINDOWS.txt @@ -0,0 +1,17 @@ +This describes the supported build method for building for Windows. + +Build can only be done on Linux and the Nix package manager must be installed first. +Install Nix from: http://nixos.org/nix/ + +Then you need to checkout a slignely patched version of the Nix packages collections. +This is needed because it has fixes enabling cross-compilation of NSPR and NSS to Windows. + +git clone -b cross-mingw-nss --single-branch https://github.com/ambrop72/nixpkgs + +It may be faster to download a zip from Github: https://github.com/ambrop72/nixpkgs/archive/cross-mingw-nss.zip + +Then you can build with the following command from the badvpn source directory: + +NIX_PATH=nixpkgs=<path-to-nixpkgs> nix-build build-win32.nix -A badvpnPkgs.badvpn -o <output-link-path> + +Upon success the chosen <output-link-path> will be a symlink to a directory with the build outputs. diff --git a/badvpn-win32.nix b/badvpn-win32.nix index b6719f7..f5e3e4f 100644 --- a/badvpn-win32.nix +++ b/badvpn-win32.nix @@ -1,30 +1,51 @@ -{ stdenv, cmake, pkgconfig, openssl, nspr, nss, debug ? false }: -let - compileFlags = "-O3 ${stdenv.lib.optionalString (!debug) "-DNDEBUG"}"; -in -stdenv.mkDerivation { - name = "badvpn"; +{ stdenv, cmake, pkgconfig, openssl, nspr, nss, zlib, sqlite, zip, debug ? false }: + +rec { + badvpn = ( + 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.dev}/include/nspr -I${nss.crossDrv.dev}/include/nss -ggdb"; + NIX_CFLAGS_LINK = ["-ggdb"]; + + preConfigure = '' + cmakeFlagsArray=( "-DCMAKE_BUILD_TYPE=" "-DCMAKE_C_FLAGS=${compileFlags}" "-DCMAKE_SYSTEM_NAME=Windows" ); + ''; + + postInstall = '' + for lib in eay32; do + cp ${openssl.crossDrv.bin}/bin/lib$lib.dll $out/bin/ + done + for lib in nspr4 plc4 plds4; do + cp ${nspr.crossDrv.out}/lib/lib$lib.dll $out/bin/ + done + for lib in nss3 nssutil3 smime3 ssl3 softokn3 freebl3; do + cp ${nss.crossDrv.out}/lib/$lib.dll $out/bin/ + done + cp ${zlib.crossDrv.out}/bin/zlib1.dll $out/bin/ + cp ${sqlite.crossDrv.out}/bin/libsqlite3-0.dll $out/bin/ + _linkDLLs() { true; } + ''; + + dontCrossStrip = true; + }).crossDrv; - 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 - ''; + badvpnZip = stdenv.mkDerivation { + name = "badvpn.zip"; + unpackPhase = "true"; + nativeBuildInputs = [ zip ]; + installPhase = '' + mkdir badvpn-win32 + ln -s ${badvpn}/bin badvpn-win32/bin + zip -q -r $out badvpn-win32 + ''; + }; } diff --git a/build-win32.nix b/build-win32.nix index e701fe1..1609d74 100644 --- a/build-win32.nix +++ b/build-win32.nix @@ -21,12 +21,8 @@ in rec { inherit pkgs; - drvs = rec { - badvpnFunc = import ./badvpn-win32.nix; - badvpn = pkgs.callPackage badvpnFunc {}; - badvpnDebug = pkgs.callPackage badvpnFunc { debug = true; }; - }; + badvpnPkgsFunc = import ./badvpn-win32.nix; - badvpn = drvs.badvpn.crossDrv; - badvpnDebug = drvs.badvpnDebug.crossDrv; + badvpnPkgs = pkgs.callPackage badvpnPkgsFunc {}; + badvpnDebugPkgs = pkgs.callPackage badvpnPkgsFunc { debug = true; }; } |