Skip to content

Commit

Permalink
Merge pull request #79 from fore-stun/feat/handbrake
Browse files Browse the repository at this point in the history
Add handbrake binaries on darwin
  • Loading branch information
dbaynard authored Aug 20, 2024
2 parents 917ac09 + c255d47 commit 3072d92
Show file tree
Hide file tree
Showing 5 changed files with 151 additions and 0 deletions.
2 changes: 2 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
./editors/language-server
./editors/formatter

./media/video

./network/tunnel

./utils/email
Expand Down
32 changes: 32 additions & 0 deletions media/video/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{ self, lib, nixpkgs, ... }:

let
pnames = [ "handbrake-bin" "handbrake-cli-bin" "handbrake-gui-bin" ];
in
{
overlays.video = final: prev:
let
extras = {
"handbrake-bin" = {
inherit (final) handbrake-cli-bin handbrake-gui-bin;
};
};
in
lib.foldFor pnames
(pname: {
${pname} = prev.callPackage
(./. + "/${pname}.nix")
(extras."${pname}" or { });
});
} //
lib.foldFor lib.platforms.all (system:
let
pkgs = nixpkgs.legacyPackages.${system};
in
{
packages.${system} =
lib.filterAttrs (_: lib.isDerivation) self.legacyPackages.${system};
legacyPackages.${system} = self.overlays.video
(pkgs // self.packages.${system})
pkgs;
})
21 changes: 21 additions & 0 deletions media/video/handbrake-bin.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{ lib
, handbrake-cli-bin
, handbrake-gui-bin
, handbrake
, symlinkJoin
}:

let

inherit (handbrake) pname;
inherit (handbrake-cli-bin) meta;
version = "1.8.2";

in
symlinkJoin {
name = "${pname}-${version}";
inherit pname version meta;
buildInputs = [ ];

paths = [ handbrake-cli-bin handbrake-gui-bin ];
}
50 changes: 50 additions & 0 deletions media/video/handbrake-cli-bin.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{ lib
, darwin
, fetchurl
, hostPlatform
, handbrake
, stdenvNoCC
, undmg
}:

let

inherit (handbrake) pname meta;
version = "1.8.2";

src = let name = "${pname}-${version}.dmg"; in
fetchurl
{
inherit name;
urls = [
"https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrakeCLI-${version}.dmg"
];
hash = "sha256-Tfw9cO9bYMhv2MrIfiF062usMqAfnD6cXiLzyxImRsU=";
};

handbrakeCliBin = stdenvNoCC.mkDerivation {
pname = "${pname}-cli";
inherit src version;
sourceRoot = ".";

meta = meta // {
platforms = lib.platforms.darwin;
broken = false;
mainProgram = "HandBrakeCLI";
};

nativeBuildInputs = [
undmg
];

installPhase = ''
mkdir -p "$out/bin"
cp -pR "HandBrakeCLI" "$out/bin/"
mkdir -p "$out/share/"
cp -pR "doc" "$out/share/"
'';
};

in
handbrakeCliBin
46 changes: 46 additions & 0 deletions media/video/handbrake-gui-bin.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{ lib
, darwin
, fetchurl
, hostPlatform
, handbrake
, stdenvNoCC
, undmg
}:

let

inherit (handbrake) pname meta;
version = "1.8.2";

src = let name = "${pname}-${version}.dmg"; in
fetchurl
{
inherit name;
urls = [
"https://github.com/HandBrake/HandBrake/releases/download/${version}/HandBrake-${version}.dmg"
];
hash = "sha256-pZ3Ba2qmzlBBZyYgs+6+LlG7MgXkvQpWI1nL8TI7LYQ=";
};

handbrakeBin = stdenvNoCC.mkDerivation {
pname = "${pname}-gui";
inherit src version;
sourceRoot = ".";

meta = meta // {
platforms = lib.platforms.darwin;
broken = false;
};

nativeBuildInputs = [
undmg
];

installPhase = ''
mkdir -p "$out/Applications/"
cp -pR "HandBrake.app" "$out/Applications/"
'';
};

in
handbrakeBin

0 comments on commit 3072d92

Please sign in to comment.