2021-01-11 07:54:33 +00:00
|
|
|
{ lib, stdenv
|
2020-11-06 14:19:57 +00:00
|
|
|
, fetchurl
|
|
|
|
, pkg-config
|
|
|
|
, makeWrapper
|
|
|
|
, runtimeShell
|
2021-03-14 16:05:16 +00:00
|
|
|
, iproute2
|
2020-11-06 14:19:57 +00:00
|
|
|
, lzo
|
|
|
|
, openssl
|
|
|
|
, pam
|
|
|
|
, useSystemd ? stdenv.isLinux
|
2021-03-15 01:13:27 +00:00
|
|
|
, systemd
|
|
|
|
, util-linux
|
2020-11-06 14:19:57 +00:00
|
|
|
, pkcs11Support ? false
|
2021-03-15 01:13:27 +00:00
|
|
|
, pkcs11helper
|
2016-09-16 04:22:25 +01:00
|
|
|
}:
|
|
|
|
|
2021-01-15 09:19:50 +00:00
|
|
|
with lib;
|
2019-04-02 14:38:57 +01:00
|
|
|
let
|
2020-05-21 10:24:47 +01:00
|
|
|
# Check if the script needs to have other binaries wrapped when changing this.
|
2019-04-02 14:38:57 +01:00
|
|
|
update-resolved = fetchurl {
|
2020-05-21 10:24:47 +01:00
|
|
|
url = "https://raw.githubusercontent.com/jonathanio/update-systemd-resolved/v1.3.0/update-systemd-resolved";
|
|
|
|
sha256 = "021qzv1k0zxgv1rmyfpqj3zlzqr28xa7zff1n7vrbjk36ijylpsc";
|
2019-04-02 14:38:57 +01:00
|
|
|
};
|
|
|
|
|
2020-11-06 14:19:57 +00:00
|
|
|
generic = { version, sha256 }:
|
|
|
|
let
|
2022-01-08 17:56:01 +00:00
|
|
|
withIpRoute = stdenv.isLinux && (versionOlder version "2.5.4");
|
2020-11-06 14:19:57 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation
|
|
|
|
rec {
|
|
|
|
pname = "openvpn";
|
|
|
|
inherit version;
|
2009-04-06 14:07:18 +01:00
|
|
|
|
2020-11-06 14:19:57 +00:00
|
|
|
src = fetchurl {
|
2022-03-17 13:28:52 +00:00
|
|
|
url = "https://swupdate.openvpn.net/community/releases/${pname}-${version}.tar.gz";
|
2020-11-06 14:19:57 +00:00
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper pkg-config ];
|
2009-04-06 14:07:18 +01:00
|
|
|
|
2020-11-06 14:19:57 +00:00
|
|
|
buildInputs = [ lzo openssl ]
|
|
|
|
++ optional stdenv.isLinux pam
|
2021-03-14 16:05:16 +00:00
|
|
|
++ optional withIpRoute iproute2
|
2020-11-06 14:19:57 +00:00
|
|
|
++ optional useSystemd systemd
|
|
|
|
++ optional pkcs11Support pkcs11helper;
|
2019-04-02 14:38:57 +01:00
|
|
|
|
2020-11-06 14:19:57 +00:00
|
|
|
configureFlags = optionals withIpRoute [
|
|
|
|
"--enable-iproute2"
|
2021-03-14 16:05:16 +00:00
|
|
|
"IPROUTE=${iproute2}/sbin/ip"
|
2020-11-06 14:19:57 +00:00
|
|
|
]
|
|
|
|
++ optional useSystemd "--enable-systemd"
|
|
|
|
++ optional pkcs11Support "--enable-pkcs11"
|
|
|
|
++ optional stdenv.isDarwin "--disable-plugin-auth-pam";
|
2016-09-16 04:22:25 +01:00
|
|
|
|
2020-11-06 14:19:57 +00:00
|
|
|
postInstall = ''
|
|
|
|
mkdir -p $out/share/doc/openvpn/examples
|
|
|
|
cp -r sample/sample-config-files/ $out/share/doc/openvpn/examples
|
|
|
|
cp -r sample/sample-keys/ $out/share/doc/openvpn/examples
|
|
|
|
cp -r sample/sample-scripts/ $out/share/doc/openvpn/examples
|
|
|
|
'' + optionalString useSystemd ''
|
|
|
|
install -Dm555 ${update-resolved} $out/libexec/update-systemd-resolved
|
|
|
|
wrapProgram $out/libexec/update-systemd-resolved \
|
2021-03-14 16:05:16 +00:00
|
|
|
--prefix PATH : ${makeBinPath [ runtimeShell iproute2 systemd util-linux ]}
|
2020-11-06 14:19:57 +00:00
|
|
|
'';
|
2013-05-28 13:47:23 +01:00
|
|
|
|
2020-11-06 14:19:57 +00:00
|
|
|
enableParallelBuilding = true;
|
2012-04-02 23:05:02 +01:00
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2020-11-06 14:19:57 +00:00
|
|
|
description = "A robust and highly flexible tunneling application";
|
|
|
|
downloadPage = "https://openvpn.net/community-downloads/";
|
|
|
|
homepage = "https://openvpn.net/";
|
|
|
|
license = licenses.gpl2;
|
|
|
|
maintainers = with maintainers; [ viric peterhoeg ];
|
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
{
|
|
|
|
openvpn_24 = generic {
|
2022-03-17 21:47:40 +00:00
|
|
|
version = "2.4.12";
|
|
|
|
sha256 = "1vjx82nlkxrgzfiwvmmlnz8ids5m2fiqz7scy1smh3j9jnf2v5b6";
|
2020-11-06 14:19:57 +00:00
|
|
|
};
|
2013-05-28 13:47:23 +01:00
|
|
|
|
2020-11-06 14:19:57 +00:00
|
|
|
openvpn = generic {
|
2022-03-17 13:28:52 +00:00
|
|
|
version = "2.5.6";
|
|
|
|
sha256 = "0gdd88rcan9vfiwkzsqn6fxxdim7kb1bsxrcra59c5xksprpwfik";
|
2009-04-06 14:07:18 +01:00
|
|
|
};
|
|
|
|
}
|