e0464e4788
In preparation for the deprecation of `stdenv.isX`. These shorthands are not conducive to cross-compilation because they hide the platforms. Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way One example of why this is bad and especially affects compiler packages https://www.github.com/NixOS/nixpkgs/pull/343059 There are too many files to go through manually but a treewide should get users thinking when they see a `hostPlatform.isX` in a place where it doesn't make sense. ``` fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is" fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is" fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is" ```
69 lines
2.0 KiB
Nix
69 lines
2.0 KiB
Nix
{ lib
|
|
, stdenv
|
|
, fetchurl
|
|
, pkg-config
|
|
, libcap_ng
|
|
, libnl
|
|
, lz4
|
|
, lzo
|
|
, openssl
|
|
, pam
|
|
, useSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
|
|
, systemd
|
|
, update-systemd-resolved
|
|
, pkcs11Support ? false
|
|
, pkcs11helper
|
|
, nixosTests
|
|
}:
|
|
|
|
let
|
|
inherit (lib) optional optionals optionalString;
|
|
in
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
pname = "openvpn";
|
|
version = "2.6.12";
|
|
|
|
src = fetchurl {
|
|
url = "https://swupdate.openvpn.net/community/releases/openvpn-${finalAttrs.version}.tar.gz";
|
|
hash = "sha256-HGEP3etobjTxNnw0fgJ+QY4HUjoQ9NjOSiwq8vYaGSk=";
|
|
};
|
|
|
|
nativeBuildInputs = [ pkg-config ];
|
|
|
|
buildInputs = [ lz4 lzo openssl ]
|
|
++ optionals stdenv.hostPlatform.isLinux [ libcap_ng libnl pam ]
|
|
++ optional useSystemd systemd
|
|
++ optional pkcs11Support pkcs11helper;
|
|
|
|
configureFlags = optional useSystemd "--enable-systemd"
|
|
++ optional pkcs11Support "--enable-pkcs11"
|
|
++ optional stdenv.hostPlatform.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/*
|
|
'';
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
passthru.tests = {
|
|
inherit (nixosTests) initrd-network-openvpn systemd-initrd-networkd-openvpn;
|
|
};
|
|
|
|
meta = with lib; {
|
|
description = "Robust and highly flexible tunneling application";
|
|
downloadPage = "https://openvpn.net/community-downloads/";
|
|
homepage = "https://openvpn.net/";
|
|
license = licenses.gpl2Only;
|
|
maintainers = with maintainers; [ peterhoeg ];
|
|
platforms = platforms.unix;
|
|
mainProgram = "openvpn";
|
|
};
|
|
})
|