about summary refs log tree commit diff
path: root/pkgs/applications/video/losslesscut-bin/build-from-appimage.nix
blob: b6aa8009dcd0adf65c54cb2ba90c98ea026d7473 (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
{ appimageTools
, fetchurl
, makeWrapper
, pname
, version
, hash
, metaCommon ? { }
}:

let
  pname = "losslesscut";

  src = fetchurl {
    url = "https://github.com/mifi/lossless-cut/releases/download/v${version}/LosslessCut-linux-x86_64.AppImage";
    inherit hash;
  };

  extracted = appimageTools.extractType2 {
    inherit pname version src;
  };
in
appimageTools.wrapType2 {
  inherit pname version src;

  profile = ''
    export LC_ALL=C.UTF-8
  '';

  extraInstallCommands = ''
    (
      mkdir -p $out/share
      cd ${extracted}/usr
      find share -mindepth 1 -type d -exec mkdir -p $out/{} \;
      find share -mindepth 1 -type f,l -exec ln -s $PWD/{} $out/{} \;
    )
    ln -s ${extracted}/losslesscut.png $out/share/icons/losslesscut.png
    mkdir $out/share/applications
    cp ${extracted}/losslesscut.desktop $out/share/applications
    substituteInPlace $out/share/applications/losslesscut.desktop \
      --replace AppRun losslesscut
    source "${makeWrapper}/nix-support/setup-hook"
    wrapProgram "$out/bin/losslesscut" \
      --add-flags "--disable-seccomp-filter-sandbox"
  '';

  meta = metaCommon // {
    platforms = [ "x86_64-linux" ];
    mainProgram = "losslesscut";
  };
}