nixpkgs/pkgs/tools/networking/openvpn/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

81 lines
2.4 KiB
Nix
Raw Normal View History

{ lib
, stdenv
2020-11-06 14:19:57 +00:00
, fetchurl
, pkg-config
2021-03-14 16:05:16 +00:00
, iproute2
2020-11-06 14:19:57 +00:00
, lzo
, openssl
, pam
, useSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
2021-03-15 01:13:27 +00:00
, systemd
, update-systemd-resolved
2020-11-06 14:19:57 +00:00
, pkcs11Support ? false
2021-03-15 01:13:27 +00:00
, pkcs11helper
2016-09-16 03:22:25 +00:00
}:
let
inherit (lib) versionOlder optional optionals optionalString;
generic = { version, sha256, extraBuildInputs ? [] }:
2020-11-06 14:19:57 +00:00
let
withIpRoute = stdenv.isLinux && (versionOlder version "2.5.4");
2020-11-06 14:19:57 +00:00
in
stdenv.mkDerivation
rec {
pname = "openvpn";
inherit version;
2020-11-06 14:19:57 +00:00
src = fetchurl {
url = "https://swupdate.openvpn.net/community/releases/${pname}-${version}.tar.gz";
2020-11-06 14:19:57 +00:00
inherit sha256;
};
nativeBuildInputs = [ pkg-config ];
buildInputs = [ lzo ]
2020-11-06 14:19:57 +00:00
++ 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
++ extraBuildInputs;
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 03:22:25 +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-06 14:19:57 +00:00
postInstall = ''
mkdir -p $out/share/doc/openvpn/examples
cp -r sample/sample-{config-files,keys,scripts}/ $out/share/doc/openvpn/examples
2020-11-06 14:19:57 +00:00
'' + optionalString useSystemd ''
install -Dm555 -t $out/libexec ${update-systemd-resolved}/libexec/openvpn/*
2020-11-06 14:19:57 +00:00
'';
2013-05-28 12:47:23 +00:00
2020-11-06 14:19:57 +00:00
enableParallelBuilding = true;
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.gpl2Only;
2020-11-06 14:19:57 +00:00
maintainers = with maintainers; [ viric peterhoeg ];
platforms = platforms.unix;
};
};
in
{
openvpn = generic {
2022-11-01 08:14:23 +00:00
version = "2.5.8";
sha256 = "1cixqm4gn2d1v8qkbww75j30fzvxz13gc7whcmz54i0x4fvibwx6";
extraBuildInputs = [ openssl ];
};
}