summary refs log tree commit diff
path: root/pkgs/tools/networking
diff options
context:
space:
mode:
authorKier Davis <kierdavis@gmail.com>2018-01-02 17:28:15 +0000
committerKier Davis <kierdavis@gmail.com>2018-01-06 15:05:44 +0000
commit397daef20586ea21c0361546a1ad9414ebf329fb (patch)
tree56e2b721f269d6e9e539f7b876ff12180fc8ecc0 /pkgs/tools/networking
parentb067aa2cad70fa2541cd4e44b91488ae3222c3c5 (diff)
downloadnixlib-397daef20586ea21c0361546a1ad9414ebf329fb.tar
nixlib-397daef20586ea21c0361546a1ad9414ebf329fb.tar.gz
nixlib-397daef20586ea21c0361546a1ad9414ebf329fb.tar.bz2
nixlib-397daef20586ea21c0361546a1ad9414ebf329fb.tar.lz
nixlib-397daef20586ea21c0361546a1ad9414ebf329fb.tar.xz
nixlib-397daef20586ea21c0361546a1ad9414ebf329fb.tar.zst
nixlib-397daef20586ea21c0361546a1ad9414ebf329fb.zip
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
Diffstat (limited to 'pkgs/tools/networking')
-rw-r--r--pkgs/tools/networking/openvpn/default.nix9
1 files changed, 6 insertions, 3 deletions
diff --git a/pkgs/tools/networking/openvpn/default.nix b/pkgs/tools/networking/openvpn/default.nix
index ddcdfd31c260..272900e0e5b0 100644
--- a/pkgs/tools/networking/openvpn/default.nix
+++ b/pkgs/tools/networking/openvpn/default.nix
@@ -1,7 +1,9 @@
-{ stdenv, fetchurl, iproute, lzo, openssl, pam, systemd, pkgconfig
+{ stdenv, fetchurl, iproute, lzo, openssl, pam, pkgconfig
+, useSystemd ? stdenv.isLinux, systemd ? null
 , pkcs11Support ? false, pkcs11helper ? null,
 }:
 
+assert useSystemd -> (systemd != null);
 assert pkcs11Support -> (pkcs11helper != null);
 
 with stdenv.lib;
@@ -17,13 +19,14 @@ stdenv.mkDerivation rec {
 
   nativeBuildInputs = [ pkgconfig ];
   buildInputs = [ lzo openssl ]
-                  ++ optionals stdenv.isLinux [ pam systemd iproute ]
+                  ++ optionals stdenv.isLinux [ pam iproute ]
+                  ++ optional useSystemd systemd
                   ++ optional pkcs11Support pkcs11helper;
 
   configureFlags = optionals stdenv.isLinux [
-    "--enable-systemd"
     "--enable-iproute2"
     "IPROUTE=${iproute}/sbin/ip" ]
+    ++ optional useSystemd "--enable-systemd"
     ++ optional pkcs11Support "--enable-pkcs11"
     ++ optional stdenv.isDarwin "--disable-plugin-auth-pam";