summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/nm/nmtrust/package.nix
blob: a36a40c8c6f0be354ba77e451809ce4f00bab5ab (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{
  lib,
  stdenv,
  fetchFromGitHub,
  makeWrapper,
  nixosTests,
  shellcheck,
  bash,
  systemd,
  coreutils,
  gawk,
  util-linux,
}:

stdenv.mkDerivation {
  pname = "nmtrust";
  version = "0.1.1";

  strictDeps = true;
  __structuredAttrs = true;

  src = fetchFromGitHub {
    owner = "brett";
    repo = "nmtrust-nix";
    rev = "v0.1.1";
    hash = "sha256-niCbYxeunNxfkM/HEUiMAvwiholR0nmEPqssOOl9Qvo=";
  };

  nativeBuildInputs = [ makeWrapper ];
  nativeCheckInputs = [ shellcheck ];

  doCheck = true;
  checkPhase = ''
    runHook preCheck
    shellcheck nmtrust.sh
    runHook postCheck
  '';

  installPhase = ''
    runHook preInstall
    install -Dm755 nmtrust.sh $out/bin/nmtrust
    wrapProgram $out/bin/nmtrust \
      --prefix PATH : ${
        lib.makeBinPath [
          bash
          systemd
          coreutils
          gawk
          util-linux
        ]
      }
    runHook postInstall
  '';

  passthru.tests = { inherit (nixosTests) nmtrust; };

  meta = {
    description = "Declarative network trust management for NixOS";
    longDescription = ''
      nmtrust evaluates the trust state of active NetworkManager connections
      and activates corresponding systemd targets. Services bound to these
      targets start and stop automatically as you move between trusted,
      untrusted, and offline networks.

      A NixOS-native reimplementation of nmtrust by Peter Hogg (pigmonkey).
    '';
    homepage = "https://github.com/brett/nmtrust-nix";
    license = lib.licenses.unlicense;
    maintainers = [ lib.maintainers.brett ];
    mainProgram = "nmtrust";
    platforms = lib.platforms.linux;
  };
}