about summary refs log tree commit diff
path: root/nixpkgs/pkgs/applications/video/subtitleedit/default.nix
blob: 7ab14d8c1e6786654ce2056225ae27c3d1fcd506 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
{ lib
, stdenv
, copyDesktopItems
, makeDesktopItem
, makeWrapper
, fetchzip
, ffmpeg
, gtk2
, hunspell
, icoutils
, mono
, mpv
, tesseract4
, nix-update-script
}:

stdenv.mkDerivation rec {
  pname = "subtitleedit";
  version = "4.0.1";

  src = fetchzip {
    url = "https://github.com/SubtitleEdit/subtitleedit/releases/download/${version}/SE${lib.replaceStrings [ "." ] [ "" ] version}.zip";
    hash = "sha256-Z7NVn4F19Hx55YWPNmbpWZ8yQulXd50bcy2A/8pCqJ4=";
    stripRoot = false;
  };

  nativeBuildInputs = [
    copyDesktopItems
    icoutils
    makeWrapper
  ];

  runtimeLibs = lib.makeLibraryPath [
    gtk2
    hunspell
    mpv
    tesseract4
  ];

  runtimeBins = lib.makeBinPath [
    ffmpeg
    hunspell
    tesseract4
  ];

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin
    mkdir -p $out/share/icons/hicolor/{16x16,32x32,48x48,256x256}/apps

    cp -r * $out/bin/
    ln -s ${hunspell.out}/lib/libhunspell*.so $out/bin/libhunspell.so
    makeWrapper "${mono}/bin/mono" $out/bin/subtitleedit \
      --add-flags "$out/bin/SubtitleEdit.exe" \
      --prefix LD_LIBRARY_PATH : ${runtimeLibs} \
      --prefix PATH : ${runtimeBins}

    wrestool -x -t 14 SubtitleEdit.exe > subtitleedit.ico
    icotool -x -i 3 -o $out/share/icons/hicolor/16x16/apps/subtitleedit.png subtitleedit.ico
    icotool -x -i 6 -o $out/share/icons/hicolor/32x32/apps/subtitleedit.png subtitleedit.ico
    icotool -x -i 9 -o $out/share/icons/hicolor/48x48/apps/subtitleedit.png subtitleedit.ico
    icotool -x -i 10 -o $out/share/icons/hicolor/256x256/apps/subtitleedit.png subtitleedit.ico

    runHook postInstall
  '';

  desktopItems = [
    (makeDesktopItem {
      name = pname;
      desktopName = "Subtitle Edit";
      exec = "subtitleedit";
      icon = "subtitleedit";
      comment = meta.description;
      categories = [ "Video" ];
    })
  ];

  passthru.updateScript = nix-update-script { };

  meta = with lib; {
    description = "A subtitle editor";
    homepage = "https://nikse.dk/subtitleedit";
    license = licenses.gpl3Plus;
    longDescription = ''
      With Subtitle Edit you can easily adjust a subtitle if it is out of sync with
      the video in several different ways. You can also use it for making
      new subtitles from scratch (using the time-line /waveform/spectrogram)
      or for translating subtitles.
    '';
    maintainers = with maintainers; [ paveloom ];
    platforms = platforms.all;
    sourceProvenance = with sourceTypes; [ binaryNativeCode ];
  };
}