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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
{
stdenv,
lib,
fetchFromGitHub,
coreutils,
lazarus,
fpc,
libx11,
# GTK3
harfbuzz,
pango,
cairo,
glib,
atk,
gtk3,
gdk-pixbuf,
python3,
wrapGAppsHook3,
# Qt5
libsForQt5,
widgetset ? "qt5",
# See https://github.com/Alexey-T/CudaText-lexers
additionalLexers ? [ "Nix" ],
}:
assert builtins.elem widgetset [
"gtk3"
"qt5"
];
let
deps = lib.mapAttrs (
name: spec:
fetchFromGitHub {
repo = name;
inherit (spec) owner rev hash;
}
) (lib.importJSON ./deps.json);
in
stdenv.mkDerivation (finalAttrs: {
pname = "cudatext";
version = "1.236.0.5";
src = fetchFromGitHub {
owner = "Alexey-T";
repo = "CudaText";
tag = finalAttrs.version;
hash = "sha256-DH4X9IsBs4a8tPjDmMgb5xoAmkfP5uBWs1eoKlmq8c4=";
};
patches = [ ./proc_globdata.patch ];
postPatch = ''
substituteInPlace app/proc_globdata.pas \
--subst-var out \
--subst-var-by python3 ${python3}
substituteInPlace app/proc_editor_saving.pas \
--replace-fail '/bin/cp' "${coreutils}/bin/cp"
'';
nativeBuildInputs = [
lazarus
fpc
]
++ lib.optional (widgetset == "gtk3") wrapGAppsHook3 # required for FileChooser
++ lib.optional (widgetset == "qt5") libsForQt5.wrapQtAppsHook;
buildInputs = [
libx11
]
++ lib.optionals (widgetset == "gtk3") [
harfbuzz
pango
cairo
glib
atk
gdk-pixbuf
gtk3
]
++ lib.optional (widgetset == "qt5") libsForQt5.libqtpas;
env.NIX_LDFLAGS = toString [
"--as-needed"
"-rpath"
(lib.makeLibraryPath finalAttrs.buildInputs)
];
buildPhase =
lib.concatStringsSep "\n" (
lib.mapAttrsToList (name: dep: ''
cp -r ${dep} ${name}
'') deps
)
+ ''
lazbuild --lazarusdir=${lazarus}/share/lazarus --pcp=./lazarus --ws=${widgetset} \
bgrabitmap/bgrabitmap/bgrabitmappack.lpk \
EncConv/encconv/encconv_package.lpk \
ATBinHex-Lazarus/atbinhex/atbinhex_package.lpk \
ATFlatControls/atflatcontrols/atflatcontrols_package.lpk \
ATSynEdit/atsynedit/atsynedit_package.lpk \
ATSynEdit_Cmp/atsynedit_cmp/atsynedit_cmp_package.lpk \
EControl/econtrol/econtrol_package.lpk \
ATSynEdit_Ex/atsynedit_ex/atsynedit_ex_package.lpk \
Python-for-Lazarus/python4lazarus/python4lazarus_package.lpk \
Emmet-Pascal/emmet/emmet_package.lpk \
app/cudatext.lpi
'';
installPhase = ''
install -Dm755 app/cudatext -t $out/bin
install -dm755 $out/share/cudatext
cp -r app/{data,py,settings_default} $out/share/cudatext
install -Dm644 setup/debfiles/cudatext-512.png -t $out/share/pixmaps
install -Dm644 setup/debfiles/cudatext.desktop -t $out/share/applications
''
+ lib.concatMapStringsSep "\n" (lexer: ''
if [ -d "CudaText-lexers/${lexer}" ]; then
install -Dm644 CudaText-lexers/${lexer}/*.{cuda-lexmap,lcf} $out/share/cudatext/data/lexlib
else
echo "${lexer} lexer not found"
exit 1
fi
'') additionalLexers;
passthru.updateScript = ./update.sh;
meta = {
description = "Cross-platform code editor";
longDescription = ''
Text/code editor with lite UI. Syntax highlighting for 200+ languages.
Config system in JSON files. Multi-carets and multi-selections.
Search and replace with RegEx. Extendable by Python plugins and themes.
'';
homepage = "https://cudatext.github.io/";
changelog = "https://cudatext.github.io/history.txt";
license = lib.licenses.mpl20;
maintainers = with lib.maintainers; [ sikmir ];
platforms = lib.platforms.linux;
mainProgram = "cudatext";
};
})
|