1{
2 lib,
3 stdenv,
4 fetchurl,
5 copper,
6 python3,
7 pkg-config,
8 withQt ? false,
9 qtbase ? null,
10 wrapQtAppsHook ? null,
11 withGtk2 ? false,
12 gtk2,
13 withGtk3 ? false,
14 gtk3,
15 mkDerivation ? stdenv.mkDerivation,
16}:
17let
18 onlyOneEnabled = xs: 1 == builtins.length (builtins.filter lib.id xs);
19in
20assert onlyOneEnabled [
21 withQt
22 withGtk2
23 withGtk3
24];
25mkDerivation rec {
26 pname = "code-browser";
27 version = "8.0";
28 src = fetchurl {
29 url = "https://tibleiz.net/download/code-browser-${version}-src.tar.gz";
30 sha256 = "sha256-beCp4lx4MI1+hVgWp2h3piE/zu51zfwQdB5g7ImgmwY=";
31 };
32 postPatch = ''
33 substituteInPlace Makefile --replace "LFLAGS=-no-pie" "LFLAGS=-no-pie -L."
34 patchShebangs .
35 ''
36 + lib.optionalString withQt ''
37 substituteInPlace libs/copper-ui/Makefile --replace "moc -o" "${qtbase.dev}/bin/moc -o"
38 substituteInPlace libs/copper-ui/Makefile --replace "all: qt gtk gtk2" "all: qt"
39 ''
40 + lib.optionalString withGtk2 ''
41 substituteInPlace libs/copper-ui/Makefile --replace "all: qt gtk gtk2" "all: gtk2"
42 ''
43 + lib.optionalString withGtk3 ''
44 substituteInPlace libs/copper-ui/Makefile --replace "all: qt gtk gtk2" "all: gtk"
45 '';
46 nativeBuildInputs = [
47 copper
48 python3
49 pkg-config
50 ]
51 ++ lib.optionals withGtk2 [ gtk2 ]
52 ++ lib.optionals withGtk3 [ gtk3 ]
53 ++ lib.optionals withQt [
54 qtbase
55 wrapQtAppsHook
56 ];
57 buildInputs =
58 lib.optionals withQt [ qtbase ]
59 ++ lib.optionals withGtk2 [ gtk2 ]
60 ++ lib.optionals withGtk3 [ gtk3 ];
61 makeFlags = [
62 "prefix=$(out)"
63 "COPPER=${copper}/bin/copper-elf64"
64 "with-local-libs"
65 ]
66 ++ lib.optionals withQt [
67 "QINC=${qtbase.dev}/include"
68 "UI=qt"
69 ]
70 ++ lib.optionals withGtk2 [ "UI=gtk2" ]
71 ++ lib.optionals withGtk3 [ "UI=gtk" ];
72
73 meta = with lib; {
74 description = "Folding text editor, designed to hierarchically structure any kind of text file and especially source code";
75 homepage = "https://tibleiz.net/code-browser/";
76 license = licenses.gpl2;
77 platforms = platforms.x86_64;
78 };
79}