Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{
2 lib,
3 stdenv,
4 fetchFromSourcehut,
5 makeBinaryWrapper,
6 curlMinimal,
7 mandoc,
8 ncurses,
9 nim,
10 pandoc,
11 pkg-config,
12 brotli,
13 zlib,
14 gitUpdater,
15 versionCheckHook,
16}:
17
18stdenv.mkDerivation (finalAttrs: {
19 pname = "chawan";
20 version = "0.2.2";
21
22 src = fetchFromSourcehut {
23 owner = "~bptato";
24 repo = "chawan";
25 rev = "v${finalAttrs.version}";
26 hash = "sha256-pUwwqFvTtLAGFQG62W90hEH+yPN+ifa5BDRYNh/Jupg=";
27 };
28
29 patches = [ ./mancha-augment-path.diff ];
30
31 # Include chawan's man pages in mancha's search path
32 postPatch = ''
33 # As we need the $out reference, we can't use `replaceVars` here.
34 substituteInPlace adapter/protocol/man.nim \
35 --replace-fail '@out@' "$out"
36 '';
37
38 env.NIX_CFLAGS_COMPILE = toString (
39 lib.optional stdenv.cc.isClang "-Wno-error=implicit-function-declaration"
40 );
41
42 nativeBuildInputs = [
43 makeBinaryWrapper
44 nim
45 pandoc
46 pkg-config
47 brotli
48 ];
49
50 buildInputs = [
51 curlMinimal
52 ncurses
53 zlib
54 ];
55
56 buildFlags = [
57 "all"
58 "manpage"
59 ];
60 installFlags = [
61 "DESTDIR=$(out)"
62 "PREFIX=/"
63 ];
64
65 postInstall =
66 let
67 makeWrapperArgs = ''
68 --set MANCHA_CHA $out/bin/cha \
69 --set MANCHA_MAN ${mandoc}/bin/man
70 '';
71 in
72 ''
73 wrapProgram $out/bin/cha ${makeWrapperArgs}
74 wrapProgram $out/bin/mancha ${makeWrapperArgs}
75 '';
76
77 nativeInstallCheckInputs = [
78 versionCheckHook
79 ];
80 doInstallCheck = true;
81 versionCheckProgramArg = "--version";
82
83 passthru.updateScript = gitUpdater { rev-prefix = "v"; };
84
85 meta = {
86 description = "Lightweight and featureful terminal web browser";
87 homepage = "https://sr.ht/~bptato/chawan/";
88 changelog = "https://git.sr.ht/~bptato/chawan/refs/v${finalAttrs.version}";
89 license = lib.licenses.unlicense;
90 platforms = lib.platforms.unix;
91 maintainers = with lib.maintainers; [ ];
92 mainProgram = "cha";
93 };
94})