nixpkgs/pkgs/tools/networking/strongswan/default.nix

115 lines
4.1 KiB
Nix
Raw Normal View History

{ stdenv, fetchurl, fetchpatch
, pkgconfig, autoreconfHook
, gmp, python, iptables, ldns, unbound, openssl, pcsclite
, openresolv
, systemd, pam
, curl
, enableTNC ? false, trousers, sqlite, libxml2
, enableNetworkManager ? false, networkmanager
, darwin
}:
# Note on curl support: If curl is built with gnutls as its backend, the
# strongswan curl plugin may break.
# See https://wiki.strongswan.org/projects/strongswan/wiki/Curl for more info.
with stdenv.lib;
2014-09-16 18:10:37 +00:00
stdenv.mkDerivation rec {
pname = "strongswan";
2019-06-03 16:01:55 +00:00
version = "5.8.0"; # Make sure to also update <nixpkgs/nixos/modules/services/networking/strongswan-swanctl/swanctl-params.nix> when upgrading!
2014-09-16 18:10:37 +00:00
src = fetchurl {
url = "https://download.strongswan.org/${pname}-${version}.tar.bz2";
2019-06-03 16:01:55 +00:00
sha256 = "0cq9m86ydd2i0awxkv4a256f4926p2f9pzlisyskl9fngl6f3c8m";
2014-09-16 18:10:37 +00:00
};
dontPatchELF = true;
2017-07-19 21:46:49 +00:00
nativeBuildInputs = [ pkgconfig autoreconfHook ];
2015-08-03 14:59:33 +00:00
buildInputs =
[ curl gmp python ldns unbound openssl pcsclite ]
++ optionals enableTNC [ trousers sqlite libxml2 ]
++ optionals stdenv.isLinux [ systemd.dev pam iptables ]
++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ SystemConfiguration ])
++ optionals enableNetworkManager [ networkmanager ];
patches = [
2014-12-22 19:55:01 +00:00
./ext_auth-path.patch
./firewall_defaults.patch
2014-12-22 19:55:01 +00:00
./updown-path.patch
# Don't use etc/dbus-1/system.d
(fetchpatch {
url = "https://patch-diff.githubusercontent.com/raw/strongswan/strongswan/pull/150.patch";
sha256 = "1irfxb99blb8v3hs0kmlhzkkwbmds1p0gq319z8lmacz36cgyj2c";
})
];
2014-09-19 05:09:00 +00:00
2019-03-08 13:16:15 +00:00
postPatch = optionalString stdenv.isLinux ''
# glibc-2.26 reorganized internal includes
sed '1i#include <stdint.h>' -i src/libstrongswan/utils/utils/memory.h
substituteInPlace src/libcharon/plugins/resolve/resolve_handler.c --replace "/sbin/resolvconf" "${openresolv}/sbin/resolvconf"
2015-08-05 10:12:09 +00:00
'';
2015-08-03 14:59:33 +00:00
configureFlags =
[ "--enable-swanctl"
"--enable-cmd"
"--enable-openssl"
2015-08-04 17:16:27 +00:00
"--enable-eap-sim" "--enable-eap-sim-file" "--enable-eap-simaka-pseudonym"
"--enable-eap-simaka-reauth" "--enable-eap-identity" "--enable-eap-md5"
"--enable-eap-gtc" "--enable-eap-aka" "--enable-eap-aka-3gpp2"
"--enable-eap-mschapv2" "--enable-eap-radius" "--enable-xauth-eap" "--enable-ext-auth"
"--enable-acert"
2015-09-06 19:05:11 +00:00
"--enable-pkcs11" "--enable-eap-sim-pcsc" "--enable-dnscert" "--enable-unbound"
"--enable-chapoly"
"--enable-curl" ]
++ optionals stdenv.isLinux [
"--enable-farp" "--enable-dhcp"
"--enable-systemd" "--with-systemdsystemunitdir=${placeholder "out"}/etc/systemd/system"
"--enable-xauth-pam"
"--enable-forecast"
"--enable-connmark"
"--enable-af-alg" ]
++ optionals stdenv.isx86_64 [ "--enable-aesni" "--enable-rdrand" ]
++ optional (stdenv.hostPlatform.system == "i686-linux") "--enable-padlock"
++ optionals enableTNC [
2015-08-03 14:59:33 +00:00
"--disable-gmp" "--disable-aes" "--disable-md5" "--disable-sha1" "--disable-sha2" "--disable-fips-prf"
"--enable-eap-tnc" "--enable-eap-ttls" "--enable-eap-dynamic" "--enable-tnccs-20"
"--enable-tnc-imc" "--enable-imc-os" "--enable-imc-attestation"
"--enable-tnc-imv" "--enable-imv-attestation"
2015-08-04 17:16:27 +00:00
"--enable-tnc-ifmap" "--enable-tnc-imc" "--enable-tnc-imv"
2015-08-03 14:59:33 +00:00
"--with-tss=trousers"
"--enable-aikgen"
"--enable-sqlite" ]
++ optionals enableNetworkManager [
"--enable-nm"
"--with-nm-ca-dir=/etc/ssl/certs" ]
# Taken from: https://wiki.strongswan.org/projects/strongswan/wiki/MacOSX
++ optionals stdenv.isDarwin [
"--disable-systemd"
"--disable-xauth-pam"
"--disable-kernel-netlink"
"--enable-kernel-pfkey"
"--enable-kernel-pfroute"
"--enable-kernel-libipsec"
"--enable-osx-attr"
"--disable-scripts"
];
2014-09-16 18:10:37 +00:00
postInstall = ''
# this is needed for l2tp
echo "include /etc/ipsec.secrets" >> $out/etc/ipsec.secrets
'';
NIX_LDFLAGS = optionalString stdenv.cc.isGNU "-lgcc_s" ;
2014-09-16 18:10:37 +00:00
meta = {
description = "OpenSource IPsec-based VPN Solution";
homepage = https://www.strongswan.org;
license = licenses.gpl2Plus;
platforms = platforms.all;
2014-09-16 18:10:37 +00:00
};
}