nixpkgs/pkgs/by-name/fl/fluffychat/package.nix
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

100 lines
2.9 KiB
Nix

{ lib
, fetchzip
, fetchFromGitHub
, imagemagick
, mesa
, libdrm
, flutter324
, pulseaudio
, makeDesktopItem
, zenity
, olm
, targetFlutterPlatform ? "linux"
}:
let
libwebrtcRpath = lib.makeLibraryPath [ mesa libdrm ];
pubspecLock = lib.importJSON ./pubspec.lock.json;
in
flutter324.buildFlutterApplication (rec {
pname = "fluffychat-${targetFlutterPlatform}";
version = "1.22.1";
src = fetchFromGitHub {
owner = "krille-chan";
repo = "fluffychat";
rev = "refs/tags/v${version}";
hash = "sha256-biFoRcMss3JVrMoilc8BzJ+R6f+e4RYpZ5dbxDpnfTk=";
};
inherit pubspecLock;
gitHashes = {
flutter_shortcuts = "sha256-4nptZ7/tM2W/zylk3rfQzxXgQ6AipFH36gcIb/0RbHo=";
keyboard_shortcuts = "sha256-U74kRujftHPvpMOIqVT0Ph+wi1ocnxNxIFA1krft4Os=";
};
inherit targetFlutterPlatform;
meta = with lib; {
description = "Chat with your friends (matrix client)";
homepage = "https://fluffychat.im/";
license = licenses.agpl3Plus;
mainProgram = "fluffychat";
maintainers = with maintainers; [ mkg20001 gilice ];
platforms = [ "x86_64-linux" "aarch64-linux" ];
sourceProvenance = [ sourceTypes.fromSource ];
inherit (olm.meta) knownVulnerabilities;
};
} // lib.optionalAttrs (targetFlutterPlatform == "linux") {
nativeBuildInputs = [ imagemagick ];
runtimeDependencies = [ pulseaudio ];
extraWrapProgramArgs = "--prefix PATH : ${zenity}/bin";
env.NIX_LDFLAGS = "-rpath-link ${libwebrtcRpath}";
desktopItem = makeDesktopItem {
name = "Fluffychat";
exec = "fluffychat";
icon = "fluffychat";
desktopName = "Fluffychat";
genericName = "Chat with your friends (matrix client)";
categories = [ "Chat" "Network" "InstantMessaging" ];
};
postInstall = ''
FAV=$out/app/fluffychat-linux/data/flutter_assets/assets/favicon.png
ICO=$out/share/icons
install -D $FAV $ICO/fluffychat.png
mkdir $out/share/applications
cp $desktopItem/share/applications/*.desktop $out/share/applications
for size in 24 32 42 64 128 256 512; do
D=$ICO/hicolor/''${s}x''${s}/apps
mkdir -p $D
convert $FAV -resize ''${size}x''${size} $D/fluffychat.png
done
patchelf --add-rpath ${libwebrtcRpath} $out/app/fluffychat-linux/lib/libwebrtc.so
'';
} // lib.optionalAttrs (targetFlutterPlatform == "web") {
prePatch =
# https://github.com/krille-chan/fluffychat/blob/v1.17.1/scripts/prepare-web.sh
let
# Use Olm 1.3.2, the oldest version, for FluffyChat 1.14.1 which depends on olm_flutter 1.2.0.
olmVersion = pubspecLock.packages.flutter_olm.version;
olmJs = fetchzip {
url = "https://github.com/famedly/olm/releases/download/v${olmVersion}/olm.zip";
stripRoot = false;
hash = "sha256-Vl3Cp2OaYzM5CPOOtTHtUb1W48VXePzOV6FeiIzyD1Y=";
};
in
''
rm -r assets/js/package
cp -r '${olmJs}/javascript' assets/js/package
'';
})