nixpkgs/pkgs/tools/networking/stunnel/default.nix
Sheldon Neuberger 446e0752e9 stunnel: fix compilation on darwin
stunnel 5.65 has a build error on darwin: `client.c:1514:11: error: use
of undeclared identifier 'environ'`. I think darwin is unique in that it
has unistd but doesn't define `environ`. I tested the resulting binary
for my stunnel use-case and it works on x86-darwin.

Introduced in:
f6d7bf0315

Failing build: https://hydra.nixos.org/build/187400018
2022-09-03 16:22:54 -07:00

52 lines
1.4 KiB
Nix

{ lib, stdenv, fetchurl, fetchpatch, openssl, nixosTests }:
stdenv.mkDerivation rec {
pname = "stunnel";
version = "5.65";
src = fetchurl {
url = "https://www.stunnel.org/downloads/${pname}-${version}.tar.gz";
sha256 = "60c500063bd1feff2877f5726e38278c086f96c178f03f09d264a2012d6bf7fc";
# please use the contents of "https://www.stunnel.org/downloads/stunnel-${version}.tar.gz.sha256",
# not the output of `nix-prefetch-url`
};
patches = [
# Fixes compilation on darwin, patch is from
# https://github.com/mtrojnar/stunnel/pull/15.
(fetchpatch {
name = "stunnel_darwin_environ.patch";
url = "https://github.com/mtrojnar/stunnel/commit/d41932f6d55f639cc921007c2e180a55ef88bf00.patch";
sha256 = "sha256-d2K/BHE6GxvDCBIbttCHEVwH9SCu0jggNvhVHkC/qto=";
})
];
buildInputs = [ openssl ];
configureFlags = [
"--with-ssl=${openssl.dev}"
"--sysconfdir=/etc"
"--localstatedir=/var"
];
postInstall = ''
# remove legacy compatibility-wrapper that would require perl
rm $out/bin/stunnel3
'';
installFlags = [
"sysconfdir=\${out}/etc"
"localstatedir=\${TMPDIR}"
];
passthru.tests = {
stunnel = nixosTests.stunnel;
};
meta = {
description = "Universal tls/ssl wrapper";
homepage = "https://www.stunnel.org/";
license = lib.licenses.gpl2Plus;
platforms = lib.platforms.unix;
maintainers = [ lib.maintainers.thoughtpolice ];
};
}