openvpn: make systemd dependency optional

systemd is a fairly large dependency, and it doesn't appear to
be necessary in all circumstances - e.g. when openvpn is
not run as a systemd service (as is usually the case when it is
run in a Docker container).

This change makes the dependency on systemd optional, controlled
by a new argument `useSystemd`. The default behaviour remains
the same as it was before this change: enabled only on Linux systems.

For me, this change reduces the size of my container image (dominated
by the closure of openvpn) from about 110 MB to 45 MB.

Version 2: rename argument to `useSystemd` (was `systemdSupport`), and
rebase onto master

+6 -3
+6 -3
pkgs/tools/networking/openvpn/default.nix
··· 1 - { stdenv, fetchurl, iproute, lzo, openssl, pam, systemd, pkgconfig 2 , pkcs11Support ? false, pkcs11helper ? null, 3 }: 4 5 assert pkcs11Support -> (pkcs11helper != null); 6 7 with stdenv.lib; ··· 17 18 nativeBuildInputs = [ pkgconfig ]; 19 buildInputs = [ lzo openssl ] 20 - ++ optionals stdenv.isLinux [ pam systemd iproute ] 21 ++ optional pkcs11Support pkcs11helper; 22 23 configureFlags = optionals stdenv.isLinux [ 24 - "--enable-systemd" 25 "--enable-iproute2" 26 "IPROUTE=${iproute}/sbin/ip" ] 27 ++ optional pkcs11Support "--enable-pkcs11" 28 ++ optional stdenv.isDarwin "--disable-plugin-auth-pam"; 29
··· 1 + { stdenv, fetchurl, iproute, lzo, openssl, pam, pkgconfig 2 + , useSystemd ? stdenv.isLinux, systemd ? null 3 , pkcs11Support ? false, pkcs11helper ? null, 4 }: 5 6 + assert useSystemd -> (systemd != null); 7 assert pkcs11Support -> (pkcs11helper != null); 8 9 with stdenv.lib; ··· 19 20 nativeBuildInputs = [ pkgconfig ]; 21 buildInputs = [ lzo openssl ] 22 + ++ optionals stdenv.isLinux [ pam iproute ] 23 + ++ optional useSystemd systemd 24 ++ optional pkcs11Support pkcs11helper; 25 26 configureFlags = optionals stdenv.isLinux [ 27 "--enable-iproute2" 28 "IPROUTE=${iproute}/sbin/ip" ] 29 + ++ optional useSystemd "--enable-systemd" 30 ++ optional pkcs11Support "--enable-pkcs11" 31 ++ optional stdenv.isDarwin "--disable-plugin-auth-pam"; 32