biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / applications / editors / cudatext / default.nix
blob37b79d9815c3e7dfa82d2f95dae7fc60a459326d
1 { stdenv
2 , lib
3 , fetchFromGitHub
4 , lazarus
5 , fpc
6 , libX11
8 # GTK2/3
9 , pango
10 , cairo
11 , glib
12 , atk
13 , gtk2
14 , gtk3
15 , gdk-pixbuf
16 , python3
18 # Qt5
19 , libqt5pas
20 , qt5
22 , widgetset ? "qt5"
23 # See https://github.com/Alexey-T/CudaText-lexers
24 , additionalLexers ? [ "Nix" ]
27 assert builtins.elem widgetset [ "gtk2" "gtk3" "qt5" ];
29 let
30   deps = lib.mapAttrs
31     (name: spec:
32       fetchFromGitHub {
33         repo = name;
34         inherit (spec) owner rev hash;
35       }
36     )
37     (lib.importJSON ./deps.json);
39 stdenv.mkDerivation rec {
40   pname = "cudatext";
41   version = "1.202.1";
43   src = fetchFromGitHub {
44     owner = "Alexey-T";
45     repo = "CudaText";
46     rev = version;
47     hash = "sha256-ZFMO986D4RtrTnLFdcL0a2BNjcsB+9pIolylblku7j4=";
48   };
50   patches = [ ./proc_globdata.patch ];
52   postPatch = ''
53     substituteInPlace app/proc_globdata.pas \
54       --subst-var out \
55       --subst-var-by python3 ${python3}
56   '';
58   nativeBuildInputs = [ lazarus fpc ]
59     ++ lib.optional (widgetset == "qt5") qt5.wrapQtAppsHook;
61   buildInputs = [ libX11 ]
62     ++ lib.optionals (lib.hasPrefix "gtk" widgetset) [ pango cairo glib atk gdk-pixbuf ]
63     ++ lib.optional (widgetset == "gtk2") gtk2
64     ++ lib.optional (widgetset == "gtk3") gtk3
65     ++ lib.optional (widgetset == "qt5") libqt5pas;
67   NIX_LDFLAGS = "--as-needed -rpath ${lib.makeLibraryPath buildInputs}";
69   buildPhase = lib.concatStringsSep "\n" (lib.mapAttrsToList (name: dep: ''
70     cp -r ${dep} ${name}
71   '') deps) + ''
72     # See https://wiki.freepascal.org/CudaText#How_to_compile_CudaText
73     substituteInPlace ATSynEdit/atsynedit/atsynedit_package.lpk \
74       --replace GTK2_IME_CODE _GTK2_IME_CODE
76     lazbuild --lazarusdir=${lazarus}/share/lazarus --pcp=./lazarus --ws=${widgetset} \
77       bgrabitmap/bgrabitmap/bgrabitmappack.lpk \
78       EncConv/encconv/encconv_package.lpk \
79       ATBinHex-Lazarus/atbinhex/atbinhex_package.lpk \
80       ATFlatControls/atflatcontrols/atflatcontrols_package.lpk \
81       ATSynEdit/atsynedit/atsynedit_package.lpk \
82       ATSynEdit_Cmp/atsynedit_cmp/atsynedit_cmp_package.lpk \
83       EControl/econtrol/econtrol_package.lpk \
84       ATSynEdit_Ex/atsynedit_ex/atsynedit_ex_package.lpk \
85       Python-for-Lazarus/python4lazarus/python4lazarus_package.lpk \
86       Emmet-Pascal/emmet/emmet_package.lpk \
87       app/cudatext.lpi
88   '';
90   installPhase = ''
91     install -Dm755 app/cudatext -t $out/bin
93     install -dm755 $out/share/cudatext
94     cp -r app/{data,py,settings_default} $out/share/cudatext
96     install -Dm644 setup/debfiles/cudatext-512.png -t $out/share/pixmaps
97     install -Dm644 setup/debfiles/cudatext.desktop -t $out/share/applications
98   '' + lib.concatMapStringsSep "\n" (lexer: ''
99     if [ -d "CudaText-lexers/${lexer}" ]; then
100       install -Dm644 CudaText-lexers/${lexer}/*.{cuda-lexmap,lcf} $out/share/cudatext/data/lexlib
101     else
102       echo "${lexer} lexer not found"
103       exit 1
104     fi
105   '') additionalLexers;
107   passthru.updateScript = ./update.sh;
109   meta = with lib; {
110     description = "Cross-platform code editor";
111     longDescription = ''
112       Text/code editor with lite UI. Syntax highlighting for 200+ languages.
113       Config system in JSON files. Multi-carets and multi-selections.
114       Search and replace with RegEx. Extendable by Python plugins and themes.
115     '';
116     homepage = "https://cudatext.github.io/";
117     changelog = "https://cudatext.github.io/history.txt";
118     license = licenses.mpl20;
119     maintainers = with maintainers; [ sikmir ];
120     platforms = platforms.linux;
121     mainProgram = "cudatext";
122   };