1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 bmake,
6 cleanPackaging,
7}:
8
9stdenv.mkDerivation {
10 pname = "kgt";
11 version = "2023-06-03";
12
13 src = fetchFromGitHub {
14 owner = "katef";
15 repo = "kgt";
16 # 2023-06-03, no version tags (yet)
17 rev = "dc881796aa691f1fddb1d01ec77216b34fe8134d";
18 hash = "sha256-Az5995/eGUHFL1C1WAdgh1td3goHUYgzWFeVFz2zb8g=";
19 fetchSubmodules = true;
20 };
21
22 outputs = [
23 "bin"
24 "doc"
25 "out"
26 ];
27
28 nativeBuildInputs = [ bmake ];
29 enableParallelBuilding = true;
30
31 makeFlags = [
32 "-r"
33 "PREFIX=$(bin)"
34 ];
35
36 installPhase = ''
37 runHook preInstall
38
39 ${
40 cleanPackaging.commonFileActions {
41 docFiles = [
42 "README.md"
43 "LICENCE"
44 "examples"
45 # TODO: this is just a docbook file, not a mangpage yet
46 # https://github.com/katef/kgt/issues/50
47 "man"
48 "examples"
49 "doc"
50 ];
51 noiseFiles = [
52 "build/src"
53 "build/lib"
54 "Makefile"
55 "src/**/*.c"
56 "src/**/*.h"
57 "src/**/Makefile"
58 "src/**/lexer.lx"
59 "src/**/parser.sid"
60 "src/**/parser.act"
61 "share/git"
62 "share/css"
63 "share/xsl"
64 ".gitignore"
65 ".gitmodules"
66 ".gitattributes"
67 ".github"
68 ];
69 }
70 } $doc/share/doc/kgt
71
72 install -Dm755 build/bin/kgt $bin/bin/kgt
73 rm build/bin/kgt
74
75 runHook postInstall
76 '';
77
78 postFixup = ''
79 ${cleanPackaging.checkForRemainingFiles}
80 '';
81
82 meta = with lib; {
83 description = "BNF wrangling and railroad diagrams";
84 mainProgram = "kgt";
85 longDescription = ''
86 KGT: Kate's Grammar Tool
87
88 Input: Various BNF-like syntaxes
89 Output: Various BNF-like syntaxes, AST dumps, and Railroad Syntax Diagrams
90 '';
91 homepage = "https://github.com/katef/kgt";
92 license = licenses.bsd2;
93 platforms = platforms.unix;
94 maintainers = with maintainers; [ Profpatsch ];
95 };
96
97}