fluffychat: 1.7.0 -> 2.0.0

This commit is contained in:
aleksana
2025-06-29 00:12:46 +08:00
parent 61eda88c65
commit b5aec1f9cd
3 changed files with 209 additions and 86 deletions
+44 -64
View File
@@ -1,15 +1,16 @@
{
lib,
fetchzip,
fetchFromGitHub,
fetchpatch,
imagemagick,
libgbm,
libdrm,
flutter332,
pulseaudio,
copyDesktopItems,
makeDesktopItem,
olm,
callPackage,
vodozemac-wasm ? callPackage ./vodozemac-wasm.nix { flutter = flutter332; },
targetFlutterPlatform ? "linux",
}:
@@ -24,81 +25,72 @@ in
flutter332.buildFlutterApplication (
rec {
pname = "fluffychat-${targetFlutterPlatform}";
version = "1.27.0";
version = "2.0.0";
src = fetchFromGitHub {
owner = "krille-chan";
repo = "fluffychat";
tag = "v${version}";
hash = "sha256-kt4VpegxcZ+d0NIKan2A0AUqFLdYNcU9HY/4zyd2eSU=";
hash = "sha256-fFc6nIVQUY9OiGkEc7jrzXnBQPDWC5x5A4/XHUhu6hs=";
};
# https://github.com/krille-chan/fluffychat/pull/1965
patches = [
(fetchpatch {
name = "fix_compilation_mxc_image.patch";
url = "https://github.com/krille-chan/fluffychat/commit/e1ec87d3aaae00eb030bcfda28ec8f247e2c3346.patch";
hash = "sha256-/cd3geNVPifAC7iTcx8V1l2WY9Y/mEw+VPl2B4HSJKY=";
})
];
inherit pubspecLock;
gitHashes = {
flutter_secure_storage_linux = "sha256-cFNHW7dAaX8BV7arwbn68GgkkBeiAgPfhMOAFSJWlyY=";
flutter_web_auth_2 = "sha256-3aci73SP8eXg6++IQTQoyS+erUUuSiuXymvR32sxHFw=";
flutter_typeahead = "sha256-ZGXbbEeSddrdZOHcXE47h3Yu3w6oV7q+ZnO6GyW7Zg8=";
flutter_secure_storage_linux = "sha256-cFNHW7dAaX8BV7arwbn68GgkkBeiAgPfhMOAFSJWlyY=";
};
inherit targetFlutterPlatform;
meta = {
description = "Chat with your friends (matrix client)";
homepage = "https://fluffychat.im/";
license = lib.licenses.agpl3Plus;
mainProgram = "fluffychat";
maintainers = with lib.maintainers; [
mkg20001
tebriel
aleksana
];
platforms = [
"x86_64-linux"
"aarch64-linux"
];
sourceProvenance = [ lib.sourceTypes.fromSource ];
inherit (olm.meta) knownVulnerabilities;
};
meta =
{
description = "Chat with your friends (matrix client)";
homepage = "https://fluffychat.im/";
license = lib.licenses.agpl3Plus;
maintainers = with lib.maintainers; [
mkg20001
tebriel
aleksana
];
badPlatforms = lib.platforms.darwin;
}
// lib.optionalAttrs (targetFlutterPlatform == "linux") {
mainProgram = "fluffychat";
};
}
// lib.optionalAttrs (targetFlutterPlatform == "linux") {
nativeBuildInputs = [ imagemagick ];
nativeBuildInputs = [
imagemagick
copyDesktopItems
];
runtimeDependencies = [ pulseaudio ];
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"
];
};
desktopItems = [
(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
D=$ICO/hicolor/''${size}x''${size}/apps
mkdir -p $D
magick $FAV -resize ''${size}x''${size} $D/fluffychat.png
done
@@ -107,20 +99,8 @@ flutter332.buildFlutterApplication (
'';
}
// 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
'';
preBuild = ''
cp -r ${vodozemac-wasm}/* ./assets/vodozemac/
'';
}
)
+42 -22
View File
@@ -176,6 +176,16 @@
"source": "hosted",
"version": "2.1.2"
},
"build_cli_annotations": {
"dependency": "transitive",
"description": {
"name": "build_cli_annotations",
"sha256": "b59d2769769efd6c9ff6d4c4cede0be115a566afc591705c2040b707534b1172",
"url": "https://pub.dev"
},
"source": "hosted",
"version": "2.1.0"
},
"canonical_json": {
"dependency": "transitive",
"description": {
@@ -764,16 +774,6 @@
"source": "hosted",
"version": "1.1.1"
},
"flutter_olm": {
"dependency": "direct main",
"description": {
"name": "flutter_olm",
"sha256": "5e6211af8cba1abf7d1f92e543f6d573dfe6017fe4742e0d04ba84beab47f940",
"url": "https://pub.dev"
},
"source": "hosted",
"version": "2.0.0"
},
"flutter_openssl_crypto": {
"dependency": "direct main",
"description": {
@@ -794,6 +794,16 @@
"source": "hosted",
"version": "2.0.28"
},
"flutter_rust_bridge": {
"dependency": "transitive",
"description": {
"name": "flutter_rust_bridge",
"sha256": "b416ff56002789e636244fb4cc449f587656eff995e5a7169457eb0593fcaddb",
"url": "https://pub.dev"
},
"source": "hosted",
"version": "2.10.0"
},
"flutter_secure_storage": {
"dependency": "direct main",
"description": {
@@ -882,6 +892,16 @@
"source": "git",
"version": "5.2.0"
},
"flutter_vodozemac": {
"dependency": "direct main",
"description": {
"name": "flutter_vodozemac",
"sha256": "2405ca121b84d1cd83200a14021022e1691b123a23bcefc36adc7740cefbc1f9",
"url": "https://pub.dev"
},
"source": "hosted",
"version": "0.2.2"
},
"flutter_web_auth_2": {
"dependency": "direct main",
"description": {
@@ -1445,11 +1465,11 @@
"dependency": "direct main",
"description": {
"name": "matrix",
"sha256": "f8f78700f967de4333a0c9ca609dac2ae05914a27faa60c5530026b7aca6ae78",
"sha256": "996e3b1560959afaa3118ec2b5a06734ad29acf64f9c3c09a605c3ddef22039f",
"url": "https://pub.dev"
},
"source": "hosted",
"version": "0.40.2"
"version": "1.0.1"
},
"meta": {
"dependency": "transitive",
@@ -1521,16 +1541,6 @@
"source": "hosted",
"version": "2.0.2"
},
"olm": {
"dependency": "transitive",
"description": {
"name": "olm",
"sha256": "6a3fe1e5170b954dd9e4ba3b27513e6aa9b7591eb7bb0d7f6f32140b7f140c6f",
"url": "https://pub.dev"
},
"source": "hosted",
"version": "3.1.0"
},
"opus_caf_converter_dart": {
"dependency": "direct main",
"description": {
@@ -2747,6 +2757,16 @@
"source": "hosted",
"version": "15.0.0"
},
"vodozemac": {
"dependency": "transitive",
"description": {
"name": "vodozemac",
"sha256": "dba14017e042748fb22d270e8ab1d3e46965b89788dd3857dba938ec07571968",
"url": "https://pub.dev"
},
"source": "hosted",
"version": "0.2.0"
},
"wakelock_plus": {
"dependency": "direct main",
"description": {
@@ -0,0 +1,123 @@
{
lib,
stdenv,
fluffychat-web,
symlinkJoin,
buildPackages,
rustc,
rustPlatform,
cargo,
flutter,
flutter_rust_bridge_codegen,
which,
wasm-pack,
wasm-bindgen-cli_0_2_100,
binaryen,
writableTmpDirAsHomeHook,
runCommand,
}:
let
pubSources = fluffychat-web.pubspecLock.dependencySources;
# wasm-pack doesn't take 'RUST_SRC_PATH' into consideration
rustcWithLibSrc = buildPackages.rustc.override {
sysroot = symlinkJoin {
name = "rustc_unwrapped_with_libsrc";
paths = [
buildPackages.rustc.unwrapped
];
postBuild = ''
mkdir -p $out/lib/rustlib/src/rust
ln -s ${rustPlatform.rustLibSrc} $out/lib/rustlib/src/rust/library
'';
};
};
in
# https://github.com/krille-chan/fluffychat/blob/main/scripts/prepare-web.sh
stdenv.mkDerivation {
pname = "vodozemac-wasm";
inherit (pubSources.vodozemac) version;
# These two were in the same repository, so just reuse them
unpackPhase = ''
runHook preUnpack
cp -r ${pubSources.flutter_vodozemac}/rust ./rust
cp -r ${pubSources.vodozemac} ./dart
chmod -R +rwx .
runHook postUnpack
'';
# Remove dev_dependencies to avoid downloading them
postPatch = ''
sed -i '/^dev_dependencies:/,/^$/d' dart/pubspec.yaml
'';
cargoRoot = "rust";
cargoDeps = symlinkJoin {
name = "vodozemac-wasm-cargodeps";
paths = [
pubSources.flutter_vodozemac.passthru.cargoDeps
# Pull in rust vendor so we don't have to vendor rustLibSrc again
# This is required because `-Z build-std=std,panic_abort` rebuilds std
rustPlatform.rustVendorSrc
];
};
nativeBuildInputs = [
rustPlatform.cargoSetupHook
rustcWithLibSrc
rustc.llvmPackages.lld
cargo
flutter
flutter_rust_bridge_codegen
which
wasm-pack
wasm-bindgen-cli_0_2_100
binaryen
writableTmpDirAsHomeHook
];
buildPhase = ''
runHook preBuild
pushd dart
dart pub get --offline
popd
RUST_LOG=info flutter_rust_bridge_codegen build-web \
--dart-root $(realpath ./dart) --rust-root $(realpath ./rust) --release
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out
cp -r dart/web/pkg/vodozemac_bindings_dart* $out/
runHook postInstall
'';
env = {
# Build a pub cache from fluffychat, as dart-vodozemac should be a subset
# This is required because dart-vodozemac, as a pub, doesn't have a pubspec.lock
# But flutter_rust_bridge_codegen still requires all dependencies of it
PUB_CACHE = runCommand "fluffychat-pub-cache" { } ''
mkdir -p $out/hosted/pub.dev
pushd $out/hosted/pub.dev
${lib.concatMapAttrsStringSep "; " (
_: p:
"ln -s ${p} ./${if lib.hasPrefix "pub-" p.name then lib.removePrefix "pub-" p.name else p.name}"
) pubSources}
popd
'';
RUSTC_BOOTSTRAP = 1; # `-Z build-std=std,panic_abort` requires nightly toolchain
};
inherit (fluffychat-web) meta;
}