22 common-updater-scripts,
30 pnameBase = "sublimetext4";
31 packageAttribute = "sublime4${lib.optionalString dev "-dev"}";
38 primaryBinary = "sublime_text";
39 primaryBinaryAliases = [
45 if lib.versionAtLeast buildVersion "4153" then "crash_handler" else "crash_reporter";
47 arch: "https://download.sublimetext.com/sublime_text_build_${buildVersion}_${arch}.tar.xz";
48 versionUrl = "https://download.sublimetext.com/latest/${if dev then "dev" else "stable"}";
49 versionFile = builtins.toString ./packages.nix;
63 ++ lib.optionals (lib.versionAtLeast buildVersion "4145") [
67 binaryPackage = stdenv.mkDerivation rec {
68 pname = "${pnameBase}-bin";
69 version = buildVersion;
71 src = passthru.sources.${stdenv.hostPlatform.system};
78 # for GSETTINGS_SCHEMAS_PATH
90 for binary in ${builtins.concatStringsSep " " binaries}; do
92 --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
93 --set-rpath ${lib.makeLibraryPath neededLibraries}:${lib.getLib stdenv.cc.cc}/lib${lib.optionalString stdenv.hostPlatform.is64bit "64"} \
97 # Rewrite pkexec argument. Note that we cannot delete bytes in binary.
98 sed -i -e 's,/bin/cp\x00,cp\x00\x00\x00\x00\x00\x00,g' ${primaryBinary}
106 # No need to patch these libraries, it works well with our own
107 rm libcrypto.so.1.1 libssl.so.1.1
108 ${lib.optionalString (lib.versionAtLeast buildVersion "4145") "rm libsqlite3.so"}
116 dontWrapGApps = true; # non-standard location, need to wrap the executables manually
119 sed -i 's#/usr/bin/pkexec#pkexec\x00\x00\x00\x00\x00\x00\x00\x00\x00#g' "$out/${primaryBinary}"
121 wrapProgram $out/${primaryBinary} \
122 --set LOCALE_ARCHIVE "${glibcLocales.out}/lib/locale/locale-archive" \
123 "''${gappsWrapperArgs[@]}"
128 "aarch64-linux" = fetchurl {
129 url = downloadUrl "arm64";
130 sha256 = aarch64sha256;
132 "x86_64-linux" = fetchurl {
133 url = downloadUrl "x64";
140 stdenv.mkDerivation (rec {
142 version = buildVersion;
146 ${primaryBinary} = binaryPackage;
148 nativeBuildInputs = [
155 makeWrapper "''$${primaryBinary}/${primaryBinary}" "$out/bin/${primaryBinary}"
157 + builtins.concatStringsSep "" (
158 map (binaryAlias: "ln -s $out/bin/${primaryBinary} $out/bin/${binaryAlias}\n") primaryBinaryAliases
161 mkdir -p "$out/share/applications"
164 "''$${primaryBinary}/${primaryBinary}.desktop" \
165 "$out/share/applications/${primaryBinary}.desktop" \
166 --replace-fail "/opt/${primaryBinary}/${primaryBinary}" "${primaryBinary}"
168 for directory in ''$${primaryBinary}/Icon/*; do
169 size=$(basename $directory)
170 mkdir -p "$out/share/icons/hicolor/$size/apps"
171 ln -s ''$${primaryBinary}/Icon/$size/* $out/share/icons/hicolor/$size/apps
178 script = writeShellScript "${packageAttribute}-update-script" ''
182 common-updater-scripts
188 latestVersion=$(curl -s "${versionUrl}")
190 if [[ "${buildVersion}" = "$latestVersion" ]]; then
191 echo "The new version same as the old version."
195 for platform in ${lib.escapeShellArgs meta.platforms}; do
196 update-source-version "${packageAttribute}.${primaryBinary}" "$latestVersion" --ignore-same-version --file="$versionFile" --version-key=buildVersion --source-key="sources.$platform"
207 description = "Sophisticated text editor for code, markup and prose";
208 homepage = "https://www.sublimetext.com/";
209 maintainers = with maintainers; [
215 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
216 license = licenses.unfree;