about summary refs log tree commit diff
path: root/pkgs/applications/video
diff options
context:
space:
mode:
authorShamrock Lee <44064051+ShamrockLee@users.noreply.github.com>2022-01-13 12:04:08 +0800
committerShamrock Lee <44064051+ShamrockLee@users.noreply.github.com>2022-12-08 13:57:55 +0000
commitbd2a5f009a87fcfd33797b31407b4dfe2aee269b (patch)
treef489f8943d09b955fe685e2af3d67946c4be00c2 /pkgs/applications/video
parentcee75d23a9825985cad20b0deaac752766f6725c (diff)
losslesscut-bin: refactor the build expression
* appimage.nix -> build-from-appimage.nix to avoid confusion
* .appimage -> x86_64-appimage to allow packaging binaries for architectures
* Pass chromium flag --disable-seccomp-filter-sandbox to the executable
* Use hostPlatform instead of stdenvNoCC.hostPlatform
* Remove unnessesary intermediate variables
Diffstat (limited to 'pkgs/applications/video')
-rw-r--r--pkgs/applications/video/losslesscut-bin/appimage.nix44
-rw-r--r--pkgs/applications/video/losslesscut-bin/build-from-appimage.nix58
-rw-r--r--pkgs/applications/video/losslesscut-bin/build-from-dmg.nix36
-rw-r--r--pkgs/applications/video/losslesscut-bin/build-from-windows.nix37
-rw-r--r--pkgs/applications/video/losslesscut-bin/default.nix56
-rw-r--r--pkgs/applications/video/losslesscut-bin/dmg.nix31
-rw-r--r--pkgs/applications/video/losslesscut-bin/windows.nix46
7 files changed, 170 insertions, 138 deletions
diff --git a/pkgs/applications/video/losslesscut-bin/appimage.nix b/pkgs/applications/video/losslesscut-bin/appimage.nix
deleted file mode 100644
index 8e84406c60ebf..0000000000000
--- a/pkgs/applications/video/losslesscut-bin/appimage.nix
+++ /dev/null
@@ -1,44 +0,0 @@
-{ appimageTools, lib, fetchurl, version, sha256 }:
-
-let
-  pname = "losslesscut";
-  nameRepo = "lossless-cut";
-  nameCamel = "LosslessCut";
-  name = "${pname}-${version}";
-  nameSource = "${nameCamel}-linux-x86_64.AppImage";
-  nameExecutable = "losslesscut";
-  owner = "mifi";
-  src = fetchurl {
-    url = "https://github.com/${owner}/${nameRepo}/releases/download/v${version}/${nameSource}";
-    name = nameSource;
-    inherit sha256;
-  };
-  extracted = appimageTools.extractType2 {
-    inherit name src;
-  };
-in appimageTools.wrapType2 {
-  inherit name src;
-
-  profile = ''
-    export LC_ALL=C.UTF-8
-  '';
-
-  extraPkgs = ps: appimageTools.defaultFhsEnvArgs.multiPkgs ps;
-
-  extraInstallCommands = ''
-    mv $out/bin/{${name},${nameExecutable}}
-    (
-      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}/${nameExecutable}.png $out/share/icons/${nameExecutable}.png
-    mkdir $out/share/applications
-    cp ${extracted}/${nameExecutable}.desktop $out/share/applications
-    substituteInPlace $out/share/applications/${nameExecutable}.desktop \
-        --replace AppRun ${nameExecutable}
-  '';
-
-  meta.platforms = with lib.platforms; [ "x86_64-linux" ];
-}
diff --git a/pkgs/applications/video/losslesscut-bin/build-from-appimage.nix b/pkgs/applications/video/losslesscut-bin/build-from-appimage.nix
new file mode 100644
index 0000000000000..d75adb88f359c
--- /dev/null
+++ b/pkgs/applications/video/losslesscut-bin/build-from-appimage.nix
@@ -0,0 +1,58 @@
+{ lib
+, appimageTools
+, fetchurl
+, makeWrapper
+, gtk3
+, gsettings-desktop-schemas
+, 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
+  '';
+
+  extraPkgs = ps: appimageTools.defaultFhsEnvArgs.multiPkgs ps;
+
+  extraInstallCommands = ''
+    mv $out/bin/{${pname}-${version},losslesscut}
+    (
+      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";
+  };
+}) // {
+  inherit pname version;
+}
diff --git a/pkgs/applications/video/losslesscut-bin/build-from-dmg.nix b/pkgs/applications/video/losslesscut-bin/build-from-dmg.nix
new file mode 100644
index 0000000000000..dac04e779e2b9
--- /dev/null
+++ b/pkgs/applications/video/losslesscut-bin/build-from-dmg.nix
@@ -0,0 +1,36 @@
+{ lib
+, stdenvNoCC
+, fetchurl
+, undmg
+, pname
+, version
+, hash
+, metaCommon ? { }
+}:
+
+let
+  pname = "losslesscut";
+  src = fetchurl {
+    url = "https://github.com/mifi/lossless-cut/releases/download/v${version}/LosslessCut-mac-x64.dmg";
+    inherit hash;
+  };
+in
+stdenvNoCC.mkDerivation {
+  inherit pname version src;
+
+  nativeBuildInputs = [ undmg ];
+
+  sourceRoot = "LosslessCut.app";
+
+  installPhase = ''
+    mkdir -p "$out/Applications/LosslessCut.app"
+    cp -R . "$out/Applications/LosslessCut.app"
+    mkdir -p "$out/bin"
+    ln -s "$out/Applications/LosslessCut.app/Contents/MacOS/LosslessCut" "$out/bin/losslesscut"
+  '';
+
+  meta = metaCommon // (with lib; {
+    platforms = platforms.darwin;
+    mainProgram = "losslesscut";
+  });
+}
diff --git a/pkgs/applications/video/losslesscut-bin/build-from-windows.nix b/pkgs/applications/video/losslesscut-bin/build-from-windows.nix
new file mode 100644
index 0000000000000..ddaf873806448
--- /dev/null
+++ b/pkgs/applications/video/losslesscut-bin/build-from-windows.nix
@@ -0,0 +1,37 @@
+{ lib
+, stdenvNoCC
+, fetchurl
+, p7zip
+, pname
+, version
+, hash
+, metaCommon ? { }
+}:
+
+stdenvNoCC.mkDerivation {
+  inherit pname version;
+
+  src = fetchurl {
+    url = "https://github.com/mifi/lossless-cut/releases/download/v${version}/LosslessCut-win-x64.7z";
+    inherit hash;
+  };
+
+  nativeBuildInputs = [ p7zip ];
+
+  unpackPhase = ''
+    7z x $src -oLosslessCut-win-x64
+  '';
+
+  sourceRoot = "LosslessCut-win-x64";
+
+  installPhase = ''
+    mkdir -p $out/bin $out/libexec
+    (cd .. && mv LosslessCut-win-x64 $out/libexec)
+    ln -s "$out/libexec/LosslessCut-win-x64/LosslessCut.exe" "$out/bin/LosslessCut.exe"
+  '';
+
+  meta = metaCommon // (with lib; {
+    platforms = platforms.windows;
+    mainProgram = "LosslessCut.exe";
+  });
+}
diff --git a/pkgs/applications/video/losslesscut-bin/default.nix b/pkgs/applications/video/losslesscut-bin/default.nix
index 77dd6e0c35fa2..7d5f8fe1ddeae 100644
--- a/pkgs/applications/video/losslesscut-bin/default.nix
+++ b/pkgs/applications/video/losslesscut-bin/default.nix
@@ -1,24 +1,46 @@
-{ callPackage, stdenvNoCC, lib }:
+{ lib
+, callPackage
+, buildPackages
+, hostPlatform
+}:
+
 let
+  pname = "losslesscut";
   version = "3.46.2";
-  appimage = callPackage ./appimage.nix { inherit version; sha256 = "sha256-p+HscYsChR90JHdYjurY4OOHgveGXbJomz1klBCsF2Q="; };
-  dmg = callPackage ./dmg.nix { inherit version; sha256 = "sha256-350MHWwyjCdvIv6W6lX6Hr6PLDiAwO/e+KW0yKi/Yoc="; };
-  windows = callPackage ./windows.nix { inherit version; sha256 = "sha256-48ifhvIWSPmmnBnW8tP7NeWPIWJYWNqGP925O50CAwQ="; };
-in (
-  if stdenvNoCC.isDarwin then dmg
-  else if stdenvNoCC.isCygwin then windows
-  else appimage
-).overrideAttrs
-(oldAttrs: {
-  meta = with lib; {
+  metaCommon = with lib; {
     description = "The swiss army knife of lossless video/audio editing";
     homepage = "https://mifi.no/losslesscut/";
     license = licenses.gpl2Only;
     maintainers = with maintainers; [ ShamrockLee ];
-  } // oldAttrs.meta // {
-    platforms =
-      appimage.meta.platforms
-      ++ dmg.meta.platforms
-      ++ windows.meta.platforms;
   };
-})
+  x86_64-appimage = callPackage ./build-from-appimage.nix {
+    inherit pname version metaCommon;
+    hash = "sha256-p+HscYsChR90JHdYjurY4OOHgveGXbJomz1klBCsF2Q=";
+    inherit (buildPackages) makeWrapper;
+  };
+  x86_64-dmg = callPackage ./build-from-dmg.nix {
+    inherit pname version metaCommon;
+    hash = "sha256-350MHWwyjCdvIv6W6lX6Hr6PLDiAwO/e+KW0yKi/Yoc=";
+  };
+  x86_64-windows = callPackage ./build-from-windows.nix {
+    inherit pname version metaCommon;
+    hash = "sha256-48ifhvIWSPmmnBnW8tP7NeWPIWJYWNqGP925O50CAwQ=";
+  };
+in
+(
+  if hostPlatform.isDarwin then x86_64-dmg
+  else if hostPlatform.isCygwin then x86_64-windows
+  else x86_64-appimage
+).overrideAttrs
+  (oldAttrs: {
+    passthru = (oldAttrs.passthru or { }) // {
+      inherit x86_64-appimage x86_64-dmg x86_64-windows;
+    };
+    meta = oldAttrs.meta // {
+      platforms = lib.unique (
+        x86_64-appimage.meta.platforms
+          ++ x86_64-dmg.meta.platforms
+          ++ x86_64-windows.meta.platforms
+      );
+    };
+  })
diff --git a/pkgs/applications/video/losslesscut-bin/dmg.nix b/pkgs/applications/video/losslesscut-bin/dmg.nix
deleted file mode 100644
index e334c0a58b9a6..0000000000000
--- a/pkgs/applications/video/losslesscut-bin/dmg.nix
+++ /dev/null
@@ -1,31 +0,0 @@
-{ stdenvNoCC, lib, fetchurl, undmg, version , sha256 }:
-
-let
-  pname = "losslesscut";
-  nameRepo = "lossless-cut";
-  nameCamel = "LosslessCut";
-  nameSource = "${nameCamel}-mac-x64.dmg";
-  nameApp = nameCamel + ".app";
-  owner = "mifi";
-  src = fetchurl {
-    url = "https://github.com/${owner}/${nameRepo}/releases/download/v${version}/${nameSource}";
-    name = nameSource;
-    inherit sha256;
-  };
-in stdenvNoCC.mkDerivation {
-  inherit pname version src;
-
-  nativeBuildInputs = [ undmg ];
-
-  unpackPhase = ''
-    undmg ${src}
-  '';
-  sourceRoot = nameApp;
-
-  installPhase = ''
-    mkdir -p $out/Applications/${nameApp}
-    cp -R . $out/Applications/${nameApp}
-  '';
-
-  meta.platforms = lib.platforms.darwin;
-}
diff --git a/pkgs/applications/video/losslesscut-bin/windows.nix b/pkgs/applications/video/losslesscut-bin/windows.nix
deleted file mode 100644
index 89ccbca483231..0000000000000
--- a/pkgs/applications/video/losslesscut-bin/windows.nix
+++ /dev/null
@@ -1,46 +0,0 @@
-{ stdenvNoCC
-, lib
-, fetchurl
-, p7zip
-, version
-, sha256
-, useMklink ? false
-, customSymlinkCommand ? null
-}:
-let
-  pname = "losslesscut";
-  nameRepo = "lossless-cut";
-  nameCamel = "LosslessCut";
-  nameSourceBase = "${nameCamel}-win-x64";
-  nameSource = "${nameSourceBase}.7z";
-  nameExecutable = "${nameCamel}.exe";
-  owner = "mifi";
-  getSymlinkCommand = if (customSymlinkCommand != null) then customSymlinkCommand
-    else if useMklink then (targetPath: linkPath: "mklink ${targetPath} ${linkPath}")
-    else (targetPath: linkPath: "ln -s ${targetPath} ${linkPath}");
-in stdenvNoCC.mkDerivation {
-  inherit pname version sha256;
-
-  src = fetchurl {
-    name = nameSource;
-    url = "https://github.com/${owner}/${nameRepo}/releases/download/v${version}/${nameSource}";
-    inherit sha256;
-  };
-
-  nativeBuildInputs = [ p7zip ];
-
-  unpackPhase = ''
-    7z x $src -o${nameSourceBase}
-  '';
-
-  sourceRoot = nameSourceBase;
-
-  installPhase = ''
-    mkdir -p $out/bin $out/libexec
-    cd ..
-    mv ${nameSourceBase} $out/libexec
-
-  '' + (getSymlinkCommand "${nameSourceBase}/${nameExecutable}" "$out/bin/${nameExecutable}");
-
-  meta.platforms = lib.platforms.windows;
-}