localsend: 1.17.0 -> 1.18.0

This commit is contained in:
Sizhe Zhao
2026-08-17 01:22:52 +08:00
parent 7021f3b216
commit a4adbb5773
6 changed files with 812 additions and 699 deletions

View File

@@ -0,0 +1,48 @@
{
pname,
version,
meta,
lib,
fetchurl,
stdenvNoCC,
# nativeBuildInputs
makeBinaryWrapper,
undmg,
}:
stdenvNoCC.mkDerivation (finalAttrs: {
inherit pname version;
__structuredAttrs = true;
strictDeps = true;
src = fetchurl {
url = "https://github.com/localsend/localsend/releases/download/v${finalAttrs.version}/LocalSend-${finalAttrs.version}.dmg";
hash = "sha256-k6uITCcDoPq9cmEQl7JhbA3vhsQlbOoq3XoP823Xazo=";
};
nativeBuildInputs = [
makeBinaryWrapper
undmg
];
sourceRoot = ".";
installPhase = ''
runHook preInstall
mkdir -p $out/Applications
cp -r LocalSend.app $out/Applications
makeWrapper $out/Applications/LocalSend.app/Contents/MacOS/LocalSend $out/bin/localsend
runHook postInstall
'';
meta = meta // {
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
mainProgram = "localsend";
platforms = [ "aarch64-darwin" ];
};
})

View File

@@ -0,0 +1,126 @@
{
pname,
version,
meta,
lib,
fetchFromGitHub,
flutter341,
replaceVars,
rustPlatform,
stdenvNoCC,
# nativeBuildInputs
copyDesktopItems,
makeDesktopItem,
# buildInputs
libayatana-appindicator,
# passthru
nixosTests,
}:
flutter341.buildFlutterApplication (finalAttrs: {
inherit pname version;
strictDeps = true;
src = fetchFromGitHub {
owner = "localsend";
repo = "localsend";
tag = "v${finalAttrs.version}";
hash = "sha256-AmQVXGMVKLTOZ0HMi05ba/y4TmB56NlNvtGaKYvqt4o=";
};
sourceRoot = "${finalAttrs.src.name}/app";
pubspecLock = lib.importJSON ./pubspec.lock.json;
gitHashes = {
device_apps = "sha256-oreTBOYh4J2N4HhY2gxNwwxfl1OSAZRH1GOeVrH8LG8=";
pasteboard = "sha256-lJA5OWoAHfxORqWMglKzhsL1IFr9YcdAQP/NVOLYB4o=";
permission_handler_windows = "sha256-+TP3neqlQRZnW6BxHaXr2EbmdITIx1Yo7AEn5iwAhwM=";
};
postPatch = ''
substituteInPlace lib/util/native/autostart_helper.dart \
--replace-fail 'Exec=''${Platform.resolvedExecutable}' "Exec=localsend_app"
'';
nativeBuildInputs = [ copyDesktopItems ];
buildInputs = [ libayatana-appindicator ];
customSourceBuilders.rust_lib_localsend_app =
{ version, src, ... }:
stdenvNoCC.mkDerivation (finalAttrs': {
pname = "rust_lib_localsend_app";
inherit version src;
inherit (src) passthru;
postPatch = ''
pushd ${finalAttrs'.src.passthru.packageRoot}
patch -p1 <${
replaceVars ./no-cargokit.patch {
inherit (finalAttrs.passthru) rustLib;
}
}
popd
'';
installPhase = ''
runHook preInstall
cp -r . $out
runHook postInstall
'';
});
postInstall = ''
for s in 32 128 256 512; do
d=$out/share/icons/hicolor/''${s}x''${s}/apps
mkdir -p $d
cp assets/img/logo-''${s}.png $d/localsend.png
done
'';
extraWrapProgramArgs = ''
--prefix LD_LIBRARY_PATH : $out/app/localsend/lib
'';
desktopItems = [
(makeDesktopItem {
name = "LocalSend";
exec = "localsend_app %U";
icon = "localsend";
desktopName = "LocalSend";
startupWMClass = "localsend_app";
genericName = "An open source cross-platform alternative to AirDrop";
categories = [
"GTK"
"FileTransfer"
"Utility"
];
keywords = [
"Sharing"
"LAN"
"Files"
];
startupNotify = true;
})
];
passthru = {
rustLib = rustPlatform.buildRustPackage {
pname = "${finalAttrs.pname}-rust-lib";
inherit (finalAttrs) version src;
cargoHash = "sha256-mdyWYfzS6YieY+dwQXREZJDo4PEKO5W9C3A3XGWoDKI=";
buildAndTestSubdir = "packages/localsend_isolates/rust";
};
tests = { inherit (nixosTests) localsend; };
};
meta = meta // {
mainProgram = "localsend_app";
platforms = lib.platforms.linux;
};
})

View File

@@ -0,0 +1,17 @@
--- a/linux/CMakeLists.txt
+++ b/linux/CMakeLists.txt
@@ -7,13 +7,10 @@
set(PROJECT_NAME "rust_lib_localsend_app")
project(${PROJECT_NAME} LANGUAGES CXX)
-include("../cargokit/cmake/cargokit.cmake")
-apply_cargokit(${PROJECT_NAME} ../../rust rust_lib_localsend_app "")
-
# List of absolute paths to libraries that should be bundled with the plugin.
# This list could contain prebuilt libraries, or libraries created by an
# external build triggered from this build file.
set(rust_lib_localsend_app_bundled_libraries
- "${${PROJECT_NAME}_cargokit_lib}"
+ "@rustLib@/lib/librust_lib_localsend_app.so"
PARENT_SCOPE
)

View File

@@ -1,152 +1,77 @@
{
lib,
stdenv,
fetchurl,
fetchFromGitHub,
flutter329,
makeDesktopItem,
copyDesktopItems,
nixosTests,
libayatana-appindicator,
undmg,
makeBinaryWrapper,
fetchpatch,
}:
fetchurl,
flutter341,
replaceVars,
rustPlatform,
stdenvNoCC,
# nativeBuildInputs
copyDesktopItems,
makeBinaryWrapper,
makeDesktopItem,
undmg,
# buildInputs
libayatana-appindicator,
# passthru
nixosTests,
}:
let
pname = "localsend";
version = "1.17.0";
version = "1.18.0";
linux = flutter329.buildFlutterApplication rec {
inherit pname version;
src = fetchFromGitHub {
owner = "localsend";
repo = "localsend";
tag = "v${version}";
hash = "sha256-1xMzlIcGEJ58laSM48bCKMxzHQ36eUHD5Mac0O1dnXk=";
};
sourceRoot = "${src.name}/app";
pubspecLock = lib.importJSON ./pubspec.lock.json;
gitHashes = {
permission_handler_windows = "sha256-+TP3neqlQRZnW6BxHaXr2EbmdITIx1Yo7AEn5iwAhwM=";
pasteboard = "sha256-lJA5OWoAHfxORqWMglKzhsL1IFr9YcdAQP/NVOLYB4o=";
};
patches = [
# Fix for https://github.com/localsend/localsend/security/advisories/GHSA-34v6-52hh-x4r4
# See: https://github.com/NixOS/nixpkgs/issues/488755
# Can be removed with new release > 1.17.0
(fetchpatch {
url = "https://github.com/localsend/localsend/commit/8f3cec85aa29b2b13fed9b2f8e499e1ac9b0504c.patch";
hash = "sha256-Fswir+TebCDPxHVBg8YM3ROx2uoLG92E3E15wnzHz+U=";
})
];
patchFlags = [ "-p2" ];
postPatch = ''
substituteInPlace lib/util/native/autostart_helper.dart \
--replace-fail 'Exec=''${Platform.resolvedExecutable}' "Exec=localsend_app"
'';
nativeBuildInputs = [
copyDesktopItems
];
buildInputs = [ libayatana-appindicator ];
postInstall = ''
for s in 32 128 256 512; do
d=$out/share/icons/hicolor/''${s}x''${s}/apps
mkdir -p $d
cp ./assets/img/logo-''${s}.png $d/localsend.png
done
'';
extraWrapProgramArgs = ''
--prefix LD_LIBRARY_PATH : $out/app/localsend/lib
'';
desktopItems = [
(makeDesktopItem {
name = "LocalSend";
exec = "localsend_app %U";
icon = "localsend";
desktopName = "LocalSend";
startupWMClass = "localsend_app";
genericName = "An open source cross-platform alternative to AirDrop";
categories = [
"GTK"
"FileTransfer"
"Utility"
];
keywords = [
"Sharing"
"LAN"
"Files"
];
startupNotify = true;
})
];
passthru = {
updateScript = ./update.sh;
tests.localsend = nixosTests.localsend;
};
meta = metaCommon // {
mainProgram = "localsend_app";
};
};
darwin = stdenv.mkDerivation {
inherit pname version;
src = fetchurl {
url = "https://github.com/localsend/localsend/releases/download/v${version}/LocalSend-${version}.dmg";
hash = "sha256-/fGkLuE+uf3WrpTcWIOYHooJWZ51i94j9uZ3xPq1yTw=";
};
nativeBuildInputs = [
undmg
makeBinaryWrapper
];
sourceRoot = ".";
installPhase = ''
runHook preInstall
mkdir -p $out/Applications
cp -r LocalSend.app $out/Applications
makeBinaryWrapper $out/Applications/LocalSend.app/Contents/MacOS/LocalSend $out/bin/localsend
runHook postInstall
'';
meta = metaCommon // {
mainProgram = "localsend";
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
platforms = [
"aarch64-darwin"
];
};
};
metaCommon = {
meta = {
description = "Open source cross-platform alternative to AirDrop";
homepage = "https://localsend.org/";
donationPage = "https://localsend.org/donate";
license = lib.licenses.mit;
downloadPage = "https://github.com/localsend/localsend/releases";
changelog = "https://github.com/localsend/localsend/blob/HEAD/CHANGELOG.md";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [
sikmir
linsui
pandapip1
prince213
];
};
in
if stdenv.hostPlatform.isDarwin then darwin else linux
if stdenvNoCC.hostPlatform.isDarwin then
import ./darwin.nix {
inherit
pname
version
meta
lib
fetchurl
stdenvNoCC
makeBinaryWrapper
undmg
;
}
else
import ./linux.nix {
inherit
pname
version
meta
lib
fetchFromGitHub
flutter341
replaceVars
rustPlatform
stdenvNoCC
copyDesktopItems
makeDesktopItem
libayatana-appindicator
nixosTests
;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,26 +0,0 @@
#! /usr/bin/env nix-shell
#! nix-shell -I nixpkgs=./. -i bash -p curl gnused jq yq nix
set -eou pipefail
ROOT="$(dirname "$(readlink -f "$0")")"
latestVersion=$(curl --fail --silent https://api.github.com/repos/localsend/localsend/releases/latest | jq --raw-output .tag_name | sed 's/^v//')
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; localsend.version or (lib.getVersion localsend)" | tr -d '"')
if [[ "$currentVersion" == "$latestVersion" ]]; then
echo "package is up-to-date: $currentVersion"
exit 0
fi
sed -i "s/version = \".*\"/version = \"${latestVersion}\"/" "$ROOT/package.nix"
DARWIN_x64_URL="https://github.com/localsend/localsend/releases/download/v${latestVersion}/LocalSend-${latestVersion}.dmg"
DARWIN_X64_SHA=$(nix --extra-experimental-features nix-command hash to-sri --type sha256 $(nix-prefetch-url ${DARWIN_x64_URL}))
sed -i "/darwin/,/hash/{s|hash = \".*\"|hash = \"${DARWIN_X64_SHA}\"|}" "$ROOT/package.nix"
GIT_SRC_URL="https://github.com/localsend/localsend/archive/refs/tags/v${latestVersion}.tar.gz"
GIT_SRC_SHA=$(nix --extra-experimental-features nix-command hash to-sri --type sha256 $(nix-prefetch-url --unpack ${GIT_SRC_URL}))
sed -i "/linux/,/hash/{s|hash = \".*\"|hash = \"${GIT_SRC_SHA}\"|}" "$ROOT/package.nix"
curl https://raw.githubusercontent.com/localsend/localsend/v${latestVersion}/app/pubspec.lock | yq . > $ROOT/pubspec.lock.json