git.iko.soy/typeable/nixpkgs
on master help sign in
strongswan: Make it build on macOS

Original expression could not be built on macOS due to using dependencies to Linux only packages. This change fixes that by grouping the dependencies based on the suitable system. In addition, it uses `configure` flags recommended by the project for building on macOS, as well the ones used by Homebrew.

commit1609f860f58b0543044797b427f56498f3b481b5 authorNikola Knezevic <nikola@knezevic.ch> dateWed 6 Mar 2019, 15:14 (8 years ago) parent931ee3e
1 file changed+32−12
pkgs/tools/networking/strongswan/default.nix+32−12
pkgs/tools/networking/strongswan/default.nix+32−12
@@ -8,6 +8,7 @@
88, enableTNC ? false, trousers, sqlite, libxml2
99, enableNetworkManager ? false, networkmanager
1010, libpcap
11+, darwin
1112}:
1213
1314# Note on curl support: If curl is built with gnutls as its backend, the
@@ -29,9 +30,10 @@ stdenv.mkDerivation rec {
2930
3031 nativeBuildInputs = [ pkgconfig autoreconfHook ];
3132 buildInputs =
32− [ curl gmp python iptables ldns unbound openssl pcsclite ]
33+ [ curl gmp python ldns unbound openssl pcsclite ]
3334 ++ optionals enableTNC [ trousers sqlite libxml2 ]
34− ++ optionals stdenv.isLinux [ systemd.dev pam ]
35+ ++ optionals stdenv.isLinux [ systemd.dev pam iptables ]
36+ ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ SystemConfiguration ])
3537 ++ optionals enableNetworkManager [ networkmanager ]
3638 # ad-hoc fix for https://github.com/NixOS/nixpkgs/pull/51787
3739 # Remove when the above PR lands in master
@@ -41,23 +43,24 @@ stdenv.mkDerivation rec {
4143 ./ext_auth-path.patch
4244 ./firewall_defaults.patch
4345 ./updown-path.patch
44− (substituteAll {
46+ (optional stdenv.isLinux (substituteAll {
4547 src = ./modprobe-path.patch;
4648 inherit kmod;
47− })
49+ }))
4850 ];
4951
5052 postPatch = ''
51− substituteInPlace src/libcharon/plugins/resolve/resolve_handler.c --replace "/sbin/resolvconf" "${openresolv}/sbin/resolvconf"
52−
5353 # swanctl can be configured by files in SWANCTLDIR which defaults to
5454 # $out/etc/swanctl. Since that directory is in the nix store users can't
5555 # modify it. Ideally swanctl accepts a command line option for specifying
5656 # the configuration files. In the absence of that we patch swanctl to look
5757 # for configuration files in /etc/swanctl.
5858 substituteInPlace src/swanctl/swanctl.h --replace "SWANCTLDIR" "\"/etc/swanctl\""
59+ '' + optionalString stdenv.isLinux ''
5960 # glibc-2.26 reorganized internal includes
6061 sed '1i#include <stdint.h>' -i src/libstrongswan/utils/utils/memory.h
62+
63+ substituteInPlace src/libcharon/plugins/resolve/resolve_handler.c --replace "/sbin/resolvconf" "${openresolv}/sbin/resolvconf"
6164 '';
6265
6366 preConfigure = ''
@@ -65,17 +68,24 @@ stdenv.mkDerivation rec {
6568 '';
6669
6770 configureFlags =
68− [ "--enable-swanctl" "--enable-cmd" "--enable-systemd"
69− "--enable-farp" "--enable-dhcp"
71+ [ "--enable-swanctl"
72+ "--enable-cmd"
7073 "--enable-openssl"
7174 "--enable-eap-sim" "--enable-eap-sim-file" "--enable-eap-simaka-pseudonym"
7275 "--enable-eap-simaka-reauth" "--enable-eap-identity" "--enable-eap-md5"
7376 "--enable-eap-gtc" "--enable-eap-aka" "--enable-eap-aka-3gpp2"
7477 "--enable-eap-mschapv2" "--enable-eap-radius" "--enable-xauth-eap" "--enable-ext-auth"
75− "--enable-forecast" "--enable-connmark" "--enable-acert"
78+ "--enable-acert"
7679 "--enable-pkcs11" "--enable-eap-sim-pcsc" "--enable-dnscert" "--enable-unbound"
77− "--enable-af-alg" "--enable-xauth-pam" "--enable-chapoly"
80+ "--enable-chapoly"
7881 "--enable-curl" ]
82+ ++ optionals stdenv.isLinux [
83+ "--enable-farp" "--enable-dhcp"
84+ "--enable-systemd"
85+ "--enable-xauth-pam"
86+ "--enable-forecast"
87+ "--enable-connmark"
88+ "--enable-af-alg" ]
7989 ++ optionals stdenv.isx86_64 [ "--enable-aesni" "--enable-rdrand" ]
8090 ++ optional (stdenv.hostPlatform.system == "i686-linux") "--enable-padlock"
8191 ++ optionals enableTNC [
@@ -89,7 +99,17 @@ stdenv.mkDerivation rec {
8999 "--enable-sqlite" ]
90100 ++ optionals enableNetworkManager [
91101 "--enable-nm"
92− "--with-nm-ca-dir=/etc/ssl/certs"
102+ "--with-nm-ca-dir=/etc/ssl/certs" ]
103+ # Taken from: https://wiki.strongswan.org/projects/strongswan/wiki/MacOSX
104+ ++ optionals stdenv.isDarwin [
105+ "--disable-systemd"
106+ "--disable-xauth-pam"
107+ "--disable-kernel-netlink"
108+ "--enable-kernel-pfkey"
109+ "--enable-kernel-pfroute"
110+ "--enable-kernel-libipsec"
111+ "--enable-osx-attr"
112+ "--disable-scripts"
93113 ];
94114
95115 postInstall = ''
@@ -97,7 +117,7 @@ stdenv.mkDerivation rec {
97117 echo "include /etc/ipsec.secrets" >> $out/etc/ipsec.secrets
98118 '';
99119
100− NIX_LDFLAGS = "-lgcc_s" ;
120+ NIX_LDFLAGS = optionalString stdenv.cc.isGNU "-lgcc_s" ;
101121
102122 meta = {
103123 description = "OpenSource IPsec-based VPN Solution";