Profpatsch/third_party/overlays/sam/pkgs/by-name/noise-c/package.nix
 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
{ lib
, stdenv
, fetchFromGitHub
, autoreconfHook
}:

stdenv.mkDerivation rec {
  pname = "noise-c";
  version = "20230309";
  outputs = [
    "bin"
    "out"
  ];
  src = fetchFromGitHub {
    owner = "rweather";
    repo = pname;
    rev = "ffa626bddd1f8182e47c634af686108ca5049e56";
    hash = "sha256-HkcyV/WT4UNFWczbZZIDW2fWRliQb8IEykv2d7bZM7w=";
  };

  nativeBuildInputs = [ autoreconfHook ];

  # excise protobuf bloat
  prePatch = ''
    substituteInPlace tools/Makefile.am \
      --replace 'SUBDIRS = keytool protoc' 'SUBDIRS = keytool'
  '';

  meta = src.meta // {
    description = "Plain C implementation of the Noise Protocol";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ ehmry ];
  };
}