1{ lib
2, stdenv
3, fetchFromGitLab
4, cmake
5, libsodium
6, json_c
7, ncurses
8, libxml2
9, jq
10}:
11
12stdenv.mkDerivation rec {
13 pname = "spectre-cli";
14 version = "unstable-2022-02-05";
15
16 src = fetchFromGitLab {
17 owner = "spectre.app";
18 repo = "cli";
19 rev = "a5e7aab28f44b90e5bd1204126339a81f64942d2";
20 sha256 = "1hp4l1rhg7bzgx0hcai08rvcy6l9645sfngy2cr96l1bpypcld5i";
21 fetchSubmodules = true;
22 };
23
24 nativeBuildInputs = [
25 cmake
26 libxml2
27 jq
28 ];
29
30 buildInputs = [
31 libsodium
32 json_c
33 ncurses
34 ];
35
36 cmakeFlags = [
37 "-DBUILD_SPECTRE_TESTS=ON"
38 ];
39
40 preConfigure = ''
41 echo "${version}" > VERSION
42
43 # The default buildPhase wants to create a ´build´ dir so we rename the build script to stop conflicts.
44 mv build build.sh
45 '';
46
47 # Some tests are expected to fail on ARM64
48 # See: https://gitlab.com/spectre.app/cli/-/issues/27#note_962950844
49 doCheck = !(stdenv.isLinux && stdenv.isAarch64);
50
51 checkPhase = ''
52 mv ../spectre-cli-tests ../spectre_tests.xml ./
53 patchShebangs spectre-cli-tests
54 export HOME=$(mktemp -d)
55
56 ./spectre-tests
57 ./spectre-cli-tests
58 '';
59
60 installPhase = ''
61 mkdir -p $out/bin
62 mv spectre $out/bin
63 '';
64
65 meta = with lib; {
66 description = "A stateless cryptographic identity algorithm";
67 homepage = "https://spectre.app";
68 license = licenses.gpl3Plus;
69 maintainers = with maintainers; [ emmabastas ];
70 mainProgram = "spectre";
71 platforms = platforms.all;
72 };
73}