cherry-studio: init at 1.0.1 (#382728)

authored by Sandro and committed by GitHub 2e8dff0a 96011017

+152
+152
pkgs/by-name/ch/cherry-studio/package.nix
···
··· 1 + { 2 + lib, 3 + stdenv, 4 + stdenvNoCC, 5 + fetchFromGitHub, 6 + cacert, 7 + yarn-berry, 8 + nodejs, 9 + electron, 10 + makeWrapper, 11 + writableTmpDirAsHomeHook, 12 + makeDesktopItem, 13 + copyDesktopItems, 14 + nix-update-script, 15 + commandLineArgs ? "", 16 + }: 17 + 18 + stdenv.mkDerivation (finalAttrs: { 19 + pname = "cherry-studio"; 20 + version = "1.0.1"; 21 + 22 + src = fetchFromGitHub { 23 + owner = "CherryHQ"; 24 + repo = "cherry-studio"; 25 + tag = "v${finalAttrs.version}"; 26 + hash = "sha256-C8D0XCwIFWG+5WakAK+TmI4VVuIYJBSgkv5ynM2Ewkc="; 27 + }; 28 + 29 + yarnOfflineCache = stdenvNoCC.mkDerivation { 30 + name = "${finalAttrs.pname}-${finalAttrs.version}-offline-cache"; 31 + inherit (finalAttrs) src; 32 + 33 + nativeBuildInputs = [ 34 + cacert 35 + yarn-berry 36 + writableTmpDirAsHomeHook 37 + ]; 38 + 39 + postConfigure = 40 + let 41 + supportedArchitectures = builtins.toJSON { 42 + os = [ 43 + "darwin" 44 + "linux" 45 + ]; 46 + cpu = [ 47 + "x64" 48 + "ia32" 49 + "arm64" 50 + ]; 51 + libc = [ 52 + "glibc" 53 + "musl" 54 + ]; 55 + }; 56 + in 57 + '' 58 + yarn config set enableTelemetry false 59 + yarn config set enableGlobalCache false 60 + yarn config set supportedArchitectures --json '${supportedArchitectures}' 61 + yarn config set cacheFolder $out 62 + ''; 63 + 64 + buildPhase = '' 65 + runHook preBuild 66 + 67 + yarn install --mode=skip-build 68 + 69 + runHook postBuild 70 + ''; 71 + 72 + outputHashMode = "recursive"; 73 + outputHash = "sha256-DrEkaXkbaY40uYH7niT10OFJH+PD7ip3A4OCwbKmtz8="; 74 + }; 75 + 76 + nativeBuildInputs = [ 77 + yarn-berry 78 + makeWrapper 79 + writableTmpDirAsHomeHook 80 + copyDesktopItems 81 + ]; 82 + 83 + env = { 84 + ELECTRON_SKIP_BINARY_DOWNLOAD = "1"; 85 + npm_config_build_from_source = "true"; 86 + npm_config_nodedir = nodejs; 87 + }; 88 + 89 + postConfigure = '' 90 + yarn config set enableTelemetry false 91 + yarn config set enableGlobalCache false 92 + export cachePath=$(mktemp -d) 93 + cp -r $yarnOfflineCache/* $cachePath 94 + yarn config set cacheFolder $cachePath 95 + yarn install --mode=skip-build 96 + ''; 97 + 98 + buildPhase = '' 99 + runHook preBuild 100 + 101 + yarn run electron-vite build 102 + yarn run electron-builder --linux --dir \ 103 + --config electron-builder.yml \ 104 + -c.electronDist="${electron}/libexec/electron" \ 105 + -c.electronVersion=${electron.version} 106 + 107 + runHook postBuild 108 + ''; 109 + 110 + desktopItems = [ 111 + (makeDesktopItem { 112 + name = "cherry-studio"; 113 + desktopName = "Cherry Studio"; 114 + comment = "A powerful AI assistant for producer."; 115 + exec = "cherry-studio --no-sandbox %U"; 116 + terminal = false; 117 + icon = "cherry-studio"; 118 + startupWMClass = "Cherry Studio"; 119 + categories = [ "Utility" ]; 120 + }) 121 + ]; 122 + 123 + installPhase = '' 124 + runHook preInstall 125 + 126 + mkdir -p $out/lib/cherry-studio 127 + cp -r dist/linux-unpacked/{resources,LICENSE*} $out/lib/cherry-studio 128 + install -Dm644 build/icon.png $out/share/pixmaps/cherry-studio.png 129 + makeWrapper "${lib.getExe electron}" $out/bin/cherry-studio \ 130 + --inherit-argv0 \ 131 + --add-flags $out/lib/cherry-studio/resources/app.asar \ 132 + --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \ 133 + --add-flags ${lib.escapeShellArg commandLineArgs} 134 + 135 + runHook postInstall 136 + ''; 137 + 138 + passthru.updateScript = nix-update-script { }; 139 + 140 + meta = { 141 + description = "Desktop client that supports for multiple LLM providers"; 142 + homepage = "https://github.com/CherryHQ/cherry-studio"; 143 + changelog = "https://github.com/CherryHQ/cherry-studio/releases/tag/v${finalAttrs.version}"; 144 + mainProgram = "cherry-studio"; 145 + platforms = lib.platforms.linux; 146 + maintainers = with lib.maintainers; [ nayeko ]; 147 + license = with lib.licenses; [ 148 + asl20 149 + unfree 150 + ]; 151 + }; 152 + })