From f4033eeeafc0c180a45c9e17b9577e6ce2c93681 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Wed, 18 May 2022 08:12:51 -0400 Subject: [PATCH 1/3] go: Fix build when targetting MinGW --- pkgs/development/compilers/go/1.17.nix | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkgs/development/compilers/go/1.17.nix b/pkgs/development/compilers/go/1.17.nix index 1483660d1ec..2c673b7dd4e 100644 --- a/pkgs/development/compilers/go/1.17.nix +++ b/pkgs/development/compilers/go/1.17.nix @@ -18,8 +18,12 @@ , buildPackages , pkgsBuildTarget , callPackage +, threadsCross ? null # for MinGW }: +# threadsCross is just for MinGW +assert threadsCross != null -> stdenv.targetPlatform.isWindows; + let go_bootstrap = buildPackages.callPackage ./bootstrap.nix { }; @@ -50,6 +54,8 @@ let # We need a target compiler which is still runnable at build time, # to handle the cross-building case where build != host == target targetCC = pkgsBuildTarget.targetPackages.stdenv.cc; + + isCross = stdenv.buildPlatform != stdenv.targetPlatform; in stdenv.mkDerivation rec { @@ -71,6 +77,10 @@ stdenv.mkDerivation rec { depsTargetTargetPropagated = lib.optionals stdenv.isDarwin [ Security Foundation ]; + depsBuildTarget = lib.optional isCross targetCC; + + depsTargetTarget = lib.optional (threadsCross != null) threadsCross; + hardeningDisable = [ "all" ]; prePatch = '' @@ -194,12 +204,12 @@ stdenv.mkDerivation rec { # {CC,CXX}_FOR_TARGET must be only set for cross compilation case as go expect those # to be different from CC/CXX CC_FOR_TARGET = - if (stdenv.buildPlatform != stdenv.targetPlatform) then + if isCross then "${targetCC}/bin/${targetCC.targetPrefix}cc" else null; CXX_FOR_TARGET = - if (stdenv.buildPlatform != stdenv.targetPlatform) then + if isCross then "${targetCC}/bin/${targetCC.targetPrefix}c++" else null; @@ -223,7 +233,7 @@ stdenv.mkDerivation rec { export PATH=$(pwd)/bin:$PATH - ${lib.optionalString (stdenv.buildPlatform != stdenv.targetPlatform) '' + ${lib.optionalString isCross '' # Independent from host/target, CC should produce code for the building system. # We only set it when cross-compiling. export CC=${buildPackages.stdenv.cc}/bin/cc From 5726b8faec7e5d1cbb08debd26f8ea0063f33abe Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Wed, 18 May 2022 08:13:11 -0400 Subject: [PATCH 2/3] go_1_18: Fix build when targetting MinGW --- pkgs/development/compilers/go/1.18.nix | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pkgs/development/compilers/go/1.18.nix b/pkgs/development/compilers/go/1.18.nix index aad9c27fc56..48ca47321cd 100644 --- a/pkgs/development/compilers/go/1.18.nix +++ b/pkgs/development/compilers/go/1.18.nix @@ -18,8 +18,12 @@ , buildPackages , pkgsBuildTarget , callPackage +, threadsCross ? null # for MinGW }: +# threadsCross is just for MinGW +assert threadsCross != null -> stdenv.targetPlatform.isWindows; + let go_bootstrap = buildPackages.callPackage ./bootstrap.nix { }; @@ -50,6 +54,8 @@ let # We need a target compiler which is still runnable at build time, # to handle the cross-building case where build != host == target targetCC = pkgsBuildTarget.targetPackages.stdenv.cc; + + isCross = stdenv.buildPlatform != stdenv.targetPlatform; in stdenv.mkDerivation rec { @@ -71,6 +77,10 @@ stdenv.mkDerivation rec { depsTargetTargetPropagated = lib.optionals stdenv.isDarwin [ Security Foundation ]; + depsBuildTarget = lib.optional isCross targetCC; + + depsTargetTarget = lib.optional (threadsCross != null) threadsCross; + hardeningDisable = [ "all" ]; prePatch = '' @@ -188,12 +198,12 @@ stdenv.mkDerivation rec { # {CC,CXX}_FOR_TARGET must be only set for cross compilation case as go expect those # to be different from CC/CXX CC_FOR_TARGET = - if (stdenv.buildPlatform != stdenv.targetPlatform) then + if isCross then "${targetCC}/bin/${targetCC.targetPrefix}cc" else null; CXX_FOR_TARGET = - if (stdenv.buildPlatform != stdenv.targetPlatform) then + if isCross then "${targetCC}/bin/${targetCC.targetPrefix}c++" else null; @@ -217,7 +227,7 @@ stdenv.mkDerivation rec { export PATH=$(pwd)/bin:$PATH - ${lib.optionalString (stdenv.buildPlatform != stdenv.targetPlatform) '' + ${lib.optionalString isCross '' # Independent from host/target, CC should produce code for the building system. # We only set it when cross-compiling. export CC=${buildPackages.stdenv.cc}/bin/cc From 121a26897fa38c709197987c3eb82836463726c8 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Wed, 18 May 2022 08:15:04 -0400 Subject: [PATCH 3/3] npiperelay: init at 0.1.0 --- pkgs/os-specific/windows/default.nix | 2 ++ .../windows/npiperelay/default.nix | 23 +++++++++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 pkgs/os-specific/windows/npiperelay/default.nix diff --git a/pkgs/os-specific/windows/default.nix b/pkgs/os-specific/windows/default.nix index 15e3d7f89ab..c34f97a17db 100644 --- a/pkgs/os-specific/windows/default.nix +++ b/pkgs/os-specific/windows/default.nix @@ -37,6 +37,8 @@ lib.makeScope newScope (self: with self; { stdenv = crossThreadsStdenv; }; + npiperelay = callPackage ./npiperelay { }; + pthreads = callPackage ./pthread-w32 { }; wxMSW = callPackage ./wxMSW-2.8 { }; diff --git a/pkgs/os-specific/windows/npiperelay/default.nix b/pkgs/os-specific/windows/npiperelay/default.nix new file mode 100644 index 00000000000..edc83a27e55 --- /dev/null +++ b/pkgs/os-specific/windows/npiperelay/default.nix @@ -0,0 +1,23 @@ +{ lib, buildGoModule, fetchFromGitHub }: + +buildGoModule rec { + pname = "npiperelay"; + version = "0.1.0"; + + src = fetchFromGitHub { + owner = "jstarks"; + repo = "npiperelay"; + rev = "v${version}"; + sha256 = "sha256-cg4aZmpTysc8m1euxIO2XPv8OMnBk1DwhFcuIFHF/1o="; + }; + + vendorSha256 = null; + + meta = { + description = "Access Windows named pipes from WSL"; + homepage = "https://github.com/jstarks/npiperelay"; + license = lib.licenses.mit; + maintainers = [ lib.maintainers.shlevy ]; + platforms = lib.platforms.windows; + }; +}