~ehmry/noiseprotocol

50b8fc61d4c91350f4f6a74bc8b034abb3f84459 — Emery Hemingway 8 months ago 5ac1063
Package noise-c in shell.nix
2 files changed, 33 insertions(+), 4 deletions(-)

A Tuprules.tup
M shell.nix
A Tuprules.tup => Tuprules.tup +1 -0
@@ 0,0 1,1 @@
NIM = $(DIRENV) $(NIM)

M shell.nix => shell.nix +32 -4
@@ 1,5 1,33 @@
let
  syndicate = builtins.getFlake "syndicate";
  pkgs =
    import <nixpkgs> { overlays = builtins.attrValues syndicate.overlays; };
in pkgs.nimPackages.noiseprotocol
  pkgs = import <nixpkgs> { };
  noise-c = with pkgs;
    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 ];
      };
    };

in pkgs.buildNimPackage {
  name = "noiseprotocol";
  buildInputs = [ noise-c ];
}