11 , useSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
13 , update-systemd-resolved
14 , pkcs11Support ? false
20 inherit (lib) optional optionals optionalString;
22 stdenv.mkDerivation (finalAttrs: {
27 url = "https://swupdate.openvpn.net/community/releases/openvpn-${finalAttrs.version}.tar.gz";
28 hash = "sha256-HGEP3etobjTxNnw0fgJ+QY4HUjoQ9NjOSiwq8vYaGSk=";
31 nativeBuildInputs = [ pkg-config ];
33 buildInputs = [ lz4 lzo openssl ]
34 ++ optionals stdenv.hostPlatform.isLinux [ libcap_ng libnl pam ]
35 ++ optional useSystemd systemd
36 ++ optional pkcs11Support pkcs11helper;
38 configureFlags = optional useSystemd "--enable-systemd"
39 ++ optional pkcs11Support "--enable-pkcs11"
40 ++ optional stdenv.hostPlatform.isDarwin "--disable-plugin-auth-pam";
42 # We used to vendor the update-systemd-resolved script inside libexec,
43 # but a separate package was made, that uses libexec/openvpn. Copy it
44 # into libexec in case any consumers expect it to be there even though
45 # they should use the update-systemd-resolved package instead.
47 mkdir -p $out/share/doc/openvpn/examples
48 cp -r sample/sample-{config-files,keys,scripts}/ $out/share/doc/openvpn/examples
49 '' + optionalString useSystemd ''
50 install -Dm555 -t $out/libexec ${update-systemd-resolved}/libexec/openvpn/*
53 enableParallelBuilding = true;
56 inherit (nixosTests) initrd-network-openvpn systemd-initrd-networkd-openvpn;
60 description = "Robust and highly flexible tunneling application";
61 downloadPage = "https://openvpn.net/community-downloads/";
62 homepage = "https://openvpn.net/";
63 license = licenses.gpl2Only;
64 maintainers = with maintainers; [ peterhoeg ];
65 platforms = platforms.unix;
66 mainProgram = "openvpn";