summary refs log tree commit diff
path: root/pkgs/tools/networking/openssh
diff options
context:
space:
mode:
authorNiklas Hambüchen <mail@nh2.me>2020-12-09 00:39:56 +0100
committerGitHub <noreply@github.com>2020-12-09 00:39:56 +0100
commit87413f30a5d3b974dc381985cf901ea7757096b5 (patch)
treede74b1880dc333f6b8bb42f53bb01079f087cfb0 /pkgs/tools/networking/openssh
parent5ed8ad03ce86164c9bed6efc594f08b95a2afce7 (diff)
parent4879ea90342ea3afa4f301b3fab44a8ec3e7c3e7 (diff)
downloadnixpkgs-87413f30a5d3b974dc381985cf901ea7757096b5.tar
nixpkgs-87413f30a5d3b974dc381985cf901ea7757096b5.tar.gz
nixpkgs-87413f30a5d3b974dc381985cf901ea7757096b5.tar.bz2
nixpkgs-87413f30a5d3b974dc381985cf901ea7757096b5.tar.lz
nixpkgs-87413f30a5d3b974dc381985cf901ea7757096b5.tar.xz
nixpkgs-87413f30a5d3b974dc381985cf901ea7757096b5.tar.zst
nixpkgs-87413f30a5d3b974dc381985cf901ea7757096b5.zip
Merge pull request #100906 from KAction/openssh
openssh: fix static build
Diffstat (limited to 'pkgs/tools/networking/openssh')
-rw-r--r--pkgs/tools/networking/openssh/default.nix20
1 files changed, 19 insertions, 1 deletions
diff --git a/pkgs/tools/networking/openssh/default.nix b/pkgs/tools/networking/openssh/default.nix
index f8a518ca4dc..c9e75f39e9b 100644
--- a/pkgs/tools/networking/openssh/default.nix
+++ b/pkgs/tools/networking/openssh/default.nix
@@ -66,7 +66,9 @@ stdenv.mkDerivation rec {
       substituteInPlace Makefile.in --replace '$(INSTALL) -m 4711' '$(INSTALL) -m 0711'
     '';
 
-  nativeBuildInputs = [ pkgconfig ] ++ optional (hpnSupport || withGssapiPatches) autoreconfHook;
+  nativeBuildInputs = [ pkgconfig ]
+    ++ optional (hpnSupport || withGssapiPatches) autoreconfHook
+    ++ optional withKerberos kerberos.dev;
   buildInputs = [ zlib openssl libedit pam ]
     ++ optional withFIDO libfido2
     ++ optional withKerberos kerberos;
@@ -75,6 +77,22 @@ stdenv.mkDerivation rec {
     # Setting LD causes `configure' and `make' to disagree about which linker
     # to use: `configure' wants `gcc', but `make' wants `ld'.
     unset LD
+  ''
+  # Upstream build system does not support static build, so we fall back
+  # on fragile patching of configure script.
+  #
+  # libedit is found by pkgconfig, but without --static flag, required
+  # to get also transitive dependencies for static linkage, hence sed
+  # expression.
+  #
+  # Kerberos can be found either by krb5-config or by fall-back shell
+  # code in openssh's configure.ac. Neither of them support static
+  # build, but patching code for krb5-config is simpler, so to get it
+  # into PATH, kerberos.dev is added into buildInputs.
+  + optionalString stdenv.hostPlatform.isStatic ''
+    sed -i "s,PKGCONFIG --libs,PKGCONFIG --libs --static,g" configure
+    sed -i 's#KRB5CONF --libs`#KRB5CONF --libs` -lkrb5support -lkeyutils#g' configure
+    sed -i 's#KRB5CONF --libs gssapi`#KRB5CONF --libs gssapi` -lkrb5support -lkeyutils#g' configure
   '';
 
   # I set --disable-strip because later we strip anyway. And it fails to strip