"Create custom package for jellyfin-media-player"

This commit is contained in:
SeanOMik 2022-10-07 18:35:34 -04:00
parent 9dab96573a
commit c81d494387
Signed by: SeanOMik
GPG Key ID: 568F326C7EB33ACB
9 changed files with 191 additions and 74 deletions

View File

@ -55,6 +55,25 @@
"type": "github" "type": "github"
} }
}, },
"flatpak": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1662408312,
"narHash": "sha256-H1kmMTmXLud5duk6O+wR0zWU7TPh37y1uDB7SAfpW/w=",
"owner": "yawnt",
"repo": "declarative-nix-flatpak",
"rev": "a82b3b135f79b78c379c4f1b0c52957cd7ccf50c",
"type": "github"
},
"original": {
"owner": "yawnt",
"ref": "main",
"repo": "declarative-nix-flatpak",
"type": "github"
}
},
"git-crypt-agessh": { "git-crypt-agessh": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -130,6 +149,20 @@
} }
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": {
"lastModified": 1664904529,
"narHash": "sha256-mGlB/SQR4E9jb7fOOxCTJlwL6Mk1Dpyvi4UrOXL6C18=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b7a47253e0c8cb04c0a3f8ed3149e90229e62884",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_3": {
"locked": { "locked": {
"lastModified": 1658912196, "lastModified": 1658912196,
"narHash": "sha256-GTP5XCLPU2Hg2bQC5dVqSBF9ef5C/J6pD4qM09Ba4Gk=", "narHash": "sha256-GTP5XCLPU2Hg2bQC5dVqSBF9ef5C/J6pD4qM09Ba4Gk=",
@ -145,7 +178,7 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_3": { "nixpkgs_4": {
"locked": { "locked": {
"lastModified": 1658119717, "lastModified": 1658119717,
"narHash": "sha256-4upOZIQQ7Bc4CprqnHsKnqYfw+arJeAuU+QcpjYBXW0=", "narHash": "sha256-4upOZIQQ7Bc4CprqnHsKnqYfw+arJeAuU+QcpjYBXW0=",
@ -165,7 +198,7 @@
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"libnbtplusplus": "libnbtplusplus", "libnbtplusplus": "libnbtplusplus",
"nixpkgs": "nixpkgs_3", "nixpkgs": "nixpkgs_4",
"tomlplusplus": "tomlplusplus" "tomlplusplus": "tomlplusplus"
}, },
"locked": { "locked": {
@ -186,9 +219,10 @@
"inputs": { "inputs": {
"agenix": "agenix", "agenix": "agenix",
"fenix": "fenix", "fenix": "fenix",
"flatpak": "flatpak",
"git-crypt-agessh": "git-crypt-agessh", "git-crypt-agessh": "git-crypt-agessh",
"home-manager": "home-manager", "home-manager": "home-manager",
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs_3",
"polymc": "polymc", "polymc": "polymc",
"unstable": "unstable" "unstable": "unstable"
} }

View File

@ -18,11 +18,13 @@
git-crypt-agessh.inputs.nixpkgs.follows = "nixpkgs"; # idk if this is needed git-crypt-agessh.inputs.nixpkgs.follows = "nixpkgs"; # idk if this is needed
polymc.url = "github:PolyMC/PolyMC"; polymc.url = "github:PolyMC/PolyMC";
flatpak.url = "github:yawnt/declarative-nix-flatpak/main";
}; };
# nixpkgs.overlays = [ inputs.polymc.overlay ]; # nixpkgs.overlays = [ inputs.polymc.overlay ];
outputs = inputs@{ nixpkgs, unstable, home-manager, agenix, git-crypt-agessh, polymc, ... }: outputs = inputs@{ nixpkgs, unstable, home-manager, agenix, flatpak, git-crypt-agessh, polymc, ... }:
let let
system = "x86_64-linux"; system = "x86_64-linux";
@ -51,6 +53,9 @@
inherit (pkgs.stdenv.targetPlatform) system; inherit (pkgs.stdenv.targetPlatform) system;
config.allowUnfree = true; config.allowUnfree = true;
}; };
# _module.args.flatpak = import inputs.flatpak {
# inherit (pkgs.stdenv.targetPlatform) system;
# };
}; };
in [ in [
{ {

View File

@ -67,7 +67,7 @@
slack slack
google-chrome google-chrome
(callPackage ../../modules/pkgs/upwork.nix { inherit runCommandLocal; }) (callPackage ../../modules/pkgs/upwork.nix { inherit runCommandLocal; })
(callPackage ../../modules/pkgs/jellyfin-media-player.nix { inherit runCommandLocal; }) (libsForQt5.callPackage ../../modules/pkgs/jellyfin-media-player.nix { })
jetbrains.idea-community jetbrains.idea-community
renderdoc renderdoc
]; ];

View File

@ -3,5 +3,6 @@
imports = [ imports = [
./audio ./audio
./cli-tools.nix ./cli-tools.nix
./flatpak
]; ];
} }

21
modules/flatpak/default.nix Executable file
View File

@ -0,0 +1,21 @@
{pkgs, flatpak, ... }:
let
runtime = flatpak.lib.flatpak.fetchRuntimeFromFlatHub {
name = "org.freedesktop.Platform";
branch = "21.08";
commit = "c7252386179c4c1ecf5d93bdaec6ca82852dddfdae7112b5c3177f7424c4a928";
sha256 = "sha256-wuFiB2+x+Mj6F9idkrknvD9Su6bWr5QVhgcB8/4uBQc=";
};
jmp = flatpak.lib.flatpak.fetchAppFromFlatHub {
name = "com.github.iwalton3.jellyfin-media-player";
commit = "f26193386f3552bc7d6849078ef073d1ca94629d";
sha256 = "sha256-yxnsiou/ujd9fdP4D7J7i00uNGm0TjHgrIp0TTwUq3o=";
inherit runtime;
};
in {
services.flatpak.enable = true;
environment.systemPackages = [
flatpak.lib.flatpak.wrapFlatpakLauncher "com.github.iwalton3.jellyfin-media-player" jmp runtime
];
}

View File

@ -0,0 +1,50 @@
{ lib
, pkgs
, stdenv
, fetchFromGitHub
, cmake
, python
, unzip
, qtbase
, wrapQtAppsHook
}:
let
stdenv = pkgs.clangStdenv;
distZip = builtins.fetchurl {
url = "https://github.com/iwalton3/jellyfin-web-jmp/releases/download/jwc-10.8.1/dist.zip";
sha256 = "sha256:1mn0l89li1cv3jmazrdbdhjldbm0daphv18193jd24vhwxd4sx9z";
};
in stdenv.mkDerivation rec {
version = "v1.7.1";
pname = "jellyfin-media-player";
src = fetchFromGitHub {
owner = "jellyfin";
repo = pname;
rev = version;
sha256 = "sha256-piMqI4qxcNUSNC+0JE2KZ/cvlNgtxUOnSfrcWnBVzC0=";
};
nativeBuildInputs = [ cmake wrapQtAppsHook unzip ];
buildInputs = [ qtbase python pkgs.SDL2 pkgs.zlib-ng pkgs.fribidi pkgs.gnutls pkgs.libsForQt5.qt5.qtwebengine
pkgs.libsForQt5.qt5.qtquickcontrols pkgs.libsForQt5.qt5.qtx11extras pkgs.libsForQt5.qt5.qtwebchannel
pkgs.libcec pkgs.mpv ];
configurePhase = ''
unzip -q ${pkgs.lib.strings.escapeShellArg distZip}
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$out
'';
meta = with lib; {
description = "Jellyfin Desktop Client based on Plex Media Player.";
homepage = "https://github.com/jellyfin/jellyfin-media-player";
license = licenses.gpl2;
platforms = platforms.unix;
maintainers = with maintainers; [ seanomik ];
};
}

118
modules/pkgs/jellyfin-media-player.nix Executable file → Normal file
View File

@ -1,80 +1,78 @@
{ lib, stdenv, fetchurl, dpkg, wrapGAppsHook, autoPatchelfHook { lib
, alsa-lib, atk, at-spi2-atk, at-spi2-core, cairo, cups, dbus, expat, fontconfig, freetype , pkgs
, gdk-pixbuf, glib, gtk3, libcxx, libdrm, libnotify, libpulseaudio, libuuid, libX11, libxcb , stdenv
, libXcomposite, libXcursor, libXdamage, libXext, libXfixes, libXi, libXrandr, libXrender , fetchurl
, libXScrnSaver, libXtst, mesa, nspr, nss, openssl, pango, systemd, writeText, runCommandLocal, wget }:
# Packaging tools
, dpkg
, wrapQtAppsHook
# Dependencies
, qtbase
, qt5
, xorg
, mesa
, SDL2
, zlib-ng
, fribidi
, gnutls
, libcec
, mpv
}:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "jellyfin-media-player";
version = "1.7.1"; version = "1.7.1";
hotfix = "-1";
pname = "jellyfin-media-player";
src = runCommandLocal "${pname}_${version}_amd64-jammy.deb" src = fetchurl {
rec { url = "https://github.com/jellyfin/jellyfin-media-player/releases/download/v${version}/jellyfin-media-player_${version}${hotfix}_amd64-jammy.deb";
outputHashMode = "recursive"; sha256 = "sha256-9z3L0c+2LDPMx82biJq/Mhsb8rt6Lr+4F/jWzT5v0R4=";
outputHashAlgo = "sha256"; };
outputHash = "sha256-g2RldDAvgEpyKz+umxcaAjWfGGH9DZ56UndsIraudFg=";
nativeBuildInputs = [ wget ]; sourceRoot = ".";
unpackCmd = "dpkg-deb -x $src .";
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
} ''
# Figure out certificates
wget --no-check-certificate \
-U "Mozilla/5.0 (X11; Linux x86_64; rv:103.0)" \
https://github.com/jellyfin/jellyfin-media-player/releases/download/v1.7.1/jellyfin-media-player_1.7.1-1_amd64-jammy.deb \
-O $out
'';
nativeBuildInputs = [
dpkg
wrapGAppsHook
autoPatchelfHook
];
buildInputs = [
libcxx systemd libpulseaudio
stdenv.cc.cc alsa-lib atk at-spi2-atk at-spi2-core cairo cups
dbus expat fontconfig freetype gdk-pixbuf glib gtk3 libdrm libnotify
libuuid libX11 libxcb libXcomposite libXcursor libXdamage libXext libXfixes
libXi libXrandr libXrender libXScrnSaver libXtst mesa nspr nss pango systemd
];
libPath = lib.makeLibraryPath buildInputs;
dontWrapGApps = true;
dontBuild = true;
dontConfigure = true; dontConfigure = true;
dontBuild = true;
unpackPhase = '' nativeBuildInputs = [ wrapQtAppsHook dpkg ];
# curl -i -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:103.0) Gecko/20100101 Firefox/103.0" -O https://upwork-usw2-desktopapp.upwork.com/binaries/v5_6_10_13_3c485d1dd2af4f61/upwork_5.6.10.13_amd64.deb
echo $out buildInputs = [ qtbase qt5.qtwebengine ];
echo $src
dpkg-deb -x "$src" ./
'';
installPhase = '' installPhase = ''
runHook preInstall # Copy everything in usr to $out
mv usr $out cp -r usr/ $out/
# mv share $out
# Now it requires lib{ssl,crypto}.so.1.0.0. Fix based on Spotify pkg. # Link the web-client next to the bin file.
# https://github.com/NixOS/nixpkgs/blob/efea022d6fe0da84aa6613d4ddeafb80de713457/pkgs/applications/audio/spotify/default.nix#L129 # Without this, the qt5-webengine(?) wont load since it can't find .html files
# mkdir -p $out/lib/upwork ln -s $out/share/jellyfinmediaplayer/web-client $out/bin/web-client
# ln -s ${lib.getLib openssl}/lib/libssl.so $out/lib/upwork/libssl.so.1.0.0 '';
# ln -s ${lib.getLib openssl}/lib/libcrypto.so $out/lib/upwork/libcrypto.so.1.0.0
sed -e "s|/opt/jellyfin-media-player|$out/bin|g" -i $out/share/applications/com.github.iwalton3.jellyfin-media-player.desktop preFixup = let
makeWrapper $out/bin/jellyfinmediaplayer \ libPath = lib.makeLibraryPath [
$out/bin/jellyfinmediaplayer \ qtbase
--prefix LD_LIBRARY_PATH : ${libPath} qt5.qtwebengine qt5.qtquickcontrols qt5.qtx11extras qt5.qtwebchannel qt5.qtdeclarative
runHook postInstall xorg.libX11 # libX11.so.6
xorg.libXrandr # libXrandr.so.2
SDL2 # libSDL2-2.0.so.0
libcec # libcec.so.6
mpv # libmpv.so.1
stdenv.cc.cc.lib # libstdc++.so.6
];
in ''
patchelf \
--set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
--set-rpath "${libPath}" \
$out/bin/jellyfinmediaplayer
''; '';
meta = with lib; { meta = with lib; {
description = "Jellyfin Desktop Client based on Plex Media Player"; description = "Jellyfin Desktop Client based on Plex Media Player.";
homepage = "https://github.com/jellyfin/jellyfin-media-player"; homepage = "https://github.com/jellyfin/jellyfin-media-player";
sourceProvenance = with sourceTypes; [ binaryNativeCode ]; sourceProvenance = with sourceTypes; [ binaryNativeCode ];
license = licenses.gpl2Only; license = licenses.gpl2;
platforms = [ "x86_64-linux" ]; platforms = [ "x86_64-linux" ];
maintainers = with maintainers; [ seanomik ]; maintainers = with maintainers; [ seanomik ];
}; };

7
scripts/pull_git.py Normal file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env python3
from git import Repo
import shutil
import os
GIT_REPO_URL = "git@git.seanomik.net:SeanOMik/nixos-dotfiles.git"

View File

@ -12,17 +12,18 @@ GIT_REPO_URL = "git@git.seanomik.net:SeanOMik/nixos-dotfiles.git"
def get_yes_no_answer(question: str, error_msg: str = "ERROR: Malformed input!"): def get_yes_no_answer(question: str, error_msg: str = "ERROR: Malformed input!"):
ans = "" ans = ""
while ans != "y" or ans != "n": while True:
print(f"{question} (y,n): ", end="") print(f"{question} (y,n): ", end="")
ans = input() ans = input().lower().strip()
if ans != "y" or ans != "n": print(f"Input: \"{ans}\"");
print(error_msg)
if ans == "y": if ans == "y":
return True return True
elif ans == "n": elif ans == "n":
return False return False
print(error_msg)
## Clears the working directory ## Clears the working directory
def remove_working_dir(): def remove_working_dir():