localsend: 1.11.1 -> 1.12.0, build from source

This commit is contained in:
linsui 2023-10-08 03:26:58 +08:00 committed by linsui
parent 457610539b
commit e29677c518
5 changed files with 2577 additions and 40 deletions

View File

@ -1,49 +1,70 @@
{ lib, stdenv, appimageTools, fetchurl, undmg }:
{ lib
, stdenv
, fetchurl
, fetchFromGitHub
, flutter
, makeDesktopItem
, pkg-config
, libayatana-appindicator
, undmg
}:
let
pname = "localsend";
version = "1.11.1";
version = "1.12.0";
hashes = {
x86_64-linux = "sha256-K4M9cks0FNsCLIqQhSgUAz3tRMKng6JkZ/ZfwG2hZJA=";
x86_64-darwin = "sha256-Cixo00I4BBAmUnszsz+CxPX3EY175UTufCmwQmIsEgg=";
};
linux = flutter.buildFlutterApplication {
inherit pname version;
srcs = rec {
x86_64-linux = fetchurl {
url = "https://github.com/localsend/localsend/releases/download/v${version}/LocalSend-${version}-linux-x86-64.AppImage";
hash = hashes.x86_64-linux;
src = fetchFromGitHub {
owner = pname;
repo = pname;
rev = "v${version}";
hash = "sha256-mk0CLZP0x/mEixeAig7X41aFgQzs+kZkBJx6T//3ZKY=";
};
x86_64-darwin = fetchurl {
url = "https://github.com/localsend/localsend/releases/download/v${version}/LocalSend-${version}.dmg";
hash = hashes.x86_64-darwin;
};
aarch64-darwin = x86_64-darwin;
};
src = srcs.${stdenv.hostPlatform.system} or (throw "Unsupported system for package localsend: ${stdenv.hostPlatform.system}");
appimageContents = appimageTools.extract { inherit pname version src; };
sourceRoot = "source/app";
depsListFile = ./deps.json;
vendorHash = "sha256-fXzxT7KBi/WT2A5PEIx+B+UG4HWEbMPMsashVQsXdmU=";
linux = appimageTools.wrapType2 rec {
inherit pname version src meta;
nativeBuildInputs = [ pkg-config ];
extraPkgs = p: [ p.ayatana-ido p.libayatana-appindicator p.libayatana-indicator p.libdbusmenu p.libepoxy ];
buildInputs = [ libayatana-appindicator ];
extraInstallCommands = ''
mv $out/bin/${pname}-${version} $out/bin/${pname}
install -m 444 -D ${appimageContents}/org.localsend.localsend_app.desktop \
$out/share/applications/${pname}.desktop
substituteInPlace $out/share/applications/${pname}.desktop \
--replace 'Exec=localsend_app' "Exec=$out/bin/localsend"
install -m 444 -D ${appimageContents}/localsend.png \
$out/share/icons/hicolor/256x256/apps/localsend.png
postInstall = ''
mv $out/bin/localsend_app $out/bin/localsend
for s in 32 128 256 512; do
d=$out/share/icons/hicolor/''${s}x''${s}/apps
mkdir -p $d
ln -s $out/app/data/flutter_assets/assets/img/logo-''${s}.png $d/localsend.png
done
mkdir -p $out/share/applications
cp $desktopItem/share/applications/*.desktop $out/share/applications
substituteInPlace $out/share/applications/*.desktop --subst-var out
'';
desktopItem = makeDesktopItem {
name = "LocalSend";
exec = "@out@/bin/localsend_app";
icon = "localsend";
desktopName = "LocalSend";
startupWMClass = "localsend";
genericName = "An open source cross-platform alternative to AirDrop";
categories = [ "Network" ];
};
meta = meta // {
mainProgram = "localsend_app";
};
};
darwin = stdenv.mkDerivation {
inherit pname version src meta;
inherit pname version;
src = fetchurl {
url = "https://github.com/localsend/localsend/releases/download/v${version}/LocalSend-${version}.dmg";
hash = "sha256-XKYc3lA7x0Tf1Mf3o7D2RYwYDRDVHoSb/lj9PhKzV5U=";
};
nativeBuildInputs = [ undmg ];
@ -53,15 +74,18 @@ let
mkdir -p $out/Applications
cp -r *.app $out/Applications
'';
meta = meta // {
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
platforms = [ "x86_64-darwin" "aarch64-darwin" ];
};
};
meta = with lib; {
description = "An open source cross-platform alternative to AirDrop";
homepage = "https://localsend.org/";
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
license = licenses.mit;
maintainers = with maintainers; [ sikmir ];
platforms = builtins.attrNames srcs;
};
in
if stdenv.isDarwin

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
#! /usr/bin/env nix-shell
#! nix-shell -I nixpkgs=./. -i bash -p curl gnused
#! nix-shell -I nixpkgs=./. -i bash -p curl gnused jq
set -eou pipefail
@ -16,10 +16,6 @@ fi
sed -i "s/version = \".*\"/version = \"${latestVersion}\"/" "$ROOT/default.nix"
LINUX_x64_URL="https://github.com/localsend/localsend/releases/download/v${latestVersion}/LocalSend-${latestVersion}-linux-x86-64.AppImage"
LINUX_X64_SHA=$(nix hash to-sri --type sha256 $(nix-prefetch-url ${LINUX_x64_URL}))
sed -i "0,/x86_64-linux/{s|x86_64-linux = \".*\"|x86_64-linux = \"${LINUX_X64_SHA}\"|}" "$ROOT/default.nix"
DARWIN_x64_URL="https://github.com/localsend/localsend/releases/download/v${latestVersion}/LocalSend-${latestVersion}.dmg"
DARWIN_X64_SHA=$(nix hash to-sri --type sha256 $(nix-prefetch-url ${DARWIN_x64_URL}))
sed -i "0,/x86_64-darwin/{s|x86_64-darwin = \".*\"|x86_64-darwin = \"${DARWIN_X64_SHA}\"|}" "$ROOT/default.nix"
sed -i "/darwin/,/hash/{s|hash = \".*\"|hash = \"${DARWIN_X64_SHA}\"|}" "$ROOT/default.nix"

View File

@ -5,4 +5,5 @@
handy_window = callPackage ./handy-window { };
matrix = callPackage ./matrix { };
olm = callPackage ./olm { };
system_tray = callPackage ./system-tray { };
}

View File

@ -0,0 +1,18 @@
{ libayatana-appindicator
}:
{ ... }:
{ preBuild ? ""
, ...
}:
{
preBuild = preBuild + ''
# $PUB_CACHE/hosted is a symlink to a store path.
mv $PUB_CACHE/hosted $PUB_CACHE/hosted_copy
cp -HR $PUB_CACHE/hosted_copy $PUB_CACHE/hosted
substituteInPlace $PUB_CACHE/hosted/pub.dev/system_tray-*/linux/tray.cc \
--replace "libappindicator3.so.1" "${libayatana-appindicator}/lib/libayatana-appindicator3.so.1"
'';
}