From e66692eecda44373fd51d85c3832f47479bc3113 Mon Sep 17 00:00:00 2001 From: colin Date: Wed, 21 Sep 2022 02:58:35 -0700 Subject: [PATCH] enable fluffychat -- though reproducibility may suffer i've applied this patch, but modified the sha: - --- modules/universal/env/home-packages.nix | 2 +- .../11-186839-fluffychat1.2.0-1.6.1.patch | 533 ++++++++++++++++++ nixpatches/list.nix | 6 + 3 files changed, 540 insertions(+), 1 deletion(-) create mode 100644 nixpatches/11-186839-fluffychat1.2.0-1.6.1.patch diff --git a/modules/universal/env/home-packages.nix b/modules/universal/env/home-packages.nix index 0be250bda..ff67fb736 100644 --- a/modules/universal/env/home-packages.nix +++ b/modules/universal/env/home-packages.nix @@ -53,7 +53,7 @@ let emote # TODO: package [smile](https://github.com/mijorus/smile) for probably a better mobile experience. evince # works on phosh - # fluffychat + fluffychat foliate font-manager gimp # broken on phosh diff --git a/nixpatches/11-186839-fluffychat1.2.0-1.6.1.patch b/nixpatches/11-186839-fluffychat1.2.0-1.6.1.patch new file mode 100644 index 000000000..69c61f092 --- /dev/null +++ b/nixpatches/11-186839-fluffychat1.2.0-1.6.1.patch @@ -0,0 +1,533 @@ +diff --git a/pkgs/applications/networking/instant-messengers/fluffychat/default.nix b/pkgs/applications/networking/instant-messengers/fluffychat/default.nix +index d50e7118cc18d..6125b6c072893 100644 +--- a/pkgs/applications/networking/instant-messengers/fluffychat/default.nix ++++ b/pkgs/applications/networking/instant-messengers/fluffychat/default.nix +@@ -3,20 +3,26 @@ + , flutter + , olm + , imagemagick ++, jack2 ++, alsa-lib ++, libpulseaudio ++, fribidi ++, libgcrypt ++, libgpg-error + , makeDesktopItem + }: + + flutter.mkFlutterApp rec { + pname = "fluffychat"; +- version = "1.2.0"; ++ version = "1.6.1"; + +- vendorHash = "sha256-co+bnsVIyg42JpM9FimfGEjrd6A99GlBeow1Dgv7NBI="; ++ vendorHash = "sha256-ONcNC9J23FR7duUg/aK0pujj2401Esr7BBzulQT7Xpw="; + + src = fetchFromGitLab { + owner = "famedly"; + repo = "fluffychat"; + rev = "v${version}"; +- hash = "sha256-PJH3jMQc6u9R6Snn+9rNN8t+8kt6l3Xt7zKPbpqj13E="; ++ hash = "sha256-aBhhGyzNgwCWQ+zLanFJpQ2ibR+qI+ETRTWL0TzNHT4="; + }; + + desktopItem = makeDesktopItem { +@@ -30,8 +36,16 @@ flutter.mkFlutterApp rec { + + buildInputs = [ + olm ++ jack2 ++ alsa-lib ++ libpulseaudio ++ fribidi ++ libgcrypt ++ libgpg-error + ]; + ++ NIX_CFLAGS_COMPILE = "-I${fribidi}/include/fribidi"; ++ + nativeBuildInputs = [ + imagemagick + ]; +diff --git a/pkgs/build-support/flutter/default.nix b/pkgs/build-support/flutter/default.nix +index 691b2c5c6e600..2631014f07458 100644 +--- a/pkgs/build-support/flutter/default.nix ++++ b/pkgs/build-support/flutter/default.nix +@@ -27,6 +27,8 @@ + , dart + , nukeReferences + , targetPlatform ++, fetchgit ++, clang + , bash + , curl + , unzip +@@ -44,7 +46,6 @@ let + fetchAttrs = [ "src" "sourceRoot" "setSourceRoot" "unpackPhase" "patches" ]; + getAttrsOrNull = names: attrs: lib.genAttrs names (name: if attrs ? ${name} then attrs.${name} else null); + flutterDeps = [ +- # flutter deps + flutter.unwrapped + bash + curl +@@ -55,230 +56,221 @@ let + xz + ]; + self = +-(self: llvmPackages_13.stdenv.mkDerivation (args // { +- deps = stdenvNoCC.mkDerivation (lib.recursiveUpdate (getAttrsOrNull fetchAttrs args) { +- name = "${self.name}-deps-flutter-v${flutter.unwrapped.version}-${targetPlatform.system}.tar.gz"; +- +- nativeBuildInputs = flutterDeps ++ [ +- nukeReferences +- ]; +- +- # avoid pub phase +- dontBuild = true; +- +- installPhase = '' +- . ${../fetchgit/deterministic-git} +- +- TMP=$(mktemp -d) +- +- export HOME="$TMP" +- export PUB_CACHE=''${PUB_CACHE:-"$HOME/.pub-cache"} +- export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1 +- +- flutter config --no-analytics &>/dev/null # mute first-run +- flutter config --enable-linux-desktop +- flutter packages get +- flutter build linux || true # so it downloads tools +- ${lib.optionalString (args ? flutterExtraFetchCommands) args.flutterExtraFetchCommands} +- +- RES="$TMP" +- +- mkdir -p "$RES/f" +- +- # so we can use lock, diff yaml +- cp "pubspec.yaml" "$RES" +- cp "pubspec.lock" "$RES" +- mv .dart_tool .flutter-plugins .flutter-plugins-dependencies .packages "$RES/f" +- +- # replace paths with placeholders +- find "$RES" -type f -exec sed -i \ +- -e s,$TMP,${placeholder_deps},g \ +- -e s,${flutter.unwrapped},${placeholder_flutter},g \ +- {} + +- +- remove_line_matching() { +- replace_line_matching "$1" "$2" "" +- } +- +- replace_line_matching() { +- sed "s|.*$2.*|$3|g" -r -i "$1" +- } +- +- # nuke nondeterminism +- +- # clientId is random +- remove_line_matching "$RES/.flutter" clientId +- +- # deterministic git repos +- find "$RES" -iname .git -type d | while read -r repoGit; do +- make_deterministic_repo "$(dirname "$repoGit")" +- done +- +- # dart _fetchedAt, etc +- DART_DATE=$(date --date="@$SOURCE_DATE_EPOCH" -In | sed "s|,|.|g" | sed "s|+.*||g") +- find "$RES/.pub-cache" -iname "*.json" -exec sed -r 's|.*_fetchedAt.*| "_fetchedAt": "'"$DART_DATE"'",|g' -i {} + +- replace_line_matching "$RES/f/.dart_tool/package_config.json" '"generated"' '"generated": "'"$DART_DATE"'",' +- replace_line_matching "$RES/f/.flutter-plugins-dependencies" '"date_created"' '"date_created": "'"$DART_DATE"'",' +- remove_line_matching "$RES/f/.packages" "Generated by pub" +- +- # nuke refs +- find "$RES" -type f -exec nuke-refs {} + +- +- # Build a reproducible tar, per instructions at https://reproducible-builds.org/docs/archives/ +- tar --owner=0 --group=0 --numeric-owner --format=gnu \ +- --sort=name --mtime="@$SOURCE_DATE_EPOCH" \ +- -czf "$out" -C "$RES" . +- ''; +- +- GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt"; +- SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt"; +- +- impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [ +- "GIT_PROXY_COMMAND" "NIX_GIT_SSL_CAINFO" "SOCKS_SERVER" +- ]; +- +- # unnecesarry +- dontFixup = true; +- +- outputHashAlgo = if self ? vendorHash then null else "sha256"; +- # outputHashMode = "recursive"; +- outputHash = if self ? vendorHash then +- self.vendorHash +- else if self ? vendorSha256 then +- self.vendorSha256 +- else +- lib.fakeSha256; +- +- }); +- +- nativeBuildInputs = flutterDeps ++ [ +- # flutter dev tools +- cmake +- ninja +- pkg-config +- wrapGAppsHook +- # flutter likes dynamic linking +- autoPatchelfHook +- ] ++ lib.optionals (args ? nativeBuildInputs) args.nativeBuildInputs; +- +- buildInputs = [ +- # cmake deps +- gtk3 +- glib +- pcre +- util-linux +- # also required by cmake, not sure if really needed or dep of all packages +- libselinux +- libsepol +- libthai +- libdatrie +- xorg.libXdmcp +- xorg.libXtst +- libxkbcommon +- dbus +- at-spi2-core +- libsecret +- jsoncpp +- # build deps +- xorg.libX11 +- # directly required by build +- libepoxy +- ] ++ lib.optionals (args ? buildInputs) args.buildInputs; +- +- # TODO: do we need this? +- NIX_LDFLAGS = "-rpath ${lib.makeLibraryPath self.buildInputs}"; +- NIX_CFLAGS_COMPILE = "-I${xorg.libX11}/include"; +- LD_LIBRARY_PATH = lib.makeLibraryPath self.buildInputs; +- +- configurePhase = '' +- runHook preConfigure +- +- # for some reason fluffychat build breaks without this - seems file gets overriden by some tool +- cp pubspec.yaml pubspec-backup +- +- # we get this from $depsFolder so disabled for now, but we might need it again once deps are fetched properly +- # flutter config --no-analytics >/dev/null 2>/dev/null # mute first-run +- # flutter config --enable-linux-desktop +- +- # extract deps +- depsFolder=$(mktemp -d) +- tar xzf "$deps" -C "$depsFolder" +- +- # after extracting update paths to point to real paths +- find "$depsFolder" -type f -exec sed -i \ +- -e s,${placeholder_deps},$depsFolder,g \ +- -e s,${placeholder_flutter},${flutter.unwrapped},g \ +- {} + +- +- # ensure we're using a lockfile for the right package version +- if [ -e pubspec.lock ]; then +- # FIXME: currently this is broken. in theory this should not break, but flutter has it's own way of doing things. +- # diff -u pubspec.lock $depsFolder/pubspec.lock +- true +- else +- cp -v "$depsFolder/pubspec.lock" . +- fi +- diff -u pubspec.yaml $depsFolder/pubspec.yaml +- +- mv -v $(find $depsFolder/f -type f) . +- +- # prepare +- export HOME=$depsFolder +- export PUB_CACHE=''${PUB_CACHE:-"$HOME/.pub-cache"} +- export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1 +- +- # binaries need to be patched +- autoPatchelf -- "$depsFolder" +- +- runHook postConfigure +- ''; +- +- buildPhase = '' +- runHook preBuild +- +- # for some reason fluffychat build breaks without this - seems file gets overriden by some tool +- mv pubspec-backup pubspec.yaml +- mkdir -p build/flutter_assets/fonts +- +- flutter packages get --offline -v +- flutter build linux --release -v +- +- runHook postBuild +- ''; +- +- installPhase = '' +- runHook preInstall +- +- built=build/linux/*/release/bundle +- +- mkdir -p $out/bin +- mv $built $out/app +- +- for f in $(find $out/app -iname "*.desktop" -type f); do +- install -D $f $out/share/applications/$(basename $f) +- done +- +- for f in $(find $out/app -maxdepth 1 -type f); do +- ln -s $f $out/bin/$(basename $f) +- done +- +- # this confuses autopatchelf hook otherwise +- rm -rf "$depsFolder" +- +- # make *.so executable +- find $out/app -iname "*.so" -type f -exec chmod +x {} + +- +- # remove stuff like /build/source/packages/ubuntu_desktop_installer/linux/flutter/ephemeral +- for f in $(find $out/app -executable -type f); do +- if patchelf --print-rpath "$f" | grep /build; then # this ignores static libs (e,g. libapp.so) also +- echo "strip RPath of $f" +- newrp=$(patchelf --print-rpath $f | sed -r "s|/build.*ephemeral:||g" | sed -r "s|/build.*profile:||g") +- patchelf --set-rpath "$newrp" "$f" +- fi +- done +- +- runHook postInstall +- ''; +-})) self; ++ (self: llvmPackages_13.stdenv.mkDerivation (args // rec { ++ deps = stdenvNoCC.mkDerivation (lib.recursiveUpdate (getAttrsOrNull fetchAttrs args) { ++ name = "${self.name}-deps-flutter-v${flutter.unwrapped.version}-${targetPlatform.system}.tar.gz"; ++ ++ nativeBuildInputs = flutterDeps ++ [ ++ nukeReferences ++ ]; ++ ++ dontBuild = true; ++ ++ installPhase = '' ++ . ${../fetchgit/deterministic-git} ++ ++ TMP=$(mktemp -d) ++ ++ export HOME="$TMP" ++ export PUB_CACHE=''${PUB_CACHE:-"$HOME/.pub-cache"} ++ export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1 ++ ++ flutter config --no-analytics &>/dev/null # mute first-run ++ flutter config --enable-linux-desktop ++ flutter packages get ++ ++ # Make flutter build fail but let it download the flutter tools needed ++ flutter build linux 2>/dev/null || true # so it downloads tools ++ ${lib.optionalString (args ? flutterExtraFetchCommands) args.flutterExtraFetchCommands} ++ ++ RES="$TMP" ++ ++ mkdir -p "$RES/f" ++ ++ # so we can use lock, diff yaml ++ cp "pubspec.yaml" "$RES" ++ cp "pubspec.lock" "$RES" ++ mv .dart_tool .flutter-plugins .flutter-plugins-dependencies .packages "$RES/f" || true ++ ++ # replace paths with placeholders ++ find "$RES" -type f -exec sed -i \ ++ -e s,$TMP,${placeholder_deps},g \ ++ -e s,${flutter.unwrapped},${placeholder_flutter},g \ ++ {} + ++ ++ remove_line_matching() { ++ replace_line_matching "$1" "$2" "" ++ } ++ ++ replace_line_matching() { ++ sed "s|.*$2.*|$3|g" -r -i "$1" ++ } ++ ++ # nuke nondeterminism ++ ++ # clientId is random ++ remove_line_matching "$RES/.flutter" clientId ++ ++ # deterministic git repos ++ find "$RES" -iname .git -type d | while read -r repoGit; do ++ make_deterministic_repo "$(dirname "$repoGit")" ++ done ++ ++ # dart _fetchedAt, etc ++ DART_DATE=$(date --date="@$SOURCE_DATE_EPOCH" -In | sed "s|,|.|g" | sed "s|+.*||g") ++ find "$RES/.pub-cache" -iname "*.json" -exec sed -r 's|.*_fetchedAt.*| "_fetchedAt": "'"$DART_DATE"'",|g' -i {} + ++ replace_line_matching "$RES/f/.dart_tool/package_config.json" '"generated"' '"generated": "'"$DART_DATE"'",' ++ replace_line_matching "$RES/f/.flutter-plugins-dependencies" '"date_created"' '"date_created": "'"$DART_DATE"'",' || true ++ remove_line_matching "$RES/f/.packages" "Generated by pub" ++ ++ # nuke refs ++ find "$RES" -type f -exec nuke-refs {} + ++ ++ # Build a reproducible tar, per instructions at https://reproducible-builds.org/docs/archives/ ++ tar --owner=0 --group=0 --numeric-owner --format=gnu \ ++ --sort=name --mtime="@$SOURCE_DATE_EPOCH" \ ++ -czf "$out" -C "$RES" . ++ ''; ++ ++ # Disable NixOS Sandbox to fetch flutter required build tools through the flutter command ++ # We do not build the application here but just predownload the tools and checksum them with ++ # 'vendorHash' ++ GIT_SSL_CAINFO = "${cacert}/etc/ssl/certs/ca-bundle.crt"; ++ SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt"; ++ impureEnvVars = lib.fetchers.proxyImpureEnvVars ++ [ ++ "GIT_PROXY_COMMAND" ++ "NIX_GIT_SSL_CAINFO" ++ "SOCKS_SERVER" ++ ]; ++ ++ outputHashAlgo = if self ? vendorHash then null else "sha256"; ++ ++ outputHash = ++ if self ? vendorHash then ++ self.vendorHash ++ else if self ? vendorSha256 then ++ self.vendorSha256 ++ else ++ lib.fakeSha256; ++ }); ++ ++ nativeBuildInputs = flutterDeps ++ [ ++ cmake ++ ninja ++ pkg-config ++ wrapGAppsHook ++ autoPatchelfHook ++ ] ++ lib.optionals (args ? nativeBuildInputs) args.nativeBuildInputs; ++ ++ buildInputs = [ ++ gtk3 ++ glib ++ pcre ++ util-linux ++ libselinux ++ libsepol ++ libthai ++ libdatrie ++ xorg.libXdmcp ++ xorg.libXtst ++ libxkbcommon ++ dbus ++ at-spi2-core ++ libsecret ++ jsoncpp ++ xorg.libX11 ++ libepoxy ++ ] ++ lib.optionals (args ? buildInputs) args.buildInputs; ++ ++ configurePhase = '' ++ runHook preConfigure ++ ++ # for some reason fluffychat build breaks without this - seems file gets overriden by some tool ++ cp pubspec.yaml pubspec-backup ++ ++ # we get this from $depsFolder so disabled for now, but we might need it again once deps are fetched properly ++ # flutter config --no-analytics >/dev/null 2>/dev/null # mute first-run ++ # flutter config --enable-linux-desktop ++ ++ # extract deps ++ depsFolder=$(mktemp -d) ++ tar xzf "$deps" -C "$depsFolder" ++ ++ # after extracting update paths to point to real paths ++ find "$depsFolder" -type f -exec sed -i \ ++ -e s,${placeholder_deps},$depsFolder,g \ ++ -e s,${placeholder_flutter},${flutter.unwrapped},g \ ++ {} + ++ ++ # ensure we're using a lockfile for the right package version ++ if [ -e pubspec.lock ]; then ++ # FIXME: currently this is broken. in theory this should not break, but flutter has it's own way of doing things. ++ # diff -u pubspec.lock $depsFolder/pubspec.lock ++ true ++ else ++ cp -v "$depsFolder/pubspec.lock" . ++ fi ++ diff -u pubspec.yaml $depsFolder/pubspec.yaml ++ ++ mv -v $(find $depsFolder/f -type f) . ++ ++ # prepare ++ export HOME=$depsFolder ++ export PUB_CACHE=''${PUB_CACHE:-"$HOME/.pub-cache"} ++ export ANDROID_EMULATOR_USE_SYSTEM_LIBS=1 ++ ++ # binaries need to be patched ++ autoPatchelf -- "$depsFolder" ++ ++ runHook postConfigure ++ ''; ++ ++ buildPhase = '' ++ runHook preBuild ++ ++ # for some reason fluffychat build breaks without this - seems file gets overriden by some tool ++ mv pubspec-backup pubspec.yaml ++ mkdir -p build/flutter_assets/fonts ++ ++ flutter packages get --offline -v ++ flutter build linux --release -v ++ ++ runHook postBuild ++ ''; ++ ++ installPhase = '' ++ runHook preInstall ++ ++ built=build/linux/*/release/bundle ++ ++ mkdir -p $out/bin ++ mv $built $out/app ++ ++ for f in $(find $out/app -iname "*.desktop" -type f); do ++ install -D $f $out/share/applications/$(basename $f) ++ done ++ ++ for f in $(find $out/app -maxdepth 1 -type f); do ++ ln -s $f $out/bin/$(basename $f) ++ done ++ ++ # this confuses autopatchelf hook otherwise ++ rm -rf "$depsFolder" ++ ++ # make *.so executable ++ find $out/app -iname "*.so" -type f -exec chmod +x {} + ++ ++ # remove stuff like /build/source/packages/ubuntu_desktop_installer/linux/flutter/ephemeral ++ for f in $(find $out/app -executable -type f); do ++ if patchelf --print-rpath "$f" | grep /build; then # this ignores static libs (e,g. libapp.so) also ++ echo "strip RPath of $f" ++ newrp=$(patchelf --print-rpath $f | sed -r "s|/build.*ephemeral:||g" | sed -r "s|/build.*profile:||g") ++ patchelf --set-rpath "$newrp" "$f" ++ fi ++ done ++ ++ runHook postInstall ++ ''; ++ })) self; + in +- self ++self +diff --git a/pkgs/os-specific/linux/firmware/firmware-updater/default.nix b/pkgs/os-specific/linux/firmware/firmware-updater/default.nix +index fb9d3a9a36c4c..2b0470d43fbb8 100644 +--- a/pkgs/os-specific/linux/firmware/firmware-updater/default.nix ++++ b/pkgs/os-specific/linux/firmware/firmware-updater/default.nix +@@ -7,7 +7,7 @@ flutter.mkFlutterApp { + pname = "firmware-updater"; + version = "unstable"; + +- vendorHash = "sha256-3wVA9BLCnMijC0gOmskz+Hv7NQIGu/jhBDbWjmoq1Tc="; ++ vendorHash = "sha256-lZ+o4EwaY8K0bfGYpiECwhtGudbRG5z/UfHWjb35XLE="; + + src = fetchFromGitHub { + owner = "canonical"; diff --git a/nixpatches/list.nix b/nixpatches/list.nix index c53cdc230..6db5d2447 100644 --- a/nixpatches/list.nix +++ b/nixpatches/list.nix @@ -4,6 +4,12 @@ fetchpatch: [ # (it's a dupe of https://github.com/NixOS/nixpkgs/pull/112677 ) ./02-rpi4-uboot.patch + # (fetchpatch { + # url = "https://github.com/NixOS/nixpkgs/pull/186839.diff"; + # sha256 = "sha256-NdIfie+eTy4V1vgqiiRPtWdnxZ5ZHsvCMfkEDUv9SC8="; + # }) + ./11-186839-fluffychat1.2.0-1.6.1.patch + # # # Flutter: 3.0.4->3.3.2, flutter.dart: 2.17.5->2.18.1 # # (fetchpatch { # # url = "https://github.com/NixOS/nixpkgs/pull/189338.diff";