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
This commit is contained in:
parent
cee75d23a9
commit
bd2a5f009a
7 changed files with 170 additions and 138 deletions
|
@ -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" ];
|
||||
}
|
|
@ -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;
|
||||
}
|
36
pkgs/applications/video/losslesscut-bin/build-from-dmg.nix
Normal file
36
pkgs/applications/video/losslesscut-bin/build-from-dmg.nix
Normal file
|
@ -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";
|
||||
});
|
||||
}
|
|
@ -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";
|
||||
});
|
||||
}
|
|
@ -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
|
||||
);
|
||||
};
|
||||
})
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
Loading…
Reference in a new issue