2021-12-06 16:07:01 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub
|
2021-08-05 21:33:18 +00:00
|
|
|
, pkg-config, autoreconfHook, perl, gperf, bison, flex
|
2020-04-24 23:36:52 +00:00
|
|
|
, gmp, python3, iptables, ldns, unbound, openssl, pcsclite, glib
|
|
|
|
, openresolv
|
|
|
|
, systemd, pam
|
|
|
|
, curl
|
|
|
|
, enableTNC ? false, trousers, sqlite, libxml2
|
|
|
|
, enableNetworkManager ? false, networkmanager
|
|
|
|
, darwin
|
2022-01-26 04:04:25 +00:00
|
|
|
, nixosTests
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "strongswan";
|
2024-01-13 08:15:51 +00:00
|
|
|
version = "5.9.13"; # Make sure to also update <nixpkgs/nixos/modules/services/networking/strongswan-swanctl/swanctl-params.nix> when upgrading!
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-08-05 21:33:18 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "strongswan";
|
|
|
|
repo = "strongswan";
|
|
|
|
rev = version;
|
2024-01-13 08:15:51 +00:00
|
|
|
hash = "sha256-uI7Ibdx6I+gd83KJ24ERmpJSMNIbsk10PszdLxpcXcQ=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
dontPatchELF = true;
|
|
|
|
|
2021-08-05 21:33:18 +00:00
|
|
|
nativeBuildInputs = [ pkg-config autoreconfHook perl gperf bison flex ];
|
2020-04-24 23:36:52 +00:00
|
|
|
buildInputs =
|
|
|
|
[ curl gmp python3 ldns unbound openssl pcsclite ]
|
2023-02-02 18:25:31 +00:00
|
|
|
++ lib.optionals enableTNC [ trousers sqlite libxml2 ]
|
|
|
|
++ lib.optionals stdenv.isLinux [ systemd.dev pam iptables ]
|
|
|
|
++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ SystemConfiguration ])
|
|
|
|
++ lib.optionals enableNetworkManager [ networkmanager glib ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
patches = [
|
|
|
|
./ext_auth-path.patch
|
|
|
|
./firewall_defaults.patch
|
|
|
|
./updown-path.patch
|
|
|
|
];
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
postPatch = lib.optionalString stdenv.isLinux ''
|
2020-04-24 23:36:52 +00:00
|
|
|
# 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"
|
|
|
|
'';
|
|
|
|
|
|
|
|
configureFlags =
|
|
|
|
[ "--enable-swanctl"
|
|
|
|
"--enable-cmd"
|
|
|
|
"--enable-openssl"
|
|
|
|
"--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"
|
|
|
|
"--enable-pkcs11" "--enable-eap-sim-pcsc" "--enable-dnscert" "--enable-unbound"
|
|
|
|
"--enable-chapoly"
|
|
|
|
"--enable-curl" ]
|
2023-02-02 18:25:31 +00:00
|
|
|
++ lib.optionals stdenv.isLinux [
|
2020-04-24 23:36:52 +00:00
|
|
|
"--enable-farp" "--enable-dhcp"
|
|
|
|
"--enable-systemd" "--with-systemdsystemunitdir=${placeholder "out"}/etc/systemd/system"
|
|
|
|
"--enable-xauth-pam"
|
|
|
|
"--enable-forecast"
|
|
|
|
"--enable-connmark"
|
|
|
|
"--enable-af-alg" ]
|
2023-02-02 18:25:31 +00:00
|
|
|
++ lib.optionals stdenv.isx86_64 [ "--enable-aesni" "--enable-rdrand" ]
|
|
|
|
++ lib.optional (stdenv.hostPlatform.system == "i686-linux") "--enable-padlock"
|
|
|
|
++ lib.optionals enableTNC [
|
2020-04-24 23:36:52 +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"
|
|
|
|
"--enable-tnc-ifmap" "--enable-tnc-imc" "--enable-tnc-imv"
|
|
|
|
"--with-tss=trousers"
|
|
|
|
"--enable-aikgen"
|
|
|
|
"--enable-sqlite" ]
|
2023-02-02 18:25:31 +00:00
|
|
|
++ lib.optionals enableNetworkManager [
|
2020-04-24 23:36:52 +00:00
|
|
|
"--enable-nm"
|
|
|
|
"--with-nm-ca-dir=/etc/ssl/certs" ]
|
|
|
|
# Taken from: https://wiki.strongswan.org/projects/strongswan/wiki/MacOSX
|
2023-02-02 18:25:31 +00:00
|
|
|
++ lib.optionals stdenv.isDarwin [
|
2020-04-24 23:36:52 +00:00
|
|
|
"--disable-systemd"
|
|
|
|
"--disable-xauth-pam"
|
|
|
|
"--disable-kernel-netlink"
|
|
|
|
"--enable-kernel-pfkey"
|
|
|
|
"--enable-kernel-pfroute"
|
|
|
|
"--enable-kernel-libipsec"
|
|
|
|
"--enable-osx-attr"
|
|
|
|
"--disable-scripts"
|
|
|
|
];
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
# this is needed for l2tp
|
|
|
|
echo "include /etc/ipsec.secrets" >> $out/etc/ipsec.secrets
|
|
|
|
'';
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
NIX_LDFLAGS = lib.optionalString stdenv.cc.isGNU "-lgcc_s" ;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-01-26 04:04:25 +00:00
|
|
|
passthru.tests = { inherit (nixosTests) strongswan-swanctl; };
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "OpenSource IPsec-based VPN Solution";
|
|
|
|
homepage = "https://www.strongswan.org";
|
|
|
|
license = licenses.gpl2Plus;
|
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
}
|