summary refs log tree commit diff
path: root/pkgs/tools/networking/vpnc/default.nix
blob: 9e8f27b62bc31a5a8a4cc8294ac822dc0668fbe5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
{ lib, stdenv, fetchFromGitHub, fetchpatch, buildPackages
, makeWrapper, pkg-config, perl
, gawk, gnutls, libgcrypt, openresolv, vpnc-scripts
, opensslSupport ? false, openssl # Distributing this is a GPL violation.
}:

stdenv.mkDerivation {
  pname = "vpnc-unstable";
  version = "2021-01-31";

  src = fetchFromGitHub {
    owner = "streambinder";
    repo = "vpnc";
    rev = "43780cecd7a61668002f73b6f8b9f9ba61af74ad";
    sha256 = "1sbnvp8117qiklc5xghdhx2i310p5wgjgjg7dr6xj48i167ks1zv";
    fetchSubmodules = true;
  };

  patches = [
    # Use pkg-config to find libgcrypt, fixing cross.
    (fetchpatch {
      url = "https://github.com/streambinder/vpnc/commit/f1efcfc9824944370de2fc4ac46dc4292ddbecea.patch";
      sha256 = "13kxp2147q4jz98p5qqmj32mg15lb02jdz5j4lfjgvlmbz133q4h";
    })
    # Don't do networking during build.
    (fetchpatch {
      url = "https://github.com/streambinder/vpnc/commit/9f4e3ab1f51c8c5ff27b8290f5a533a87d85c011.patch";
      sha256 = "1h029954q9qy2kcrj6dzprgrjvr12lk96yy8dgva9nr4ghidy18a";
    })
  ];

  nativeBuildInputs = [ makeWrapper perl ]
    ++ lib.optional (!opensslSupport) pkg-config;
  buildInputs = [ libgcrypt perl ]
    ++ (if opensslSupport then [ openssl ] else [ gnutls ]);

  makeFlags = [
    "PREFIX=$(out)"
    "ETCDIR=$(out)/etc/vpnc"
    "SCRIPT_PATH=${vpnc-scripts}/bin/vpnc-script"
  ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
    "VPNC=${buildPackages.vpnc}/bin/vpnc"
  ] ++ lib.optional opensslSupport "OPENSSL_GPL_VIOLATION=yes";

  postPatch = ''
    patchShebangs src/makeman.pl
  '';

  meta = with lib; {
    homepage = "https://davidepucci.it/doc/vpnc/";
    description = "Virtual private network (VPN) client for Cisco's VPN concentrators";
    license = if opensslSupport then licenses.unfree else licenses.gpl2Plus;
    platforms = platforms.linux;
  };
}