snipaste: 2.10.8 -> 2.11.3, add macOS support (#533819)

This commit is contained in:
Oleksii Filonenko 2026-07-05 15:48:35 +00:00 committed by GitHub
commit bc65277cd9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 137 additions and 29 deletions

View file

@ -2,26 +2,23 @@
appimageTools,
lib,
fetchurl,
stdenv,
stdenvNoCC,
undmg,
makeWrapper,
}:
let
pname = "snipaste";
version = "2.10.8";
src = fetchurl {
url = "https://download.snipaste.com/archives/Snipaste-${version}-x86_64.AppImage";
hash = "sha256-Ieitxc1HPjqBpf7/rREKca+U0srE+q/s8mz+9Vhczk0=";
};
contents = appimageTools.extract { inherit pname version src; };
in
appimageTools.wrapType2 {
inherit pname version src;
passthru.updateScript = ./update.sh;
extraInstallCommands = ''
install -d $out/share/{applications,icons}
cp ${contents}/usr/share/applications/*.desktop -t $out/share/applications/
cp -r ${contents}/usr/share/icons/* -t $out/share/icons/
substituteInPlace $out/share/applications/*.desktop --replace-warn 'Exec=Snipaste' 'Exec=${pname}'
'';
let
sources = import ./sources.nix { inherit fetchurl; };
source =
sources.${stdenv.hostPlatform.system}
or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
pname = "snipaste";
inherit (source) version src;
passthru = {
updateScript = ./update.sh;
};
meta = {
description = "Screenshot tools";
@ -32,7 +29,58 @@ appimageTools.wrapType2 {
ltrump
];
mainProgram = "snipaste";
platforms = [ "x86_64-linux" ];
platforms = [
"aarch64-darwin"
"x86_64-darwin"
"x86_64-linux"
];
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
};
}
in
if stdenv.hostPlatform.isDarwin then
stdenvNoCC.mkDerivation {
inherit
pname
version
src
passthru
meta
;
nativeBuildInputs = [
undmg
makeWrapper
];
sourceRoot = ".";
installPhase = ''
runHook preInstall
mkdir -p $out/Applications $out/bin
cp -R Snipaste.app $out/Applications
makeWrapper $out/Applications/Snipaste.app/Contents/MacOS/Snipaste $out/bin/snipaste
runHook postInstall
'';
}
else
let
contents = appimageTools.extract { inherit pname version src; };
in
appimageTools.wrapType2 {
inherit
pname
version
src
passthru
meta
;
extraInstallCommands = ''
install -d $out/share/{applications,icons}
install -m 444 ${contents}/Snipaste.desktop $out/share/applications/${pname}.desktop
cp -r ${contents}/usr/share/icons/* -t $out/share/icons/
substituteInPlace $out/share/applications/${pname}.desktop --replace-warn 'Exec=Snipaste' 'Exec=${pname}'
'';
}

View file

@ -0,0 +1,23 @@
# Generated by ./update.sh - do not update manually!
# Last updated: 2026-06-20
{ fetchurl }:
let
any-darwin = {
version = "2.11.3";
src = fetchurl {
url = "https://download.snipaste.com/archives/Snipaste-2.11.3.dmg";
hash = "sha256-oih4OIieexc0pl2VK65e9/R5vcFj0MMb6RhZvKEg/T4=";
};
};
in
{
aarch64-darwin = any-darwin;
x86_64-darwin = any-darwin;
x86_64-linux = {
version = "2.11.3";
src = fetchurl {
url = "https://download.snipaste.com/archives/Snipaste-2.11.3-x86_64.AppImage";
hash = "sha256-6ARv8gRbZoul+sbXc9g3MTE6TwC6FxFHxvoaE4UkAzQ=";
};
};
}

View file

@ -1,15 +1,52 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash curl coreutils jq common-updater-scripts
#!nix-shell -i bash -p bash curl coreutils jq nix
latestTag=$(curl -sSfL https://www.snipaste.com/linux_version | jq -r ".subject")
latestVersion="$(expr "$latestTag" : 'v\(.*\)')"
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; snipaste.version" | tr -d '"')
set -euo pipefail
if [[ "$latestVersion" == "$currentVersion" ]]; then
echo "package is up-to-date"
exit 0
fi
cd "$(readlink -e "$(dirname "${BASH_SOURCE[0]}")")"
prefetch=$(nix-prefetch-url "https://download.snipaste.com/archives/Snipaste-$latestVersion-x86_64.AppImage")
hash=$(nix-hash --type sha256 --to-sri "$prefetch")
update-source-version snipaste "$latestVersion" "$hash" --ignore-same-version
linux_version=$(
curl -sSfL https://www.snipaste.com/linux_version \
| jq -r '.subject' \
| sed 's/^v//'
)
mac_version=$(
curl -sSfL https://www.snipaste.com/mac_version \
| jq -r '.subject' \
| sed 's/^v//'
)
linux_url="https://download.snipaste.com/archives/Snipaste-${linux_version}-x86_64.AppImage"
mac_url="https://download.snipaste.com/archives/Snipaste-${mac_version}.dmg"
linux_hash=$(nix-prefetch-url "$linux_url")
mac_hash=$(nix-prefetch-url "$mac_url")
linux_hash=$(nix --extra-experimental-features nix-command hash convert --to sri --hash-algo sha256 "$linux_hash")
mac_hash=$(nix --extra-experimental-features nix-command hash convert --to sri --hash-algo sha256 "$mac_hash")
cat >sources.nix <<EOF
# Generated by ./update.sh - do not update manually!
# Last updated: $(date +%F)
{ fetchurl }:
let
any-darwin = {
version = "$mac_version";
src = fetchurl {
url = "$mac_url";
hash = "$mac_hash";
};
};
in
{
aarch64-darwin = any-darwin;
x86_64-darwin = any-darwin;
x86_64-linux = {
version = "$linux_version";
src = fetchurl {
url = "$linux_url";
hash = "$linux_hash";
};
};
}
EOF