Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openvpn: cleanup unnecessary generic function #281785

Merged
merged 1 commit into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 40 additions & 63 deletions pkgs/tools/networking/openvpn/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
, stdenv
, fetchurl
, pkg-config
, iproute2
, libcap_ng
, libnl
, lz4
Expand All @@ -18,73 +17,51 @@
}:

let
inherit (lib) versionOlder optional optionals optionalString;

generic = { version, sha256, extraBuildInputs ? [ ] }:
let
withIpRoute = stdenv.isLinux && (versionOlder version "2.5.4");
in
stdenv.mkDerivation
rec {
pname = "openvpn";
inherit version;
inherit (lib) optional optionals optionalString;
in
stdenv.mkDerivation (finalAttrs: {
pname = "openvpn";
version = "2.6.8";

src = fetchurl {
url = "https://swupdate.openvpn.net/community/releases/${pname}-${version}.tar.gz";
inherit sha256;
};
src = fetchurl {
url = "https://swupdate.openvpn.net/community/releases/openvpn-${finalAttrs.version}.tar.gz";
hash = "sha256-Xt4VZcim2IAQD38jUxen7p7qg9UFLbVUfxOp52r3gF0=";
};

nativeBuildInputs = [ pkg-config ];
nativeBuildInputs = [ pkg-config ];

buildInputs = [ lz4 lzo ]
++ optionals stdenv.isLinux [ libcap_ng libnl pam ]
++ optional withIpRoute iproute2
++ optional useSystemd systemd
++ optional pkcs11Support pkcs11helper
++ extraBuildInputs;
buildInputs = [ lz4 lzo openssl ]
++ optionals stdenv.isLinux [ libcap_ng libnl pam ]
++ optional useSystemd systemd
++ optional pkcs11Support pkcs11helper;

configureFlags = optionals withIpRoute [
"--enable-iproute2"
"IPROUTE=${iproute2}/sbin/ip"
]
++ optional useSystemd "--enable-systemd"
++ optional pkcs11Support "--enable-pkcs11"
++ optional stdenv.isDarwin "--disable-plugin-auth-pam";
configureFlags = optional useSystemd "--enable-systemd"
++ optional pkcs11Support "--enable-pkcs11"
++ optional stdenv.isDarwin "--disable-plugin-auth-pam";

# 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/*
'';
# 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/*
'';

enableParallelBuilding = true;
enableParallelBuilding = true;

meta = with lib; {
description = "A robust and highly flexible tunneling application";
mainProgram = "openvpn";
downloadPage = "https://openvpn.net/community-downloads/";
homepage = "https://openvpn.net/";
license = licenses.gpl2Only;
maintainers = with maintainers; [ viric peterhoeg ];
platforms = platforms.unix;
};
};
passthru.tests = {
inherit (nixosTests) initrd-network-openvpn systemd-initrd-networkd-openvpn;
};

in
{
openvpn = (generic {
version = "2.6.8";
sha256 = "sha256-Xt4VZcim2IAQD38jUxen7p7qg9UFLbVUfxOp52r3gF0=";
extraBuildInputs = [ openssl ];
}).overrideAttrs
(_: {
passthru.tests = {
inherit (nixosTests) initrd-network-openvpn systemd-initrd-networkd-openvpn;
};
});
}
meta = with lib; {
description = "A robust and highly flexible tunneling application";
downloadPage = "https://openvpn.net/community-downloads/";
homepage = "https://openvpn.net/";
license = licenses.gpl2Only;
maintainers = with maintainers; [ viric peterhoeg ];
platforms = platforms.unix;
};
})
3 changes: 1 addition & 2 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11669,8 +11669,7 @@ with pkgs;

opentsdb = callPackage ../tools/misc/opentsdb { };

inherit (callPackages ../tools/networking/openvpn {})
openvpn;
openvpn = callPackage ../tools/networking/openvpn {};

openvpn3 = callPackage ../tools/networking/openvpn3 { };

Expand Down
Loading