summaryrefslogtreecommitdiffstats
path: root/pkgs/tools/networking/openvpn/update-systemd-resolved.nix
blob: a39e6db754c3eba0fb849a82940fb4389fac21a0 (plain)
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
{
  lib,
  stdenv,
  fetchFromGitHub,
  iproute2,
  runtimeShell,
  systemd,
  coreutils,
  util-linux,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "update-systemd-resolved";
  # when updating this, check if additional binaries need injecting into PATH
  version = "1.3.0";

  src = fetchFromGitHub {
    owner = "jonathanio";
    repo = "update-systemd-resolved";
    tag = "v${finalAttrs.version}";
    hash = "sha256-lYJTR3oBmpENcqNHa9PFXsw7ly6agwjBWf4UXf1d8Kc=";
  };

  # set SCRIPT_NAME in case we are wrapped and inject PATH
  patches = [
    ./update-systemd-resolved.patch
  ];

  env.PREFIX = "${placeholder "out"}/libexec/openvpn";

  postInstall = ''
    substituteInPlace ${finalAttrs.env.PREFIX}/update-systemd-resolved \
      --subst-var-by PATH ${
        lib.makeBinPath [
          coreutils
          iproute2
          runtimeShell
          systemd
          util-linux
        ]
      }
  '';

  meta = {
    description = "Helper script for OpenVPN to directly update the DNS settings of a link through systemd-resolved via DBus";
    homepage = "https://github.com/jonathanio/update-systemd-resolved";
    license = lib.licenses.gpl3Only;
    maintainers = with lib.maintainers; [ eadwu ];
    platforms = lib.platforms.linux;
  };
})