1{
2 lib,
3 stdenv,
4 fetchgit,
5 coreutils,
6 gawk,
7 gnugrep,
8 iproute2,
9 makeWrapper,
10 net-tools,
11 openresolv,
12 systemd,
13 withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd,
14}:
15
16stdenv.mkDerivation {
17 pname = "vpnc-scripts";
18 version = "unstable-2023-01-03";
19
20 src = fetchgit {
21 url = "https://gitlab.com/openconnect/vpnc-scripts.git";
22 rev = "22756827315bc875303190abb3756b5b1dd147ce";
23 hash = "sha256-EWrDyXg47Ur9mFutaG8+oYOCAW9AZowzwwJp3YbogIY=";
24 };
25
26 nativeBuildInputs = [ makeWrapper ];
27
28 installPhase = ''
29 mkdir -p $out/bin
30 cp vpnc-script $out/bin
31 '';
32
33 preFixup = ''
34 substituteInPlace $out/bin/vpnc-script \
35 --replace "which" "type -P"
36 ''
37 + lib.optionalString stdenv.hostPlatform.isLinux ''
38 substituteInPlace $out/bin/vpnc-script \
39 --replace "/sbin/resolvconf" "${openresolv}/bin/resolvconf"
40 ''
41 + lib.optionalString withSystemd ''
42 substituteInPlace $out/bin/vpnc-script \
43 --replace "/usr/bin/resolvectl" "${systemd}/bin/resolvectl"
44 ''
45 + ''
46 wrapProgram $out/bin/vpnc-script \
47 --prefix PATH : "${
48 lib.makeBinPath (
49 [
50 net-tools
51 gawk
52 coreutils
53 gnugrep
54 ]
55 ++ lib.optionals stdenv.hostPlatform.isLinux [
56 openresolv
57 iproute2
58 ]
59 )
60 }"
61 '';
62
63 meta = with lib; {
64 homepage = "https://www.infradead.org/openconnect/";
65 description = "Script for vpnc to configure the network routing and name service";
66 mainProgram = "vpnc-script";
67 license = licenses.gpl2Only;
68 maintainers = with maintainers; [ jerith666 ];
69 platforms = platforms.linux ++ platforms.darwin;
70 };
71}