about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/networking/namespaced-openvpn/default.nix
blob: abcf006b76415f4da6a762aaff9bc3a39c734ded (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
{ lib,
  fetchFromGitHub,
  buildPythonPackage,
  openvpn,
  iproute2,
  iptables,
  util-linux
}:

buildPythonPackage rec {
  pname = "namespaced-openvpn";
  version = "0.6.0";
  format = "other";

  src = fetchFromGitHub {
    owner = "slingamn";
    repo = pname;
    rev = "a3fa42b2d8645272cbeb6856e26a7ea9547cb7d1";
    sha256 = "+Fdaw9EGyFGH9/DSeVJczS8gPzAOv+qn+1U20zQBBqQ=";
  };

  buildInputs = [ openvpn iproute2 util-linux ];

  postPatch = ''
    substituteInPlace namespaced-openvpn \
      --replace-fail "/usr/sbin/openvpn" "${openvpn}/bin/openvpn" \
      --replace-fail "/sbin/ip" "${iproute2}/bin/ip" \
      --replace-fail "/usr/bin/nsenter" "${util-linux}/bin/nsenter" \
      --replace-fail "/bin/mount" "${util-linux}/bin/mount" \
      --replace-fail "/bin/umount" "${util-linux}/bin/umount"

    substituteInPlace seal-unseal-gateway \
      --replace-fail "/sbin/iptables" "${iptables}/bin/iptables"
  '';

  dontBuild = true;
  doCheck = false;

  installPhase = ''
    mkdir -p $out/bin
    cp namespaced-openvpn seal-unseal-gateway $out/bin
  '';

  meta = with lib; {
    homepage = "https://github.com/slingamn/namespaced-openvpn";
    description = "Network namespace isolation for OpenVPN tunnels.";
    license = licenses.mit;
    maintainers = [ maintainers.lodi ];
    platforms = platforms.linux;
    mainProgram = "namespaced-openvpn";
  };
}