1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 runCommandLocal,
6 mbrola-voices,
7}:
8
9let
10 pname = "mbrola";
11 version = "3.3-unstable-2024-01-29";
12
13 meta = with lib; {
14 license = licenses.agpl3Plus;
15 maintainers = with maintainers; [ davidak ];
16 platforms = platforms.all;
17 description = "Speech synthesizer based on the concatenation of diphones";
18 homepage = "https://github.com/numediart/MBROLA";
19 };
20
21 bin = stdenv.mkDerivation {
22 pname = "${pname}-bin";
23 inherit version;
24
25 src = fetchFromGitHub {
26 owner = "numediart";
27 repo = "MBROLA";
28 rev = "bf17e9e1416a647979ac683657a536e8ca5d880e";
29 hash = "sha256-ZjCl1gx/6sGtpXAYO4sAh6dutjwzClQ7kZoq0WaaBlU=";
30 };
31
32 # required for cross compilation
33 makeFlags = [ "CC=${stdenv.cc.targetPrefix}cc" ];
34
35 env = lib.optionalAttrs stdenv.cc.isGNU {
36 NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration";
37 };
38
39 installPhase = ''
40 runHook preInstall
41 install -D Bin/mbrola $out/bin/mbrola
42 rm -rf $out/share/mbrola/voices/*
43 runHook postInstall
44 '';
45
46 meta = meta // {
47 description = "Speech synthesizer based on the concatenation of diphones (binary only)";
48 };
49 };
50
51in
52runCommandLocal "${pname}-${version}"
53 {
54 inherit pname version meta;
55 }
56 ''
57 mkdir -p "$out/share/mbrola"
58 ln -s '${mbrola-voices}/data' "$out/share/mbrola/voices"
59 ln -s '${bin}/bin' "$out/"
60 ''