فهرست منبع

Add Nix expressions for cross-compiling to Windows.

Currently needs patched NixPkgs with fixed cross-compile of NSPR+NSS.
Ambroz Bizjak 9 سال پیش
والد
کامیت
aecd4bd419
2فایلهای تغییر یافته به همراه62 افزوده شده و 0 حذف شده
  1. 30 0
      badvpn-win32.nix
  2. 32 0
      build-win32.nix

+ 30 - 0
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
+    '';
+}

+ 32 - 0
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;
+}