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") [
65 binaryPackage = stdenv.mkDerivation rec {
66 pname = "${pnameBase}-bin";
67 version = buildVersion;
69 src = passthru.sources.${stdenv.hostPlatform.system};
76 # for GSETTINGS_SCHEMAS_PATH
88 for binary in ${builtins.concatStringsSep " " binaries}; do
90 --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
91 --set-rpath ${lib.makeLibraryPath neededLibraries}:${stdenv.cc.cc.lib}/lib${lib.optionalString stdenv.hostPlatform.is64bit "64"} \
95 # Rewrite pkexec argument. Note that we cannot delete bytes in binary.
96 sed -i -e 's,/bin/cp\x00,cp\x00\x00\x00\x00\x00\x00,g' ${primaryBinary}
104 # No need to patch these libraries, it works well with our own
105 rm libcrypto.so.1.1 libssl.so.1.1
106 ${lib.optionalString (lib.versionAtLeast buildVersion "4145") "rm libsqlite3.so"}
114 dontWrapGApps = true; # non-standard location, need to wrap the executables manually
117 sed -i 's#/usr/bin/pkexec#pkexec\x00\x00\x00\x00\x00\x00\x00\x00\x00#g' "$out/${primaryBinary}"
119 wrapProgram $out/${primaryBinary} \
120 --set LOCALE_ARCHIVE "${glibcLocales.out}/lib/locale/locale-archive" \
121 "''${gappsWrapperArgs[@]}"
126 "aarch64-linux" = fetchurl {
127 url = downloadUrl "arm64";
128 sha256 = aarch64sha256;
130 "x86_64-linux" = fetchurl {
131 url = downloadUrl "x64";
138 stdenv.mkDerivation (rec {
140 version = buildVersion;
144 ${primaryBinary} = binaryPackage;
146 nativeBuildInputs = [
153 makeWrapper "''$${primaryBinary}/${primaryBinary}" "$out/bin/${primaryBinary}"
155 + builtins.concatStringsSep "" (
156 map (binaryAlias: "ln -s $out/bin/${primaryBinary} $out/bin/${binaryAlias}\n") primaryBinaryAliases
159 mkdir -p "$out/share/applications"
162 "''$${primaryBinary}/${primaryBinary}.desktop" \
163 "$out/share/applications/${primaryBinary}.desktop" \
164 --replace-fail "/opt/${primaryBinary}/${primaryBinary}" "${primaryBinary}"
166 for directory in ''$${primaryBinary}/Icon/*; do
167 size=$(basename $directory)
168 mkdir -p "$out/share/icons/hicolor/$size/apps"
169 ln -s ''$${primaryBinary}/Icon/$size/* $out/share/icons/hicolor/$size/apps
176 script = writeShellScript "${packageAttribute}-update-script" ''
180 common-updater-scripts
186 latestVersion=$(curl -s "${versionUrl}")
188 if [[ "${buildVersion}" = "$latestVersion" ]]; then
189 echo "The new version same as the old version."
193 for platform in ${lib.escapeShellArgs meta.platforms}; do
194 update-source-version "${packageAttribute}.${primaryBinary}" "$latestVersion" --ignore-same-version --file="$versionFile" --version-key=buildVersion --source-key="sources.$platform"
205 description = "Sophisticated text editor for code, markup and prose";
206 homepage = "https://www.sublimetext.com/";
207 maintainers = with maintainers; [
213 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
214 license = licenses.unfree;