2022-04-15 01:41:22 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2020-11-24 20:58:05 +00:00
|
|
|
, fetchurl
|
|
|
|
, pkg-config
|
2021-04-05 15:23:46 +00:00
|
|
|
, iproute2
|
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
|
2022-04-15 01:41:22 +00:00
|
|
|
inherit (lib) versionOlder optional optionals optionalString;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
generic = { version, sha256, extraBuildInputs ? [ ] }:
|
2020-11-24 20:58:05 +00:00
|
|
|
let
|
2022-01-19 23:45:15 +00:00
|
|
|
withIpRoute = stdenv.isLinux && (versionOlder version "2.5.4");
|
2020-11-24 20:58:05 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation
|
|
|
|
rec {
|
|
|
|
pname = "openvpn";
|
|
|
|
inherit version;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-11-24 20:58:05 +00:00
|
|
|
src = fetchurl {
|
2022-03-30 09:31:56 +00:00
|
|
|
url = "https://swupdate.openvpn.net/community/releases/${pname}-${version}.tar.gz";
|
2020-11-24 20:58:05 +00:00
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
|
2022-04-15 01:41:22 +00:00
|
|
|
nativeBuildInputs = [ pkg-config ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-01-02 11:29:13 +00:00
|
|
|
buildInputs = [ lz4 lzo ]
|
|
|
|
++ optionals stdenv.isLinux [ libcap_ng libnl pam ]
|
2021-04-05 15:23:46 +00:00
|
|
|
++ optional withIpRoute iproute2
|
2020-11-24 20:58:05 +00:00
|
|
|
++ optional useSystemd systemd
|
2022-09-14 18:05:37 +00:00
|
|
|
++ optional pkcs11Support pkcs11helper
|
|
|
|
++ extraBuildInputs;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-11-24 20:58:05 +00:00
|
|
|
configureFlags = optionals withIpRoute [
|
|
|
|
"--enable-iproute2"
|
2021-04-05 15:23:46 +00:00
|
|
|
"IPROUTE=${iproute2}/sbin/ip"
|
2020-11-24 20:58:05 +00:00
|
|
|
]
|
|
|
|
++ optional useSystemd "--enable-systemd"
|
|
|
|
++ optional pkcs11Support "--enable-pkcs11"
|
|
|
|
++ optional stdenv.isDarwin "--disable-plugin-auth-pam";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-04-15 01:41:22 +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.
|
2020-11-24 20:58:05 +00:00
|
|
|
postInstall = ''
|
|
|
|
mkdir -p $out/share/doc/openvpn/examples
|
2022-04-15 01:41:22 +00:00
|
|
|
cp -r sample/sample-{config-files,keys,scripts}/ $out/share/doc/openvpn/examples
|
2020-11-24 20:58:05 +00:00
|
|
|
'' + optionalString useSystemd ''
|
2022-04-15 01:41:22 +00:00
|
|
|
install -Dm555 -t $out/libexec ${update-systemd-resolved}/libexec/openvpn/*
|
2020-11-24 20:58:05 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-11-24 20:58:05 +00:00
|
|
|
enableParallelBuilding = true;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-11-24 20:58:05 +00:00
|
|
|
description = "A robust and highly flexible tunneling application";
|
2024-01-25 14:12:00 +00:00
|
|
|
mainProgram = "openvpn";
|
2020-11-24 20:58:05 +00:00
|
|
|
downloadPage = "https://openvpn.net/community-downloads/";
|
|
|
|
homepage = "https://openvpn.net/";
|
2022-04-15 01:41:22 +00:00
|
|
|
license = licenses.gpl2Only;
|
2020-11-24 20:58:05 +00:00
|
|
|
maintainers = with maintainers; [ viric peterhoeg ];
|
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
{
|
2024-01-02 11:29:13 +00:00
|
|
|
openvpn = (generic {
|
|
|
|
version = "2.6.8";
|
|
|
|
sha256 = "sha256-Xt4VZcim2IAQD38jUxen7p7qg9UFLbVUfxOp52r3gF0=";
|
2022-09-14 18:05:37 +00:00
|
|
|
extraBuildInputs = [ openssl ];
|
2024-01-02 11:29:13 +00:00
|
|
|
}).overrideAttrs
|
|
|
|
(_: {
|
|
|
|
passthru.tests = {
|
|
|
|
inherit (nixosTests) initrd-network-openvpn systemd-initrd-networkd-openvpn;
|
|
|
|
};
|
|
|
|
});
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|