2022-04-15 01:41:22 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2020-11-24 20:58:05 +00:00
|
|
|
, fetchurl
|
|
|
|
, pkg-config
|
2024-01-02 11:29:13 +00:00
|
|
|
, libcap_ng
|
|
|
|
, libnl
|
|
|
|
, lz4
|
2020-11-24 20:58:05 +00:00
|
|
|
, lzo
|
|
|
|
, openssl
|
|
|
|
, pam
|
2023-02-02 18:25:31 +00:00
|
|
|
, useSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
|
2021-03-19 17:17:44 +00:00
|
|
|
, systemd
|
2022-04-15 01:41:22 +00:00
|
|
|
, update-systemd-resolved
|
2020-11-24 20:58:05 +00:00
|
|
|
, pkcs11Support ? false
|
2021-03-19 17:17:44 +00:00
|
|
|
, pkcs11helper
|
2024-01-02 11:29:13 +00:00
|
|
|
, nixosTests
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2024-02-07 01:22:34 +00:00
|
|
|
inherit (lib) optional optionals optionalString;
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
|
|
pname = "openvpn";
|
2024-09-19 14:19:46 +00:00
|
|
|
version = "2.6.12";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-02-07 01:22:34 +00:00
|
|
|
src = fetchurl {
|
|
|
|
url = "https://swupdate.openvpn.net/community/releases/openvpn-${finalAttrs.version}.tar.gz";
|
2024-09-19 14:19:46 +00:00
|
|
|
hash = "sha256-HGEP3etobjTxNnw0fgJ+QY4HUjoQ9NjOSiwq8vYaGSk=";
|
2024-02-07 01:22:34 +00:00
|
|
|
};
|
2020-11-24 20:58:05 +00:00
|
|
|
|
2024-02-07 01:22:34 +00:00
|
|
|
nativeBuildInputs = [ pkg-config ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-02-07 01:22:34 +00:00
|
|
|
buildInputs = [ lz4 lzo openssl ]
|
2024-09-26 11:04:55 +00:00
|
|
|
++ optionals stdenv.hostPlatform.isLinux [ libcap_ng libnl pam ]
|
2024-02-07 01:22:34 +00:00
|
|
|
++ optional useSystemd systemd
|
|
|
|
++ optional pkcs11Support pkcs11helper;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-02-07 01:22:34 +00:00
|
|
|
configureFlags = optional useSystemd "--enable-systemd"
|
|
|
|
++ optional pkcs11Support "--enable-pkcs11"
|
2024-09-26 11:04:55 +00:00
|
|
|
++ optional stdenv.hostPlatform.isDarwin "--disable-plugin-auth-pam";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-02-07 01:22:34 +00:00
|
|
|
# We used to vendor the update-systemd-resolved script inside libexec,
|
|
|
|
# but a separate package was made, that uses libexec/openvpn. Copy it
|
|
|
|
# into libexec in case any consumers expect it to be there even though
|
|
|
|
# they should use the update-systemd-resolved package instead.
|
|
|
|
postInstall = ''
|
|
|
|
mkdir -p $out/share/doc/openvpn/examples
|
|
|
|
cp -r sample/sample-{config-files,keys,scripts}/ $out/share/doc/openvpn/examples
|
|
|
|
'' + optionalString useSystemd ''
|
|
|
|
install -Dm555 -t $out/libexec ${update-systemd-resolved}/libexec/openvpn/*
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-02-07 01:22:34 +00:00
|
|
|
enableParallelBuilding = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-02-07 01:22:34 +00:00
|
|
|
passthru.tests = {
|
|
|
|
inherit (nixosTests) initrd-network-openvpn systemd-initrd-networkd-openvpn;
|
|
|
|
};
|
2020-11-24 20:58:05 +00:00
|
|
|
|
2024-02-07 01:22:34 +00:00
|
|
|
meta = with lib; {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Robust and highly flexible tunneling application";
|
2024-02-07 01:22:34 +00:00
|
|
|
downloadPage = "https://openvpn.net/community-downloads/";
|
|
|
|
homepage = "https://openvpn.net/";
|
|
|
|
license = licenses.gpl2Only;
|
2024-07-31 10:19:44 +00:00
|
|
|
maintainers = with maintainers; [ peterhoeg ];
|
2024-02-07 01:22:34 +00:00
|
|
|
platforms = platforms.unix;
|
2024-02-29 20:09:43 +00:00
|
|
|
mainProgram = "openvpn";
|
2024-02-07 01:22:34 +00:00
|
|
|
};
|
|
|
|
})
|