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;
61 ] ++ lib.optionals (lib.versionAtLeast buildVersion "4145") [
66 binaryPackage = stdenv.mkDerivation rec {
67 pname = "${pnameBase}-bin";
68 version = buildVersion;
70 src = passthru.sources.${stdenv.hostPlatform.system};
77 # for GSETTINGS_SCHEMAS_PATH
89 for binary in ${builtins.concatStringsSep " " binaries}; do
91 --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
92 --set-rpath ${lib.makeLibraryPath neededLibraries}:${stdenv.cc.cc.lib}/lib${lib.optionalString stdenv.is64bit "64"} \
96 # Rewrite pkexec argument. Note that we cannot delete bytes in binary.
97 sed -i -e 's,/bin/cp\x00,cp\x00\x00\x00\x00\x00\x00,g' ${primaryBinary}
105 # No need to patch these libraries, it works well with our own
106 rm libcrypto.so.1.1 libssl.so.1.1
107 ${lib.optionalString (lib.versionAtLeast buildVersion "4145") "rm libsqlite3.so"}
115 dontWrapGApps = true; # non-standard location, need to wrap the executables manually
118 sed -i 's#/usr/bin/pkexec#pkexec\x00\x00\x00\x00\x00\x00\x00\x00\x00#g' "$out/${primaryBinary}"
120 wrapProgram $out/${primaryBinary} \
121 --set LOCALE_ARCHIVE "${glibcLocales.out}/lib/locale/locale-archive" \
122 "''${gappsWrapperArgs[@]}"
127 "aarch64-linux" = fetchurl {
128 url = downloadUrl "arm64";
129 sha256 = aarch64sha256;
131 "x86_64-linux" = fetchurl {
132 url = downloadUrl "x64";
139 stdenv.mkDerivation (rec {
141 version = buildVersion;
145 ${primaryBinary} = binaryPackage;
147 nativeBuildInputs = [
154 makeWrapper "''$${primaryBinary}/${primaryBinary}" "$out/bin/${primaryBinary}"
156 + builtins.concatStringsSep "" (
157 map (binaryAlias: "ln -s $out/bin/${primaryBinary} $out/bin/${binaryAlias}\n") primaryBinaryAliases
160 mkdir -p "$out/share/applications"
163 "''$${primaryBinary}/${primaryBinary}.desktop" \
164 "$out/share/applications/${primaryBinary}.desktop" \
165 --replace-fail "/opt/${primaryBinary}/${primaryBinary}" "${primaryBinary}"
167 for directory in ''$${primaryBinary}/Icon/*; do
168 size=$(basename $directory)
169 mkdir -p "$out/share/icons/hicolor/$size/apps"
170 ln -s ''$${primaryBinary}/Icon/$size/* $out/share/icons/hicolor/$size/apps
177 script = writeShellScript "${packageAttribute}-update-script" ''
181 common-updater-scripts
187 latestVersion=$(curl -s "${versionUrl}")
189 if [[ "${buildVersion}" = "$latestVersion" ]]; then
190 echo "The new version same as the old version."
194 for platform in ${lib.escapeShellArgs meta.platforms}; do
195 # The script will not perform an update when the version attribute is up to date from previous platform run
196 # We need to clear it before each run
197 update-source-version "${packageAttribute}.${primaryBinary}" 0 "${lib.fakeSha256}" --file="$versionFile" --version-key=buildVersion --source-key="sources.$platform"
198 update-source-version "${packageAttribute}.${primaryBinary}" "$latestVersion" --file="$versionFile" --version-key=buildVersion --source-key="sources.$platform"
209 description = "Sophisticated text editor for code, markup and prose";
210 homepage = "https://www.sublimetext.com/";
211 maintainers = with maintainers; [
217 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
218 license = licenses.unfree;