diff --git a/flake.nix b/flake.nix index 2af0a031..c5124fc5 100644 --- a/flake.nix +++ b/flake.nix @@ -50,6 +50,7 @@ # for raspberry pi: allow building u-boot for rpi 4{,00} ./nixpatches/02-rpi4-uboot.patch ./nixpatches/03-whalebird-4.6.0.patch + ./nixpatches/04-dart-2.7.0.patch ]; }; nixosSystem = import (patchedPkgs + "/nixos/lib/eval-config.nix"); @@ -106,6 +107,7 @@ #### TEMPORARY: PACKAGES WAITING TO BE UPSTREAMED whalebird = prev.callPackage ./pkgs/whalebird { }; + kaiteki = prev.callPackage ./pkgs/kaiteki { }; }) ]; }; diff --git a/helpers/home-manager-gen-colin.nix b/helpers/home-manager-gen-colin.nix index e61b208d..5eacf8be 100644 --- a/helpers/home-manager-gen-colin.nix +++ b/helpers/home-manager-gen-colin.nix @@ -501,12 +501,13 @@ pkgs.gnome-podcasts pkgs.gnome.gnome-terminal # works on phosh pkgs.inkscape + pkgs.kaiteki # Pleroma client pkgs.libreoffice-fresh # XXX colin: maybe don't want this on mobile pkgs.mesa-demos pkgs.playerctl pkgs.tdesktop # broken on phosh pkgs.vlc # works on phosh - pkgs.whalebird # pleroma client. TODO: port kaiteki to nix: https://craftplacer.moe/projects/kaiteki/ + pkgs.whalebird # pleroma client. input is broken on phosh pkgs.xterm # broken on phosh ] else []) ++ (if gui == "sway" then diff --git a/nixpatches/04-dart-2.7.0.patch b/nixpatches/04-dart-2.7.0.patch new file mode 100644 index 00000000..db5e4e1a --- /dev/null +++ b/nixpatches/04-dart-2.7.0.patch @@ -0,0 +1,302 @@ +diff --git a/pkgs/development/compilers/flutter/default.nix b/pkgs/development/compilers/flutter/default.nix +index 9eba6773448..f51aeb8b624 100644 +--- a/pkgs/development/compilers/flutter/default.nix ++++ b/pkgs/development/compilers/flutter/default.nix +@@ -4,20 +4,20 @@ let + getPatches = dir: + let files = builtins.attrNames (builtins.readDir dir); + in map (f: dir + ("/" + f)) files; +- version = "2.10.1"; ++ version = "3.0.0"; + channel = "stable"; + filename = "flutter_linux_${version}-${channel}.tar.xz"; + + # Decouples flutter derivation from dart derivation, + # use specific dart version to not need to bump dart derivation when bumping flutter. +- dartVersion = "2.16.1"; ++ dartVersion = "2.17.0"; + dartSourceBase = "https://storage.googleapis.com/dart-archive/channels"; + dartForFlutter = dart.override { + version = dartVersion; + sources = { + "${dartVersion}-x86_64-linux" = fetchurl { + url = "${dartSourceBase}/stable/release/${dartVersion}/sdk/dartsdk-linux-x64-release.zip"; +- sha256 = "sha256-PMY6DCFQC8XrlnFzOEPcwgBAs5/cAvNd78969Z+I1Fk="; ++ sha256 = "57b8fd964e47c81d467aeb95b099a670ab7e8f54a1cd74d45bcd1fdc77913d86"; + }; + }; + }; +@@ -29,7 +29,7 @@ in { + pname = "flutter"; + src = fetchurl { + url = "https://storage.googleapis.com/flutter_infra_release/releases/${channel}/linux/${filename}"; +- sha256 = "sha256-rSfwcglDV2rvJl10j7FByAWmghd2FYxrlkgYnvRO54Y="; ++ sha256 = "e96d75ec8e7dc2a46bc8dad5a9e01c391ab9310ad01c4e3940c963dd263788a0"; + }; + patches = getPatches ./patches; + }; +diff --git a/pkgs/development/compilers/flutter/flutter.nix b/pkgs/development/compilers/flutter/flutter.nix +index 43538ede339..ece25c14b55 100644 +--- a/pkgs/development/compilers/flutter/flutter.nix ++++ b/pkgs/development/compilers/flutter/flutter.nix +@@ -56,12 +56,15 @@ let + export STAMP_PATH="$FLUTTER_ROOT/bin/cache/flutter_tools.stamp" + + export DART_SDK_PATH="${dart}" ++ export DART="${dart}/bin/dart" + + HOME=../.. # required for pub upgrade --offline, ~/.pub-cache + # path is relative otherwise it's replaced by /build/flutter ++ # mkdir -p "$HOME/.cache" ++ # ln -sf "$FLUTTER_ROOT" "$HOME/.cache/flutter" + + pushd "$FLUTTER_TOOLS_DIR" +- ${dart}/bin/pub get --offline ++ ${dart}/bin/dart pub get --offline + popd + + local revision="$(cd "$FLUTTER_ROOT"; git rev-parse HEAD)" +diff --git a/pkgs/development/compilers/flutter/patches/git-dir.patch b/pkgs/development/compilers/flutter/patches/git-dir.patch +new file mode 100644 +index 00000000000..0c736f945ea +--- /dev/null ++++ b/pkgs/development/compilers/flutter/patches/git-dir.patch +@@ -0,0 +1,102 @@ ++diff --git a/dev/bots/prepare_package.dart b/dev/bots/prepare_package.dart ++index 468a91a954..5def6897ce 100644 ++--- a/dev/bots/prepare_package.dart +++++ b/dev/bots/prepare_package.dart ++@@ -525,7 +525,7 @@ class ArchiveCreator { ++ ++ Future _runGit(List args, {Directory? workingDirectory}) { ++ return _processRunner.runProcess( ++- ['git', ...args], +++ ['git', '--git-dir', '.git', ...args], ++ workingDirectory: workingDirectory ?? flutterRoot, ++ ); ++ } ++diff --git a/packages/flutter_tools/lib/src/commands/downgrade.dart b/packages/flutter_tools/lib/src/commands/downgrade.dart ++index bb0eb428a9..4a2a48bb5e 100644 ++--- a/packages/flutter_tools/lib/src/commands/downgrade.dart +++++ b/packages/flutter_tools/lib/src/commands/downgrade.dart ++@@ -118,7 +118,7 @@ class DowngradeCommand extends FlutterCommand { ++ // Detect unknown versions. ++ final ProcessUtils processUtils = _processUtils!; ++ final RunResult parseResult = await processUtils.run([ ++- 'git', 'describe', '--tags', lastFlutterVersion, +++ 'git', '--git-dir', '.git', 'describe', '--tags', lastFlutterVersion, ++ ], workingDirectory: workingDirectory); ++ if (parseResult.exitCode != 0) { ++ throwToolExit('Failed to parse version for downgrade:\n${parseResult.stderr}'); ++@@ -191,7 +191,7 @@ class DowngradeCommand extends FlutterCommand { ++ continue; ++ } ++ final RunResult parseResult = await _processUtils!.run([ ++- 'git', 'describe', '--tags', sha, +++ 'git', '--git-dir', '.git', 'describe', '--tags', sha, ++ ], workingDirectory: workingDirectory); ++ if (parseResult.exitCode == 0) { ++ buffer.writeln('Channel "${getNameForChannel(channel)}" was previously on: ${parseResult.stdout}.'); ++diff --git a/packages/flutter_tools/lib/src/version.dart b/packages/flutter_tools/lib/src/version.dart ++index f2068a6ca2..99b161689e 100644 ++--- a/packages/flutter_tools/lib/src/version.dart +++++ b/packages/flutter_tools/lib/src/version.dart ++@@ -106,7 +106,7 @@ class FlutterVersion { ++ String? channel = _channel; ++ if (channel == null) { ++ final String gitChannel = _runGit( ++- 'git rev-parse --abbrev-ref --symbolic @{u}', +++ 'git --git-dir .git rev-parse --abbrev-ref --symbolic @{u}', ++ globals.processUtils, ++ _workingDirectory, ++ ); ++@@ -114,7 +114,7 @@ class FlutterVersion { ++ if (slash != -1) { ++ final String remote = gitChannel.substring(0, slash); ++ _repositoryUrl = _runGit( ++- 'git ls-remote --get-url $remote', +++ 'git --git-dir .git ls-remote --get-url $remote', ++ globals.processUtils, ++ _workingDirectory, ++ ); ++@@ -326,7 +326,7 @@ class FlutterVersion { ++ /// the branch name will be returned as `'[user-branch]'`. ++ String getBranchName({ bool redactUnknownBranches = false }) { ++ _branch ??= () { ++- final String branch = _runGit('git rev-parse --abbrev-ref HEAD', globals.processUtils); +++ final String branch = _runGit('git --git-dir .git rev-parse --abbrev-ref HEAD', globals.processUtils); ++ return branch == 'HEAD' ? channel : branch; ++ }(); ++ if (redactUnknownBranches || _branch!.isEmpty) { ++@@ -359,7 +359,7 @@ class FlutterVersion { ++ /// wrapper that does that. ++ @visibleForTesting ++ static List gitLog(List args) { ++- return ['git', '-c', 'log.showSignature=false', 'log'] + args; +++ return ['git', '-c', 'log.showSignature=false', '--git-dir', '.git', 'log'] + args; ++ } ++ ++ /// Gets the release date of the latest available Flutter version. ++@@ -730,7 +730,7 @@ class GitTagVersion { ++ ++ static GitTagVersion determine(ProcessUtils processUtils, {String? workingDirectory, bool fetchTags = false, String gitRef = 'HEAD'}) { ++ if (fetchTags) { ++- final String channel = _runGit('git rev-parse --abbrev-ref HEAD', processUtils, workingDirectory); +++ final String channel = _runGit('git --git-dir .git rev-parse --abbrev-ref HEAD', processUtils, workingDirectory); ++ if (channel == 'dev' || channel == 'beta' || channel == 'stable') { ++ globals.printTrace('Skipping request to fetchTags - on well known channel $channel.'); ++ } else { ++@@ -739,7 +739,7 @@ class GitTagVersion { ++ } ++ // find all tags attached to the given [gitRef] ++ final List tags = _runGit( ++- 'git tag --points-at $gitRef', processUtils, workingDirectory).trim().split('\n'); +++ 'git --git-dir .git tag --points-at $gitRef', processUtils, workingDirectory).trim().split('\n'); ++ ++ // Check first for a stable tag ++ final RegExp stableTagPattern = RegExp(r'^\d+\.\d+\.\d+$'); ++@@ -760,7 +760,7 @@ class GitTagVersion { ++ // recent tag and number of commits past. ++ return parse( ++ _runGit( ++- 'git describe --match *.*.* --long --tags $gitRef', +++ 'git --git-dir .git describe --match *.*.* --long --tags $gitRef', ++ processUtils, ++ workingDirectory, ++ ) +diff --git a/pkgs/development/compilers/flutter/patches/revert-frontend_server_cache.patch b/pkgs/development/compilers/flutter/patches/revert-frontend_server_cache.patch +new file mode 100644 +index 00000000000..f68029eb7a1 +--- /dev/null ++++ b/pkgs/development/compilers/flutter/patches/revert-frontend_server_cache.patch +@@ -0,0 +1,130 @@ ++diff --git a/packages/flutter_tools/lib/src/artifacts.dart b/packages/flutter_tools/lib/src/artifacts.dart ++index 2aac9686e8..32c4b98b88 100644 ++--- a/packages/flutter_tools/lib/src/artifacts.dart +++++ b/packages/flutter_tools/lib/src/artifacts.dart ++@@ -346,10 +346,10 @@ class CachedArtifacts implements Artifacts { ++ ) { ++ switch (artifact) { ++ case HostArtifact.engineDartSdkPath: ++- final String path = _dartSdkPath(_cache); +++ final String path = _dartSdkPath(_fileSystem); ++ return _fileSystem.directory(path); ++ case HostArtifact.engineDartBinary: ++- final String path = _fileSystem.path.join(_dartSdkPath(_cache), 'bin', _hostArtifactToFileName(artifact, _platform.isWindows)); +++ final String path = _fileSystem.path.join(_dartSdkPath(_fileSystem), 'bin', _hostArtifactToFileName(artifact, _platform.isWindows)); ++ return _fileSystem.file(path); ++ case HostArtifact.flutterWebSdk: ++ final String path = _getFlutterWebSdkPath(); ++@@ -398,7 +398,7 @@ class CachedArtifacts implements Artifacts { ++ case HostArtifact.dart2jsSnapshot: ++ case HostArtifact.dartdevcSnapshot: ++ case HostArtifact.kernelWorkerSnapshot: ++- final String path = _fileSystem.path.join(_dartSdkPath(_cache), 'bin', 'snapshots', _hostArtifactToFileName(artifact, _platform.isWindows)); +++ final String path = _fileSystem.path.join(_dartSdkPath(_fileSystem), 'bin', 'snapshots', _hostArtifactToFileName(artifact, _platform.isWindows)); ++ return _fileSystem.file(path); ++ case HostArtifact.iosDeploy: ++ final String artifactFileName = _hostArtifactToFileName(artifact, _platform.isWindows); ++@@ -461,11 +461,13 @@ class CachedArtifacts implements Artifacts { ++ String _getAndroidArtifactPath(Artifact artifact, TargetPlatform platform, BuildMode mode) { ++ final String engineDir = _getEngineArtifactsPath(platform, mode)!; ++ switch (artifact) { +++ case Artifact.frontendServerSnapshotForEngineDartSdk: +++ assert(mode != BuildMode.debug, 'Artifact $artifact only available in non-debug mode.'); +++ return _fileSystem.path.join(engineDir, _artifactToFileName(artifact)); ++ case Artifact.genSnapshot: ++ assert(mode != BuildMode.debug, 'Artifact $artifact only available in non-debug mode.'); ++ final String hostPlatform = getNameForHostPlatform(getCurrentHostPlatform()); ++ return _fileSystem.path.join(engineDir, hostPlatform, _artifactToFileName(artifact)); ++- case Artifact.frontendServerSnapshotForEngineDartSdk: ++ case Artifact.constFinder: ++ case Artifact.flutterFramework: ++ case Artifact.flutterMacOSFramework: ++@@ -497,13 +499,13 @@ class CachedArtifacts implements Artifacts { ++ switch (artifact) { ++ case Artifact.genSnapshot: ++ case Artifact.flutterXcframework: +++ case Artifact.frontendServerSnapshotForEngineDartSdk: ++ final String artifactFileName = _artifactToFileName(artifact)!; ++ final String engineDir = _getEngineArtifactsPath(platform, mode)!; ++ return _fileSystem.path.join(engineDir, artifactFileName); ++ case Artifact.flutterFramework: ++ final String engineDir = _getEngineArtifactsPath(platform, mode)!; ++ return _getIosEngineArtifactPath(engineDir, environmentType, _fileSystem); ++- case Artifact.frontendServerSnapshotForEngineDartSdk: ++ case Artifact.constFinder: ++ case Artifact.flutterMacOSFramework: ++ case Artifact.flutterMacOSPodspec: ++@@ -594,14 +596,10 @@ class CachedArtifacts implements Artifacts { ++ // For script snapshots any gen_snapshot binary will do. Returning gen_snapshot for ++ // android_arm in profile mode because it is available on all supported host platforms. ++ return _getAndroidArtifactPath(artifact, TargetPlatform.android_arm, BuildMode.profile); ++- case Artifact.frontendServerSnapshotForEngineDartSdk: ++- return _fileSystem.path.join( ++- _dartSdkPath(_cache), 'bin', 'snapshots', ++- _artifactToFileName(artifact), ++- ); ++ case Artifact.flutterTester: ++ case Artifact.vmSnapshotData: ++ case Artifact.isolateSnapshotData: +++ case Artifact.frontendServerSnapshotForEngineDartSdk: ++ case Artifact.icuData: ++ final String engineArtifactsPath = _cache.getArtifactDirectory('engine').path; ++ final String platformDirName = _enginePlatformDirectoryName(platform); ++@@ -797,7 +795,7 @@ class CachedLocalEngineArtifacts implements LocalEngineArtifacts { ++ final String path = _fileSystem.path.join(_hostEngineOutPath, 'dart-sdk', 'bin', 'snapshots', _hostArtifactToFileName(artifact, _platform.isWindows)); ++ return _fileSystem.file(path); ++ case HostArtifact.dartdevcSnapshot: ++- final String path = _fileSystem.path.join(_dartSdkPath(_cache), 'bin', 'snapshots', _hostArtifactToFileName(artifact, _platform.isWindows)); +++ final String path = _fileSystem.path.join(_dartSdkPath(_fileSystem), 'bin', 'snapshots', _hostArtifactToFileName(artifact, _platform.isWindows)); ++ return _fileSystem.file(path); ++ case HostArtifact.kernelWorkerSnapshot: ++ final String path = _fileSystem.path.join(_hostEngineOutPath, 'dart-sdk', 'bin', 'snapshots', _hostArtifactToFileName(artifact, _platform.isWindows)); ++@@ -922,9 +920,7 @@ class CachedLocalEngineArtifacts implements LocalEngineArtifacts { ++ case Artifact.windowsUwpCppClientWrapper: ++ return _fileSystem.path.join(_hostEngineOutPath, artifactFileName); ++ case Artifact.frontendServerSnapshotForEngineDartSdk: ++- return _fileSystem.path.join( ++- _hostEngineOutPath, 'dart-sdk', 'bin', 'snapshots', artifactFileName, ++- ); +++ return _fileSystem.path.join(_hostEngineOutPath, 'gen', artifactFileName); ++ case Artifact.uwptool: ++ return _fileSystem.path.join(_hostEngineOutPath, artifactFileName); ++ } ++@@ -1034,8 +1030,8 @@ class OverrideArtifacts implements Artifacts { ++ } ++ ++ /// Locate the Dart SDK. ++-String _dartSdkPath(Cache cache) { ++- return cache.getRoot().childDirectory('dart-sdk').path; +++String _dartSdkPath(FileSystem fileSystem) { +++ return fileSystem.path.join(Cache.flutterRoot!, 'bin', 'cache', 'dart-sdk'); ++ } ++ ++ class _TestArtifacts implements Artifacts { ++diff --git a/packages/flutter_tools/test/general.shard/artifacts_test.dart b/packages/flutter_tools/test/general.shard/artifacts_test.dart ++index d906511a15..adfdd4bb42 100644 ++--- a/packages/flutter_tools/test/general.shard/artifacts_test.dart +++++ b/packages/flutter_tools/test/general.shard/artifacts_test.dart ++@@ -153,10 +153,6 @@ void main() { ++ artifacts.getArtifactPath(Artifact.windowsUwpDesktopPath, platform: TargetPlatform.windows_uwp_x64, mode: BuildMode.release), ++ fileSystem.path.join('root', 'bin', 'cache', 'artifacts', 'engine', 'windows-uwp-x64-release'), ++ ); ++- expect( ++- artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), ++- fileSystem.path.join('root', 'bin', 'cache', 'dart-sdk', 'bin', 'snapshots', 'frontend_server.dart.snapshot') ++- ); ++ }); ++ ++ testWithoutContext('precompiled web artifact paths are correct', () { ++@@ -322,11 +318,6 @@ void main() { ++ artifacts.getHostArtifact(HostArtifact.engineDartSdkPath).path, ++ fileSystem.path.join('/out', 'host_debug_unopt', 'dart-sdk'), ++ ); ++- expect( ++- artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk), ++- fileSystem.path.join('/out', 'host_debug_unopt', 'dart-sdk', 'bin', ++- 'snapshots', 'frontend_server.dart.snapshot') ++- ); ++ }); ++ ++ testWithoutContext('getEngineType', () { diff --git a/pkgs/kaiteki/default.nix b/pkgs/kaiteki/default.nix new file mode 100644 index 00000000..e6d5204a --- /dev/null +++ b/pkgs/kaiteki/default.nix @@ -0,0 +1,88 @@ +{ lib +, fetchFromGitHub +, flutter +, olm +, imagemagick +, makeDesktopItem +}: + +flutter.mkFlutterApp rec { + pname = "kaiteki"; + version = "1.1"; + + vendorHash = "sha256-N7s63e8z4pAFtFV9cFN+CIIg+A/s8lYfiJWrBkMkkd0="; + + src = fetchFromGitHub { + owner = "Kaiteki-Fedi"; + repo = "Kaiteki"; + rev = "0a322313071e4391949d23d9b006d74de65f58d9"; + hash = "sha256-ggDIbVwueS162m15TFaC6Tcg+0lpcVGi4x/O691sxR8"; + }; + + desktopItem = makeDesktopItem { + name = "Kaiteki"; + exec = "@out@/bin/kaiteki"; + icon = "kaiteki"; + desktopName = "Kaiteki"; + genericName = "Micro-blogging client"; + categories = [ "Network" "InstantMessaging" "GTK" ]; + }; + + sourceRoot = "source/src/kaiteki"; + + # postUnpack = '' + # mv assets assets-toplevel + # mv src/kaiteki/* . + # ''; + + buildInputs = [ + olm + ]; + + nativeBuildInputs = [ + imagemagick + ]; + + # flutterExtraFetchCommands = '' + # M=$(echo $TMP/.pub-cache/hosted/pub.dartlang.org/matrix-*) + # sed -i $M/scripts/prepare.sh \ + # -e "s|/usr/lib/x86_64-linux-gnu/libolm.so.3|/bin/sh|g" \ + # -e "s|if which flutter >/dev/null; then|exit; if which flutter >/dev/null; then|g" + + # pushd $M + # bash scripts/prepare.sh + # popd + # ''; + + # replace olm dummy path + # postConfigure = '' + # M=$(echo $depsFolder/.pub-cache/hosted/pub.dartlang.org/matrix-*) + # ln -sf ${olm}/lib/libolm.so.3 $M/ffi/olm/libolm.so + # ''; + + # postInstall = '' + # FAV=$out/app/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 s in 24 32 42 64 128 256 512; do + # D=$ICO/hicolor/''${s}x''${s}/apps + # mkdir -p $D + # convert $FAV -resize ''${s}x''${s} $D/fluffychat.png + # done + + # substituteInPlace $out/share/applications/*.desktop \ + # --subst-var out + # ''; + + meta = with lib; { + description = "The comfy Fediverse client"; + homepage = "https://craftplacer.moe/projects/kaiteki/"; + license = licenses.agpl3Plus; + # maintainers = with maintainers; [ uninsane ]; + platforms = platforms.linux; + }; +}