sublime4,sublime-merge: format with nixpkgs-fmt

This commit is contained in:
Jan Tojnar 2024-04-04 15:33:55 +02:00
parent ce7b7e7e8a
commit e2d93cb47e
4 changed files with 213 additions and 78 deletions

View File

@ -1,19 +1,53 @@
{ buildVersion, aarch64sha256, x64sha256, dev ? false }: {
buildVersion,
dev ? false,
aarch64sha256,
x64sha256,
}:
{ fetchurl, stdenv, lib, xorg, glib, libglvnd, glibcLocales, gtk3, cairo, pango, makeWrapper, wrapGAppsHook {
, writeShellScript, common-updater-scripts, curl fetchurl,
, openssl_1_1, bzip2, bash, unzip, zip stdenv,
, sqlite lib,
xorg,
glib,
libglvnd,
glibcLocales,
gtk3,
cairo,
pango,
makeWrapper,
wrapGAppsHook,
writeShellScript,
common-updater-scripts,
curl,
openssl_1_1,
bzip2,
bash,
unzip,
zip,
sqlite,
}: }:
let let
pnameBase = "sublimetext4"; pnameBase = "sublimetext4";
packageAttribute = "sublime4${lib.optionalString dev "-dev"}"; packageAttribute = "sublime4${lib.optionalString dev "-dev"}";
binaries = [ "sublime_text" "plugin_host-3.3" "plugin_host-3.8" crashHandlerBinary ]; binaries = [
"sublime_text"
"plugin_host-3.3"
"plugin_host-3.8"
crashHandlerBinary
];
primaryBinary = "sublime_text"; primaryBinary = "sublime_text";
primaryBinaryAliases = [ "subl" "sublime" "sublime4" ]; primaryBinaryAliases = [
crashHandlerBinary = if lib.versionAtLeast buildVersion "4153" then "crash_handler" else "crash_reporter"; "subl"
downloadUrl = arch: "https://download.sublimetext.com/sublime_text_build_${buildVersion}_${arch}.tar.xz"; "sublime"
"sublime4"
];
crashHandlerBinary =
if lib.versionAtLeast buildVersion "4153" then "crash_handler" else "crash_reporter";
downloadUrl =
arch: "https://download.sublimetext.com/sublime_text_build_${buildVersion}_${arch}.tar.xz";
versionUrl = "https://download.sublimetext.com/latest/${if dev then "dev" else "stable"}"; versionUrl = "https://download.sublimetext.com/latest/${if dev then "dev" else "stable"}";
versionFile = builtins.toString ./packages.nix; versionFile = builtins.toString ./packages.nix;
@ -30,7 +64,8 @@ let
] ++ lib.optionals (lib.versionAtLeast buildVersion "4145") [ ] ++ lib.optionals (lib.versionAtLeast buildVersion "4145") [
sqlite sqlite
]; ];
in let in
let
binaryPackage = stdenv.mkDerivation rec { binaryPackage = stdenv.mkDerivation rec {
pname = "${pnameBase}-bin"; pname = "${pnameBase}-bin";
version = buildVersion; version = buildVersion;
@ -39,8 +74,19 @@ in let
dontStrip = true; dontStrip = true;
dontPatchELF = true; dontPatchELF = true;
buildInputs = [ glib gtk3 ]; # for GSETTINGS_SCHEMAS_PATH
nativeBuildInputs = [ zip unzip makeWrapper wrapGAppsHook ]; buildInputs = [
glib
# for GSETTINGS_SCHEMAS_PATH
gtk3
];
nativeBuildInputs = [
zip
unzip
makeWrapper
wrapGAppsHook
];
# make exec.py in Default.sublime-package use own bash with an LD_PRELOAD instead of "/bin/bash" # make exec.py in Default.sublime-package use own bash with an LD_PRELOAD instead of "/bin/bash"
patchPhase = '' patchPhase = ''
@ -63,7 +109,7 @@ in let
buildPhase = '' buildPhase = ''
runHook preBuild runHook preBuild
for binary in ${ builtins.concatStringsSep " " binaries }; do for binary in ${builtins.concatStringsSep " " binaries}; do
patchelf \ patchelf \
--interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath ${lib.makeLibraryPath neededLibraries}:${stdenv.cc.cc.lib}/lib${lib.optionalString stdenv.is64bit "64"} \ --set-rpath ${lib.makeLibraryPath neededLibraries}:${stdenv.cc.cc.lib}/lib${lib.optionalString stdenv.is64bit "64"} \
@ -116,7 +162,8 @@ in let
}; };
}; };
}; };
in stdenv.mkDerivation (rec { in
stdenv.mkDerivation (rec {
pname = pnameBase; pname = pnameBase;
version = buildVersion; version = buildVersion;
@ -124,27 +171,39 @@ in stdenv.mkDerivation (rec {
${primaryBinary} = binaryPackage; ${primaryBinary} = binaryPackage;
nativeBuildInputs = [ makeWrapper ]; nativeBuildInputs = [
makeWrapper
];
installPhase = '' installPhase =
mkdir -p "$out/bin" ''
makeWrapper "''$${primaryBinary}/${primaryBinary}" "$out/bin/${primaryBinary}" mkdir -p "$out/bin"
'' + builtins.concatStringsSep "" (map (binaryAlias: "ln -s $out/bin/${primaryBinary} $out/bin/${binaryAlias}\n") primaryBinaryAliases) + '' makeWrapper "''$${primaryBinary}/${primaryBinary}" "$out/bin/${primaryBinary}"
mkdir -p "$out/share/applications" ''
substitute "''$${primaryBinary}/${primaryBinary}.desktop" "$out/share/applications/${primaryBinary}.desktop" --replace "/opt/${primaryBinary}/${primaryBinary}" "${primaryBinary}" + builtins.concatStringsSep "" (
for directory in ''$${primaryBinary}/Icon/*; do map (binaryAlias: "ln -s $out/bin/${primaryBinary} $out/bin/${binaryAlias}\n") primaryBinaryAliases
size=$(basename $directory) )
mkdir -p "$out/share/icons/hicolor/$size/apps" + ''
ln -s ''$${primaryBinary}/Icon/$size/* $out/share/icons/hicolor/$size/apps mkdir -p "$out/share/applications"
done substitute "''$${primaryBinary}/${primaryBinary}.desktop" "$out/share/applications/${primaryBinary}.desktop" --replace "/opt/${primaryBinary}/${primaryBinary}" "${primaryBinary}"
''; for directory in ''$${primaryBinary}/Icon/*; do
size=$(basename $directory)
mkdir -p "$out/share/icons/hicolor/$size/apps"
ln -s ''$${primaryBinary}/Icon/$size/* $out/share/icons/hicolor/$size/apps
done
'';
passthru = { passthru = {
updateScript = updateScript =
let let
script = writeShellScript "${packageAttribute}-update-script" '' script = writeShellScript "${packageAttribute}-update-script" ''
set -o errexit set -o errexit
PATH=${lib.makeBinPath [ common-updater-scripts curl ]} PATH=${
lib.makeBinPath [
common-updater-scripts
curl
]
}
versionFile=$1 versionFile=$1
latestVersion=$(curl -s "${versionUrl}") latestVersion=$(curl -s "${versionUrl}")
@ -161,15 +220,27 @@ in stdenv.mkDerivation (rec {
update-source-version "${packageAttribute}.${primaryBinary}" "$latestVersion" --file="$versionFile" --version-key=buildVersion --source-key="sources.$platform" update-source-version "${packageAttribute}.${primaryBinary}" "$latestVersion" --file="$versionFile" --version-key=buildVersion --source-key="sources.$platform"
done done
''; '';
in [ script versionFile ]; in
[
script
versionFile
];
}; };
meta = with lib; { meta = with lib; {
description = "Sophisticated text editor for code, markup and prose"; description = "Sophisticated text editor for code, markup and prose";
homepage = "https://www.sublimetext.com/"; homepage = "https://www.sublimetext.com/";
maintainers = with maintainers; [ jtojnar wmertens demin-dmitriy zimbatm ]; maintainers = with maintainers; [
jtojnar
wmertens
demin-dmitriy
zimbatm
];
sourceProvenance = with sourceTypes; [ binaryNativeCode ]; sourceProvenance = with sourceTypes; [ binaryNativeCode ];
license = licenses.unfree; license = licenses.unfree;
platforms = [ "aarch64-linux" "x86_64-linux" ]; platforms = [
"aarch64-linux"
"x86_64-linux"
];
}; };
}) })

View File

@ -3,17 +3,17 @@
let let
common = opts: callPackage (import ./common.nix opts); common = opts: callPackage (import ./common.nix opts);
in in
{ {
sublime4 = common { sublime4 = common {
buildVersion = "4169"; buildVersion = "4169";
x64sha256 = "jk9wKC0QgfhiHDYUcnDhsmgJsBPOUmCkyvQeI54IJJ4="; x64sha256 = "jk9wKC0QgfhiHDYUcnDhsmgJsBPOUmCkyvQeI54IJJ4=";
aarch64sha256 = "/W/xGbE+8gGu1zNh6lERZrfG9Dh9QUGkYiqTzp216JI="; aarch64sha256 = "/W/xGbE+8gGu1zNh6lERZrfG9Dh9QUGkYiqTzp216JI=";
} {}; } { };
sublime4-dev = common { sublime4-dev = common {
buildVersion = "4168"; buildVersion = "4168";
dev = true; dev = true;
x64sha256 = "KfW1Mh78CUBTmthHQd1s15a7GrmssSnWZ1RgaarJeag="; x64sha256 = "KfW1Mh78CUBTmthHQd1s15a7GrmssSnWZ1RgaarJeag=";
aarch64sha256 = "qJ9oix1kwWN+TUb5/WSKyHcHzB+Q87XolMOhmqx1OFc="; aarch64sha256 = "qJ9oix1kwWN+TUb5/WSKyHcHzB+Q87XolMOhmqx1OFc=";
} {}; } { };
} }

View File

@ -1,18 +1,49 @@
{ buildVersion, aarch64sha256, x64sha256, dev ? false }: {
buildVersion,
dev ? false,
aarch64sha256,
x64sha256,
}:
{ fetchurl, lib, stdenv, xorg, glib, libGL, glibcLocales, gtk3, cairo, pango, libredirect, makeWrapper, wrapGAppsHook {
, pkexecPath ? "/run/wrappers/bin/pkexec" fetchurl,
, writeShellScript, common-updater-scripts, curl, gnugrep, coreutils lib,
stdenv,
xorg,
glib,
libGL,
glibcLocales,
gtk3,
cairo,
pango,
libredirect,
makeWrapper,
wrapGAppsHook,
pkexecPath ? "/run/wrappers/bin/pkexec",
writeShellScript,
common-updater-scripts,
curl,
gnugrep,
coreutils,
}: }:
let let
pnameBase = "sublime-merge"; pnameBase = "sublime-merge";
packageAttribute = "sublime-merge${lib.optionalString dev "-dev"}"; packageAttribute = "sublime-merge${lib.optionalString dev "-dev"}";
binaries = [ "sublime_merge" crashHandlerBinary "git-credential-sublime" "ssh-askpass-sublime" ]; binaries = [
"sublime_merge"
crashHandlerBinary
"git-credential-sublime"
"ssh-askpass-sublime"
];
primaryBinary = "sublime_merge"; primaryBinary = "sublime_merge";
primaryBinaryAliases = [ "smerge" ]; primaryBinaryAliases = [
crashHandlerBinary = if lib.versionAtLeast buildVersion "2086" then "crash_handler" else "crash_reporter"; "smerge"
downloadUrl = arch: "https://download.sublimetext.com/sublime_merge_build_${buildVersion}_${arch}.tar.xz"; ];
crashHandlerBinary =
if lib.versionAtLeast buildVersion "2086" then "crash_handler" else "crash_reporter";
downloadUrl =
arch: "https://download.sublimetext.com/sublime_merge_build_${buildVersion}_${arch}.tar.xz";
versionUrl = "https://www.sublimemerge.com/${if dev then "dev" else "download"}"; versionUrl = "https://www.sublimemerge.com/${if dev then "dev" else "download"}";
versionFile = builtins.toString ./default.nix; versionFile = builtins.toString ./default.nix;
@ -25,8 +56,12 @@ let
curl curl
]; ];
redirects = [ "/usr/bin/pkexec=${pkexecPath}" "/bin/true=${coreutils}/bin/true" ]; redirects = [
in let "/usr/bin/pkexec=${pkexecPath}"
"/bin/true=${coreutils}/bin/true"
];
in
let
binaryPackage = stdenv.mkDerivation rec { binaryPackage = stdenv.mkDerivation rec {
pname = "${pnameBase}-bin"; pname = "${pnameBase}-bin";
version = buildVersion; version = buildVersion;
@ -35,13 +70,20 @@ in let
dontStrip = true; dontStrip = true;
dontPatchELF = true; dontPatchELF = true;
buildInputs = [ glib gtk3 ]; # for GSETTINGS_SCHEMAS_PATH buildInputs = [
nativeBuildInputs = [ makeWrapper wrapGAppsHook ]; glib
# for GSETTINGS_SCHEMAS_PATH
gtk3
];
nativeBuildInputs = [
makeWrapper
wrapGAppsHook
];
buildPhase = '' buildPhase = ''
runHook preBuild runHook preBuild
for binary in ${ builtins.concatStringsSep " " binaries }; do for binary in ${builtins.concatStringsSep " " binaries}; do
patchelf \ patchelf \
--interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath ${lib.makeLibraryPath neededLibraries}:${libGL}/lib:${stdenv.cc.cc.lib}/lib${lib.optionalString stdenv.is64bit "64"} \ --set-rpath ${lib.makeLibraryPath neededLibraries}:${libGL}/lib:${stdenv.cc.cc.lib}/lib${lib.optionalString stdenv.is64bit "64"} \
@ -96,7 +138,8 @@ in let
}; };
}; };
}; };
in stdenv.mkDerivation (rec { in
stdenv.mkDerivation (rec {
pname = pnameBase; pname = pnameBase;
version = buildVersion; version = buildVersion;
@ -104,27 +147,40 @@ in stdenv.mkDerivation (rec {
${primaryBinary} = binaryPackage; ${primaryBinary} = binaryPackage;
nativeBuildInputs = [ makeWrapper ]; nativeBuildInputs = [
makeWrapper
];
installPhase = '' installPhase =
mkdir -p "$out/bin" ''
makeWrapper "''$${primaryBinary}/${primaryBinary}" "$out/bin/${primaryBinary}" mkdir -p "$out/bin"
'' + builtins.concatStringsSep "" (map (binaryAlias: "ln -s $out/bin/${primaryBinary} $out/bin/${binaryAlias}\n") primaryBinaryAliases) + '' makeWrapper "''$${primaryBinary}/${primaryBinary}" "$out/bin/${primaryBinary}"
mkdir -p "$out/share/applications" ''
substitute "''$${primaryBinary}/${primaryBinary}.desktop" "$out/share/applications/${primaryBinary}.desktop" --replace "/opt/${primaryBinary}/${primaryBinary}" "${primaryBinary}" + builtins.concatStringsSep "" (
for directory in ''$${primaryBinary}/Icon/*; do map (binaryAlias: "ln -s $out/bin/${primaryBinary} $out/bin/${binaryAlias}\n") primaryBinaryAliases
size=$(basename $directory) )
mkdir -p "$out/share/icons/hicolor/$size/apps" + ''
ln -s ''$${primaryBinary}/Icon/$size/* $out/share/icons/hicolor/$size/apps mkdir -p "$out/share/applications"
done substitute "''$${primaryBinary}/${primaryBinary}.desktop" "$out/share/applications/${primaryBinary}.desktop" --replace "/opt/${primaryBinary}/${primaryBinary}" "${primaryBinary}"
''; for directory in ''$${primaryBinary}/Icon/*; do
size=$(basename $directory)
mkdir -p "$out/share/icons/hicolor/$size/apps"
ln -s ''$${primaryBinary}/Icon/$size/* $out/share/icons/hicolor/$size/apps
done
'';
passthru = { passthru = {
updateScript = updateScript =
let let
script = writeShellScript "${packageAttribute}-update-script" '' script = writeShellScript "${packageAttribute}-update-script" ''
set -o errexit set -o errexit
PATH=${lib.makeBinPath [ common-updater-scripts curl gnugrep ]} PATH=${
lib.makeBinPath [
common-updater-scripts
curl
gnugrep
]
}
versionFile=$1 versionFile=$1
latestVersion=$(curl -s ${versionUrl} | grep -Po '(?<=<p class="latest"><i>Version:</i> Build )([0-9]+)') latestVersion=$(curl -s ${versionUrl} | grep -Po '(?<=<p class="latest"><i>Version:</i> Build )([0-9]+)')
@ -141,7 +197,11 @@ in stdenv.mkDerivation (rec {
update-source-version "${packageAttribute}.${primaryBinary}" "$latestVersion" --file="$versionFile" --version-key=buildVersion --source-key="sources.$platform" update-source-version "${packageAttribute}.${primaryBinary}" "$latestVersion" --file="$versionFile" --version-key=buildVersion --source-key="sources.$platform"
done done
''; '';
in [ script versionFile ]; in
[
script
versionFile
];
}; };
meta = with lib; { meta = with lib; {
@ -150,6 +210,9 @@ in stdenv.mkDerivation (rec {
maintainers = with maintainers; [ zookatron ]; maintainers = with maintainers; [ zookatron ];
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
license = licenses.unfree; license = licenses.unfree;
platforms = [ "aarch64-linux" "x86_64-linux" ]; platforms = [
"aarch64-linux"
"x86_64-linux"
];
}; };
}) })

View File

@ -2,17 +2,18 @@
let let
common = opts: callPackage (import ./common.nix opts); common = opts: callPackage (import ./common.nix opts);
in { in
{
sublime-merge = common { sublime-merge = common {
buildVersion = "2091"; buildVersion = "2091";
aarch64sha256 = "dkPKuuzQQtL3eZlaAPeL7e2p5PCxroFRSp6Rw5wHODc="; aarch64sha256 = "dkPKuuzQQtL3eZlaAPeL7e2p5PCxroFRSp6Rw5wHODc=";
x64sha256 = "T5g6gHgl9xGytEOsh3VuB08IrbDvMu24o/1edCGmfd4="; x64sha256 = "T5g6gHgl9xGytEOsh3VuB08IrbDvMu24o/1edCGmfd4=";
} {}; } { };
sublime-merge-dev = common { sublime-merge-dev = common {
buildVersion = "2092"; buildVersion = "2092";
dev = true;
aarch64sha256 = "3QMDynXMVB4QVtM8EPbZ8I4m+5sEjzs8XN+jEoMaktM="; aarch64sha256 = "3QMDynXMVB4QVtM8EPbZ8I4m+5sEjzs8XN+jEoMaktM=";
x64sha256 = "S9E+wRvO41Eq+PLA/J+sjBIAn6yz715Wg9bKRW2Eobg="; x64sha256 = "S9E+wRvO41Eq+PLA/J+sjBIAn6yz715Wg9bKRW2Eobg=";
dev = true; } { };
} {};
} }