summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/l8/l8w8jwt/package.nix
blob: 27729aa7ba031617f239f24706c011986d0b8505 (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
{
  lib,
  stdenv,
  fetchFromCodeberg,
  cmake,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "l8w8jwt";
  version = "2.5.0";

  src = fetchFromCodeberg {
    owner = "GlitchedPolygons";
    repo = "l8w8jwt";
    tag = finalAttrs.version;
    fetchSubmodules = true;
    hash = "sha256-aR3r84AYvCNx3jm9lB1qtbbEh9rU3LTkI+TK9LPQaPk=";
  };

  patches = [
    # adapted from https://github.com/Mbed-TLS/mbedtls/commit/79b513894a28718604f7cb531380bfea0354844f
    ./fix-gcc15.patch
  ];

  nativeBuildInputs = [ cmake ];

  cmakeFlags = [
    "-DL8W8JWT_PACKAGE=On"
    (lib.cmakeBool "L8W8JWT_ENABLE_TESTS" finalAttrs.finalPackage.doCheck)
  ];

  # chillibuff header isn't installed correctly
  preConfigure = ''
    mv lib/chillbuff/include/chillbuff.h include/
  '';

  doCheck = true;
  checkPhase = ''
    runHook preCheck
    ./run_tests
    runHook postCheck
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p -m777 $out/include $out/lib64
    cp -pr $src/include/l8w8jwt $out/include
    cp -pr l8w8jwt/bin/release/libl8w8jwt.a $out/lib64

    runHook postInstall
  '';

  postPatch = ''
    substituteInPlace lib/chillbuff/CMakeLists.txt \
      --replace-fail "cmake_minimum_required(VERSION 3.1)" "cmake_minimum_required(VERSION 3.10)"
  '';

  meta = {
    description = "Minimal, OpenSSL-less and super lightweight JWT library written in C";
    homepage = "https://codeberg.org/GlitchedPolygons/l8w8jwt";
    changelog = "https://codeberg.org/GlitchedPolygons/l8w8jwt/releases/tag/${finalAttrs.version}";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ jherland ];
    platforms = lib.platforms.unix;
    broken = stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isAarch64;
  };
})