1 { lib, stdenv, fetchFromGitHub
2 , pkg-config, autoreconfHook, perl, gperf, bison, flex
3 , gmp, python3, iptables, ldns, unbound, openssl, pcsclite, glib
7 , enableTNC ? false, trousers, sqlite, libxml2
8 , enableNetworkManager ? false, networkmanager
13 # Note on curl support: If curl is built with gnutls as its backend, the
14 # strongswan curl plugin may break.
15 # See https://wiki.strongswan.org/projects/strongswan/wiki/Curl for more info.
19 stdenv.mkDerivation rec {
21 version = "5.9.8"; # Make sure to also update <nixpkgs/nixos/modules/services/networking/strongswan-swanctl/swanctl-params.nix> when upgrading!
23 src = fetchFromGitHub {
27 sha256 = "sha256-RRvMQhDVoXF3Uok/Huq20RhqSsMnAsXHKOWfrXypDOk=";
32 nativeBuildInputs = [ pkg-config autoreconfHook perl gperf bison flex ];
34 [ curl gmp python3 ldns unbound openssl pcsclite ]
35 ++ optionals enableTNC [ trousers sqlite libxml2 ]
36 ++ optionals stdenv.isLinux [ systemd.dev pam iptables ]
37 ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ SystemConfiguration ])
38 ++ optionals enableNetworkManager [ networkmanager glib ];
42 ./firewall_defaults.patch
46 postPatch = optionalString stdenv.isLinux ''
47 # glibc-2.26 reorganized internal includes
48 sed '1i#include <stdint.h>' -i src/libstrongswan/utils/utils/memory.h
50 substituteInPlace src/libcharon/plugins/resolve/resolve_handler.c --replace "/sbin/resolvconf" "${openresolv}/sbin/resolvconf"
57 "--enable-eap-sim" "--enable-eap-sim-file" "--enable-eap-simaka-pseudonym"
58 "--enable-eap-simaka-reauth" "--enable-eap-identity" "--enable-eap-md5"
59 "--enable-eap-gtc" "--enable-eap-aka" "--enable-eap-aka-3gpp2"
60 "--enable-eap-mschapv2" "--enable-eap-radius" "--enable-xauth-eap" "--enable-ext-auth"
62 "--enable-pkcs11" "--enable-eap-sim-pcsc" "--enable-dnscert" "--enable-unbound"
65 ++ optionals stdenv.isLinux [
66 "--enable-farp" "--enable-dhcp"
67 "--enable-systemd" "--with-systemdsystemunitdir=${placeholder "out"}/etc/systemd/system"
72 ++ optionals stdenv.isx86_64 [ "--enable-aesni" "--enable-rdrand" ]
73 ++ optional (stdenv.hostPlatform.system == "i686-linux") "--enable-padlock"
74 ++ optionals enableTNC [
75 "--disable-gmp" "--disable-aes" "--disable-md5" "--disable-sha1" "--disable-sha2" "--disable-fips-prf"
76 "--enable-eap-tnc" "--enable-eap-ttls" "--enable-eap-dynamic" "--enable-tnccs-20"
77 "--enable-tnc-imc" "--enable-imc-os" "--enable-imc-attestation"
78 "--enable-tnc-imv" "--enable-imv-attestation"
79 "--enable-tnc-ifmap" "--enable-tnc-imc" "--enable-tnc-imv"
83 ++ optionals enableNetworkManager [
85 "--with-nm-ca-dir=/etc/ssl/certs" ]
86 # Taken from: https://wiki.strongswan.org/projects/strongswan/wiki/MacOSX
87 ++ optionals stdenv.isDarwin [
90 "--disable-kernel-netlink"
91 "--enable-kernel-pfkey"
92 "--enable-kernel-pfroute"
93 "--enable-kernel-libipsec"
99 # this is needed for l2tp
100 echo "include /etc/ipsec.secrets" >> $out/etc/ipsec.secrets
103 NIX_LDFLAGS = optionalString stdenv.cc.isGNU "-lgcc_s" ;
105 passthru.tests = { inherit (nixosTests) strongswan-swanctl; };
108 description = "OpenSource IPsec-based VPN Solution";
109 homepage = "https://www.strongswan.org";
110 license = licenses.gpl2Plus;
111 platforms = platforms.all;