azure-storage-azcopy: 10.27.1 -> 10.28.0 (#377459)
[NixPkgs.git] / pkgs / by-name / vo / voicevox / package.nix
bloba12fcef8e1c03dc952c7f3be3943aa8061bcca94
2   lib,
3   stdenv,
4   buildNpmPackage,
5   fetchFromGitHub,
6   replaceVars,
7   makeDesktopItem,
8   copyDesktopItems,
9   makeWrapper,
10   electron,
11   _7zz,
12   voicevox-engine,
13   dart-sass,
16 buildNpmPackage rec {
17   pname = "voicevox";
18   version = "0.22.3";
20   src = fetchFromGitHub {
21     owner = "VOICEVOX";
22     repo = "voicevox";
23     tag = version;
24     hash = "sha256-6z+A4bJIDfN/K8IjEdt2TqEa/EDt4uQpGh+zSWfP74I=";
25   };
27   patches = [
28     (replaceVars ./hardcode-paths.patch {
29       sevenzip_path = lib.getExe _7zz;
30       voicevox_engine_path = lib.getExe voicevox-engine;
31     })
32   ];
34   postPatch = ''
35     substituteInPlace package.json \
36         --replace-fail "999.999.999" "${version}" \
37         --replace-fail "postinstall" "_postinstall"
38   '';
40   npmDepsHash = "sha256-NuKFhDb/J6G3pFYHZedKnY2hDC5GCp70DpqrST4bJMA=";
42   # unlock very specific node version bounds specified by upstream
43   npmInstallFlags = [ "--engine-strict=false" ];
45   nativeBuildInputs =
46     [
47       makeWrapper
48     ]
49     ++ lib.optionals stdenv.hostPlatform.isLinux [
50       copyDesktopItems
51     ];
53   env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
55   # disable code signing on Darwin
56   env.CSC_IDENTITY_AUTO_DISCOVERY = "false";
58   buildPhase = ''
59     runHook preBuild
61     # force sass-embedded to use our own sass instead of the bundled one
62     substituteInPlace node_modules/sass-embedded/dist/lib/src/compiler-path.js \
63         --replace-fail 'compilerCommand = (() => {' 'compilerCommand = (() => { return ["${lib.getExe dart-sass}"];'
65     # build command taken from the definition of the `electron:build` npm script
66     VITE_TARGET=electron npm exec vite build
68     cp -r ${electron.dist} electron-dist
69     chmod -R u+w electron-dist
71     npm exec electron-builder -- \
72         --dir \
73         --config electron-builder.config.js \
74         -c.electronDist=electron-dist \
75         -c.electronVersion=${electron.version}
77     runHook postBuild
78   '';
80   installPhase = ''
81     runHook preInstall
83     ${lib.optionalString stdenv.hostPlatform.isLinux ''
84       install -Dm644 public/icon.png $out/share/icons/hicolor/256x256/apps/voicevox.png
86       mkdir -p $out/share/voicevox
87       cp -r dist_electron/*-unpacked/{locales,resources{,.pak}} $out/share/voicevox
89       makeWrapper ${lib.getExe electron} $out/bin/voicevox \
90         --add-flags $out/share/voicevox/resources/app.asar \
91         --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
92         --inherit-argv0
93     ''}
95     ${lib.optionalString stdenv.hostPlatform.isDarwin ''
96       mkdir -p $out/Applications
97       cp -r dist_electron/mac*/VOICEVOX.app $out/Applications
98       makeWrapper $out/Applications/VOICEVOX.app/Contents/MacOS/VOICEVOX $out/bin/voicevox
99     ''}
101     runHook postInstall
102   '';
104   desktopItems = [
105     (makeDesktopItem {
106       name = "voicevox";
107       exec = "voicevox";
108       icon = "voicevox";
109       desktopName = "VOICEVOX";
110       categories = [ "AudioVideo" ];
111       mimeTypes = [ "application/x-voicevox" ];
112     })
113   ];
115   meta = {
116     changelog = "https://github.com/VOICEVOX/voicevox/releases/tag/${src.tag}";
117     description = "Editor for the VOICEVOX speech synthesis software";
118     homepage = "https://github.com/VOICEVOX/voicevox";
119     license = lib.licenses.lgpl3Only;
120     mainProgram = "voicevox";
121     maintainers = with lib.maintainers; [
122       tomasajt
123       eljamm
124     ];
125     platforms = electron.meta.platforms;
126   };