From 5248460d2413b8ac7dab135b689898734d186f78 Mon Sep 17 00:00:00 2001 From: xaltsc Date: Sat, 20 Jun 2026 16:22:02 +0200 Subject: [PATCH 1/5] flake: add Closes #513 --- .gitignore | 3 + dev/nix/flake/flake-parts.nix | 5 ++ dev/nix/flake/systems.nix | 3 + dev/nix/package/_package.nix | 131 ++++++++++++++++++++++++++++++++++ dev/nix/package/default.nix | 24 +++++++ flake.lock | 111 ++++++++++++++++++++++++++++ flake.nix | 18 +++++ 7 files changed, 295 insertions(+) create mode 100644 dev/nix/flake/flake-parts.nix create mode 100644 dev/nix/flake/systems.nix create mode 100644 dev/nix/package/_package.nix create mode 100644 dev/nix/package/default.nix create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index cbe6031ed..df6b2d86e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,9 @@ build/ dist/ src/target/ +# Nix +result + # Python __pycache__/ *.pyc diff --git a/dev/nix/flake/flake-parts.nix b/dev/nix/flake/flake-parts.nix new file mode 100644 index 000000000..9469fe7d6 --- /dev/null +++ b/dev/nix/flake/flake-parts.nix @@ -0,0 +1,5 @@ +{ inputs, ... }: { + imports = [ + inputs.flake-parts.flakeModules.modules + ]; +} diff --git a/dev/nix/flake/systems.nix b/dev/nix/flake/systems.nix new file mode 100644 index 000000000..804b32fcf --- /dev/null +++ b/dev/nix/flake/systems.nix @@ -0,0 +1,3 @@ +{ inputs, ... }: { + systems = inputs.nixpkgs.lib.systems.flakeExposed; +} diff --git a/dev/nix/package/_package.nix b/dev/nix/package/_package.nix new file mode 100644 index 000000000..804e271c7 --- /dev/null +++ b/dev/nix/package/_package.nix @@ -0,0 +1,131 @@ +{ + lib, + fetchFromGitHub, + rustPlatform, + stdenv, + symlinkJoin, + pkg-config, + wrapGAppsHook4, + + # Needed at runtime by CEF + libGL, + + # Dependencies + ffmpeg, + mpv-unwrapped, + cef-binary, + libxkbcommon, + libxcb, +}: +let + mpvPrefix = symlinkJoin { + name = "mpv-external-prefix"; + paths = [ + (lib.getDev mpv-unwrapped) + (lib.getLib mpv-unwrapped) + ]; + }; + + # Jellyfin expects CEF in a certain layout. + # Cf the Stremio package for the same issue. + # Can't symlinkJoin here though because CEF uses the realpaths to determine icudtl.dat path + # Trivial compilation and should stay correctly linked. + # There's likely a Rust issue that is the reason why for the fixup. + cef = stdenv.mkDerivation (finalAttrs: { + name = "cef-for-jellyfin"; + dontUnpack = true; + installPhase = '' + mkdir -p $out + cp -r ${cef-binary}/Release/* $out/ + cp -r ${cef-binary}/Resources/* $out/ + ''; + }); +in +rustPlatform.buildRustPackage (finalAttrs: { + pname = "jellyfin-desktop"; + version = "3.0.0-unstable-2026-06-18"; + + src = fetchFromGitHub { + owner = "jellyfin"; + repo = "jellyfin-desktop"; + rev = "096a01257fc4993d1b3eb785c5d8176f734d9364"; + hash = "sha256-pP+NXdI39+vxNkKLsHuibiKhMCOk7+iHC4lBhJpRfeg="; + }; + + # Fixes some Cargo.lock issues + cargoRoot = "src"; + cargoHash = "sha256-GqSk6ZjY34esHGBmaY7sbFjQI6q9e4J3Qu87tFEW6O0="; + cargoLock = { + # Fixes some other Cargo.lock issues + lockFile = "${finalAttrs.src}/src/Cargo.lock"; + outputHashes = { + "wl-proxy-0.1.2" = "sha256-8NMNPhBSW2gLXc9bwyg2kmHb12XIaV6b4PjM62xLldQ="; + }; + }; + + strictDeps = true; + + nativeBuildInputs = [ + wrapGAppsHook4 + rustPlatform.bindgenHook # fixes clang issues + pkg-config + ]; + + buildInputs = [ + libxcb + libxkbcommon + ffmpeg + ]; + + buildPhase = '' + runHook preBuild + cargo xtask build \ + --cef-path ${cef} \ + --external-mpv ${mpvPrefix} \ + --out build/ + ''; + + installPhase = '' + runHook preInstall + + install -Dm755 \ + build/jellyfin-desktop \ + $out/bin/jellyfin-desktop + + install -Dm644 \ + resources/linux/org.jellyfin.JellyfinDesktop.desktop \ + $out/share/applications/org.jellyfin.JellyfinDesktop.desktop + install -Dm644 \ + resources/linux/org.jellyfin.JellyfinDesktop.metainfo.xml \ + $out/share/metainfo/org.jellyfin.JellyfinDesktop.metainfo.xml + install -Dm644 \ + resources/linux/org.jellyfin.JellyfinDesktop.svg \ + $out/share/icons/hicolor/scalable/apps/org.jellyfin.JellyfinDesktop.svg + + runHook postInstall + ''; + + preFixup = '' + gappsWrapperArgs+=( + --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ libGL ]}" \ + ) + ''; + + doCheck = false; + + meta = { + description = "Jellyfin desktop client"; + homepage = "https://github.com/jellyfin/jellyfin-desktop"; + license = lib.licenses.gpl2Only; + mainProgram = "jellyfin-desktop"; + # TODO: add myself once this goes on nixpkgs. + maintainers = with lib.maintainers; [ + { + email = "hey+dev@xaltsc.dev"; + name = "xaltsc"; + github = "xaltsc"; + githubId = 41400742; + } + ]; + }; +}) diff --git a/dev/nix/package/default.nix b/dev/nix/package/default.nix new file mode 100644 index 000000000..f9ab1c4e9 --- /dev/null +++ b/dev/nix/package/default.nix @@ -0,0 +1,24 @@ +{ inputs, ... }: { + imports = [ + inputs.flake-parts.flakeModules.easyOverlay + ]; + + perSystem = + { + system, + pkgs, + config, + ... + }: + { + overlayAttrs = { + inherit (config.packages) jellyfin-desktop; + }; + packages = rec { + jellyfin-desktop = pkgs.callPackage ./_package.nix { + inherit (inputs.cef-update.legacyPackages.${system}) cef-binary; + }; + default = jellyfin-desktop; + }; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..228ac4601 --- /dev/null +++ b/flake.lock @@ -0,0 +1,111 @@ +{ + "nodes": { + "cef-update": { + "locked": { + "lastModified": 1781788986, + "narHash": "sha256-aZFFyEnt1t4eZf2FCfDDlKD6bmFc1hzKueTCn85pZbY=", + "owner": "r-ryantm", + "repo": "nixpkgs", + "rev": "0a22c82e7765034aa210d581608266b368e89f2e", + "type": "github" + }, + "original": { + "owner": "r-ryantm", + "ref": "auto-update/cef-binary", + "repo": "nixpkgs", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1778716662, + "narHash": "sha256-m1Yf0wZ8j1OHjTc2UwHwyQRSnNeSgLJOd7q5Y45hzi4=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f7c1a2d347e4c52d5fb8d10cb4d94b5884e546fb", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "import-tree": { + "locked": { + "lastModified": 1778781969, + "narHash": "sha256-Jjuz5CmSkur8KvLDoGa+vylEp+RkQtv4mt/qcMznpH0=", + "owner": "denful", + "repo": "import-tree", + "rev": "d321337efd0f23a9eb14a42adb7b2c29313ab274", + "type": "github" + }, + "original": { + "owner": "denful", + "repo": "import-tree", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1781577229, + "narHash": "sha256-lrp67w8AulE9Ks53n27I45ADSzbOCn4H+CNW1Ck8B+8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "567a49d1913ce81ac6e9582e3553dd90a955875f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "lastModified": 1777168982, + "narHash": "sha256-GOkGPcboWE9BmGCRMLX3worL4EMnsnG8MyKmXNeYuhQ=", + "owner": "nix-community", + "repo": "nixpkgs.lib", + "rev": "f5901329dade4a6ea039af1433fb087bd9c1fe14", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixpkgs.lib", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1781216227, + "narHash": "sha256-9mUW6gNwoN2SWc/l0fW4svPNOulXLl8ijqKyeSOGgJE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "a0374025a863d007d98e3297f6aa46cc3141c2f0", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-26.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "cef-update": "cef-update", + "flake-parts": "flake-parts", + "import-tree": "import-tree", + "nixpkgs": "nixpkgs", + "nixpkgs-stable": "nixpkgs-stable" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..c9d77ac04 --- /dev/null +++ b/flake.nix @@ -0,0 +1,18 @@ +{ + description = "Jellyfin Desktop Client"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-26.05"; + + # TODO: Temporary until nixpkgs is updated + cef-update.url = "github:r-ryantm/nixpkgs/auto-update/cef-binary"; + + flake-parts.url = "github:hercules-ci/flake-parts"; + import-tree.url = "github:denful/import-tree"; + }; + + outputs = + inputs@{ flake-parts, import-tree, ... }: + flake-parts.lib.mkFlake { inherit inputs; } (import-tree ./dev/nix); +} From 9de6c796ea4348f11051b8a95e154f4c82e3a34d Mon Sep 17 00:00:00 2001 From: xaltsc Date: Mon, 22 Jun 2026 04:43:03 +0200 Subject: [PATCH 2/5] flake: expose knob to manually update CEF Closes #525 --- dev/nix/package/_package.nix | 29 +++++++++++++++++-------- dev/nix/package/_updated-cef-binary.nix | 10 +++++++++ dev/nix/package/default.nix | 12 +++------- flake.lock | 23 +++----------------- flake.nix | 3 --- 5 files changed, 36 insertions(+), 41 deletions(-) create mode 100644 dev/nix/package/_updated-cef-binary.nix diff --git a/dev/nix/package/_package.nix b/dev/nix/package/_package.nix index 804e271c7..b713d8a9d 100644 --- a/dev/nix/package/_package.nix +++ b/dev/nix/package/_package.nix @@ -10,6 +10,9 @@ # Needed at runtime by CEF libGL, + # Updated CEF + new-cef, + # Dependencies ffmpeg, mpv-unwrapped, @@ -26,6 +29,19 @@ let ]; }; + src = ../../..; + + cef-required-version = + let + lockFile = lib.importTOML "${src}/src/Cargo.lock"; + cefPackage = lib.findFirst (p: p.name == "cef") { version = "+FAILED"; } lockFile.package; + in + builtins.elemAt (lib.splitString "+" cefPackage.version) 1; + + # Assuming new-cef version always matches this repo needed version + # If it's the same version, then avoid unnecessary compilation and use the provided one. + cef-bin = if cef-required-version != cef-binary.version then new-cef else cef-binary; + # Jellyfin expects CEF in a certain layout. # Cf the Stremio package for the same issue. # Can't symlinkJoin here though because CEF uses the realpaths to determine icudtl.dat path @@ -36,22 +52,17 @@ let dontUnpack = true; installPhase = '' mkdir -p $out - cp -r ${cef-binary}/Release/* $out/ - cp -r ${cef-binary}/Resources/* $out/ + cp -r ${cef-bin}/Release/* $out/ + cp -r ${cef-bin}/Resources/* $out/ ''; }); + in rustPlatform.buildRustPackage (finalAttrs: { + inherit src; pname = "jellyfin-desktop"; version = "3.0.0-unstable-2026-06-18"; - src = fetchFromGitHub { - owner = "jellyfin"; - repo = "jellyfin-desktop"; - rev = "096a01257fc4993d1b3eb785c5d8176f734d9364"; - hash = "sha256-pP+NXdI39+vxNkKLsHuibiKhMCOk7+iHC4lBhJpRfeg="; - }; - # Fixes some Cargo.lock issues cargoRoot = "src"; cargoHash = "sha256-GqSk6ZjY34esHGBmaY7sbFjQI6q9e4J3Qu87tFEW6O0="; diff --git a/dev/nix/package/_updated-cef-binary.nix b/dev/nix/package/_updated-cef-binary.nix new file mode 100644 index 000000000..661e66d9e --- /dev/null +++ b/dev/nix/package/_updated-cef-binary.nix @@ -0,0 +1,10 @@ +{ cef-binary }: +cef-binary.override { + version = "149.0.4"; + gitRevision = "2f1bfd8"; + chromiumVersion = "149.0.7827.156"; + srcHashes = { + aarch64-linux = "sha256-iQmnlonux7I+2ACEtpdmlS1E4A+aNFgylRsykD+KgKA="; + x86_64-linux = "sha256-bUNgdnXkfta/pA0c/OE20E53IFKfjxxENdS6Hc0YObI="; + }; +} diff --git a/dev/nix/package/default.nix b/dev/nix/package/default.nix index f9ab1c4e9..9528a8e38 100644 --- a/dev/nix/package/default.nix +++ b/dev/nix/package/default.nix @@ -4,20 +4,14 @@ ]; perSystem = - { - system, - pkgs, - config, - ... - }: + { pkgs, config, ... }: { overlayAttrs = { inherit (config.packages) jellyfin-desktop; }; packages = rec { - jellyfin-desktop = pkgs.callPackage ./_package.nix { - inherit (inputs.cef-update.legacyPackages.${system}) cef-binary; - }; + jellyfin-desktop = pkgs.callPackage ./_package.nix { new-cef = cef-binary; }; + cef-binary = pkgs.callPackage ./_updated-cef-binary.nix { }; default = jellyfin-desktop; }; }; diff --git a/flake.lock b/flake.lock index 228ac4601..56a464a03 100644 --- a/flake.lock +++ b/flake.lock @@ -1,21 +1,5 @@ { "nodes": { - "cef-update": { - "locked": { - "lastModified": 1781788986, - "narHash": "sha256-aZFFyEnt1t4eZf2FCfDDlKD6bmFc1hzKueTCn85pZbY=", - "owner": "r-ryantm", - "repo": "nixpkgs", - "rev": "0a22c82e7765034aa210d581608266b368e89f2e", - "type": "github" - }, - "original": { - "owner": "r-ryantm", - "ref": "auto-update/cef-binary", - "repo": "nixpkgs", - "type": "github" - } - }, "flake-parts": { "inputs": { "nixpkgs-lib": "nixpkgs-lib" @@ -82,11 +66,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1781216227, - "narHash": "sha256-9mUW6gNwoN2SWc/l0fW4svPNOulXLl8ijqKyeSOGgJE=", + "lastModified": 1781808408, + "narHash": "sha256-0sOb6OIaD/K1zHxBhpmlKvkADfe0n8+l4Jj2e1Q0r3w=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a0374025a863d007d98e3297f6aa46cc3141c2f0", + "rev": "e8210c649915deed7080033cdbabcc19e40bb899", "type": "github" }, "original": { @@ -98,7 +82,6 @@ }, "root": { "inputs": { - "cef-update": "cef-update", "flake-parts": "flake-parts", "import-tree": "import-tree", "nixpkgs": "nixpkgs", diff --git a/flake.nix b/flake.nix index c9d77ac04..224176eb7 100644 --- a/flake.nix +++ b/flake.nix @@ -5,9 +5,6 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-26.05"; - # TODO: Temporary until nixpkgs is updated - cef-update.url = "github:r-ryantm/nixpkgs/auto-update/cef-binary"; - flake-parts.url = "github:hercules-ci/flake-parts"; import-tree.url = "github:denful/import-tree"; }; From d42a910f3f3abe66095b734f2861acc3d684cacf Mon Sep 17 00:00:00 2001 From: xaltsc Date: Fri, 26 Jun 2026 00:39:44 +0200 Subject: [PATCH 3/5] flake: better packaging and related improvements --- dev/nix/package/_packages/cef-binary.nix | 26 ++++++ dev/nix/package/_packages/cef-lib.nix | 16 ++++ .../jellyfin-desktop.nix} | 68 ++++------------ .../package/_packages/mpv-external-prefix.nix | 13 +++ dev/nix/package/_packages/update-cef.sh | 81 +++++++++++++++++++ dev/nix/package/_updated-cef-binary.nix | 10 --- dev/nix/package/default.nix | 32 ++++++-- 7 files changed, 177 insertions(+), 69 deletions(-) create mode 100644 dev/nix/package/_packages/cef-binary.nix create mode 100644 dev/nix/package/_packages/cef-lib.nix rename dev/nix/package/{_package.nix => _packages/jellyfin-desktop.nix} (57%) create mode 100644 dev/nix/package/_packages/mpv-external-prefix.nix create mode 100755 dev/nix/package/_packages/update-cef.sh delete mode 100644 dev/nix/package/_updated-cef-binary.nix diff --git a/dev/nix/package/_packages/cef-binary.nix b/dev/nix/package/_packages/cef-binary.nix new file mode 100644 index 000000000..7667f5020 --- /dev/null +++ b/dev/nix/package/_packages/cef-binary.nix @@ -0,0 +1,26 @@ +{ cef-binary }: +let + version = "149.0.4"; +in +( + if (cef-binary.version == version) then + cef-binary + else + (cef-binary.override { + inherit version; + gitRevision = "2f1bfd8"; + chromiumVersion = "149.0.7827.156"; + srcHashes = { + aarch64-linux = "sha256-iQmnlonux7I+2ACEtpdmlS1E4A+aNFgylRsykD+KgKA="; + x86_64-linux = "sha256-bUNgdnXkfta/pA0c/OE20E53IFKfjxxENdS6Hc0YObI="; + }; + }) +).overrideAttrs + (old: { + # make nix understand that src and version are defined in this file + inherit (old) src version; + + passthru = old.passthru // { + updateScript = ./update-cef.sh; + }; + }) diff --git a/dev/nix/package/_packages/cef-lib.nix b/dev/nix/package/_packages/cef-lib.nix new file mode 100644 index 000000000..d5aca5027 --- /dev/null +++ b/dev/nix/package/_packages/cef-lib.nix @@ -0,0 +1,16 @@ +{ stdenv, cef-binary }: +# Jellyfin expects CEF in a certain layout. +# Cf the Stremio package for the same issue. +# Can't symlinkJoin here though because CEF uses the realpaths to determine icudtl.dat path +# Trivial compilation and should stay correctly linked. +# There's likely a Rust issue that is the reason why for the fixup. +stdenv.mkDerivation (finalAttrs: { + pname = "cef-lib"; + inherit (cef-binary) version; + dontUnpack = true; + installPhase = '' + mkdir -p $out + cp -r ${cef-binary}/Release/* $out/ + cp -r ${cef-binary}/Resources/* $out/ + ''; +}) diff --git a/dev/nix/package/_package.nix b/dev/nix/package/_packages/jellyfin-desktop.nix similarity index 57% rename from dev/nix/package/_package.nix rename to dev/nix/package/_packages/jellyfin-desktop.nix index b713d8a9d..af5fe4c1e 100644 --- a/dev/nix/package/_package.nix +++ b/dev/nix/package/_packages/jellyfin-desktop.nix @@ -1,74 +1,40 @@ { lib, - fetchFromGitHub, rustPlatform, - stdenv, - symlinkJoin, pkg-config, wrapGAppsHook4, # Needed at runtime by CEF libGL, - # Updated CEF - new-cef, - # Dependencies ffmpeg, - mpv-unwrapped, - cef-binary, libxkbcommon, libxcb, -}: -let - mpvPrefix = symlinkJoin { - name = "mpv-external-prefix"; - paths = [ - (lib.getDev mpv-unwrapped) - (lib.getLib mpv-unwrapped) - ]; - }; - - src = ../../..; + cef-lib, + mpv-external-prefix, - cef-required-version = - let - lockFile = lib.importTOML "${src}/src/Cargo.lock"; - cefPackage = lib.findFirst (p: p.name == "cef") { version = "+FAILED"; } lockFile.package; - in - builtins.elemAt (lib.splitString "+" cefPackage.version) 1; - - # Assuming new-cef version always matches this repo needed version - # If it's the same version, then avoid unnecessary compilation and use the provided one. - cef-bin = if cef-required-version != cef-binary.version then new-cef else cef-binary; - - # Jellyfin expects CEF in a certain layout. - # Cf the Stremio package for the same issue. - # Can't symlinkJoin here though because CEF uses the realpaths to determine icudtl.dat path - # Trivial compilation and should stay correctly linked. - # There's likely a Rust issue that is the reason why for the fixup. - cef = stdenv.mkDerivation (finalAttrs: { - name = "cef-for-jellyfin"; - dontUnpack = true; - installPhase = '' - mkdir -p $out - cp -r ${cef-bin}/Release/* $out/ - cp -r ${cef-bin}/Resources/* $out/ - ''; - }); - -in + lastModifiedDate, +}: rustPlatform.buildRustPackage (finalAttrs: { - inherit src; + src = ../../../..; pname = "jellyfin-desktop"; - version = "3.0.0-unstable-2026-06-18"; + version = + let + majorVersion = + (lib.importTOML "${finalAttrs.src}/${finalAttrs.cargoRoot}/Cargo.toml").workspace.package.version; + + s = b: l: builtins.substring b l lastModifiedDate; + date = "${s 0 4}-${s 4 2}-${s 6 2}"; + in + "${majorVersion}-${date}"; # Fixes some Cargo.lock issues cargoRoot = "src"; cargoHash = "sha256-GqSk6ZjY34esHGBmaY7sbFjQI6q9e4J3Qu87tFEW6O0="; cargoLock = { # Fixes some other Cargo.lock issues - lockFile = "${finalAttrs.src}/src/Cargo.lock"; + lockFile = "${finalAttrs.src}/${finalAttrs.cargoRoot}/Cargo.lock"; outputHashes = { "wl-proxy-0.1.2" = "sha256-8NMNPhBSW2gLXc9bwyg2kmHb12XIaV6b4PjM62xLldQ="; }; @@ -91,8 +57,8 @@ rustPlatform.buildRustPackage (finalAttrs: { buildPhase = '' runHook preBuild cargo xtask build \ - --cef-path ${cef} \ - --external-mpv ${mpvPrefix} \ + --cef-path ${cef-lib} \ + --external-mpv ${mpv-external-prefix} \ --out build/ ''; diff --git a/dev/nix/package/_packages/mpv-external-prefix.nix b/dev/nix/package/_packages/mpv-external-prefix.nix new file mode 100644 index 000000000..a7e6d69c4 --- /dev/null +++ b/dev/nix/package/_packages/mpv-external-prefix.nix @@ -0,0 +1,13 @@ +{ + symlinkJoin, + lib, + mpv-unwrapped, +}: +symlinkJoin { + pname = "mpv-external-prefix"; + inherit (mpv-unwrapped) version; + paths = [ + (lib.getDev mpv-unwrapped) + (lib.getLib mpv-unwrapped) + ]; +} diff --git a/dev/nix/package/_packages/update-cef.sh b/dev/nix/package/_packages/update-cef.sh new file mode 100755 index 000000000..2ac604467 --- /dev/null +++ b/dev/nix/package/_packages/update-cef.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl gnused jq nix-update cargo rustc git + +set -euo pipefail + +export NIX_CONFIG="experimental-features = nix-command flakes" + +if [ -f "${PWD}/flake.nix" ]; then + ROOT="${PWD}" +else + ROOT="$(git rev-parse --show-toplevel)" +fi + +PACKAGE_PATH="${ROOT}/dev/nix/package/_packages" +PACKAGE="cef-binary" + +target_version=$(cargo metadata --format-version 1 --locked --manifest-path "${ROOT}/src/Cargo.toml" \ + | jq -r 'first(.packages[] | select(.name=="cef") | .version) + // error("Cannot determine version")' \ + | cut -d+ -f2) + +get_attr() { + local attr="$1" + local default_system='${builtins.currentSystem}' + local system="${2:-$default_system}" + nix-instantiate --eval -E \ + "(builtins.getFlake \"${ROOT}\") + .packages.${system} + .${PACKAGE}.${attr}" \ + | tr -d '"' +} + +current_version="$(get_attr 'version')" + +echo "Target version : $target_version" +echo "Current version: $current_version" + +if [[ "$target_version" == "$current_version" ]]; then + echo "Package is up-to-date" + exit 0 +fi + + +version_json=$(curl --silent https://cef-builds.spotifycdn.com/index.json \ + | jq '[ .linux64.versions[] + | select (.channel == "stable") + | select (.cef_version | startswith("'"${target_version}"'")) + ][0]') + +cef_version=$(echo "$version_json" | jq -r '.cef_version' | cut -d'+' -f1) +git_revision=$(echo "$version_json" | jq -r '.cef_version' | cut -d'+' -f2 | cut -c 2-) +chromium_version=$(echo "$version_json" | jq -r '.chromium_version') + +echo "Latest version: $cef_version" + +if [[ "$cef_version" == "$current_version" ]]; then + echo "Package is up-to-date, rust crate cef has an unsupported version" + exit 1 +fi + + + +update_nix_value() { + local key="$1" + local value="${2:-}" + sed -i "s|$key = \".*\"|$key = \"$value\"|" "${PACKAGE_PATH}/${PACKAGE}.nix" +} + +update_nix_value version "$cef_version" +update_nix_value gitRevision "$git_revision" +update_nix_value chromiumVersion "$chromium_version" + +update_hashes () { + local system="$1" + local url="$(get_attr 'src.url' "${system}")" + local hash=$(nix store prefetch-file --json "${url}" | jq -r .hash) + update_nix_value "${system}" "${hash}" +} + +update_hashes x86_64-linux +update_hashes aarch64-linux diff --git a/dev/nix/package/_updated-cef-binary.nix b/dev/nix/package/_updated-cef-binary.nix deleted file mode 100644 index 661e66d9e..000000000 --- a/dev/nix/package/_updated-cef-binary.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ cef-binary }: -cef-binary.override { - version = "149.0.4"; - gitRevision = "2f1bfd8"; - chromiumVersion = "149.0.7827.156"; - srcHashes = { - aarch64-linux = "sha256-iQmnlonux7I+2ACEtpdmlS1E4A+aNFgylRsykD+KgKA="; - x86_64-linux = "sha256-bUNgdnXkfta/pA0c/OE20E53IFKfjxxENdS6Hc0YObI="; - }; -} diff --git a/dev/nix/package/default.nix b/dev/nix/package/default.nix index 9528a8e38..bfc0db4ba 100644 --- a/dev/nix/package/default.nix +++ b/dev/nix/package/default.nix @@ -1,18 +1,34 @@ -{ inputs, ... }: { +{ inputs, self, ... }: { imports = [ inputs.flake-parts.flakeModules.easyOverlay ]; - perSystem = - { pkgs, config, ... }: + { + pkgs, + lib, + config, + ... + }: { overlayAttrs = { inherit (config.packages) jellyfin-desktop; }; - packages = rec { - jellyfin-desktop = pkgs.callPackage ./_package.nix { new-cef = cef-binary; }; - cef-binary = pkgs.callPackage ./_updated-cef-binary.nix { }; - default = jellyfin-desktop; - }; + packages = ( + lib.fix ( + p: + (lib.mapAttrs (n: d: pkgs.callPackage ./_packages/${n}.nix d) { + cef-binary = { }; + cef-lib = { inherit (p) cef-binary; }; + jellyfin-desktop = { + inherit (p) cef-lib mpv-external-prefix; + inherit (self) lastModifiedDate; + }; + mpv-external-prefix = { }; + }) + // { + default = p.jellyfin-desktop; + } + ) + ); }; } From bfd987f7a87a38f7824dbbdd129c9fa1f4bac9e1 Mon Sep 17 00:00:00 2001 From: xaltsc Date: Mon, 6 Jul 2026 05:25:36 +0200 Subject: [PATCH 4/5] flake: use patchelf instead of wrapGApps Closes #540 --- .../package/_packages/jellyfin-desktop.nix | 23 ++++++------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/dev/nix/package/_packages/jellyfin-desktop.nix b/dev/nix/package/_packages/jellyfin-desktop.nix index af5fe4c1e..965a338fb 100644 --- a/dev/nix/package/_packages/jellyfin-desktop.nix +++ b/dev/nix/package/_packages/jellyfin-desktop.nix @@ -2,7 +2,6 @@ lib, rustPlatform, pkg-config, - wrapGAppsHook4, # Needed at runtime by CEF libGL, @@ -31,7 +30,6 @@ rustPlatform.buildRustPackage (finalAttrs: { # Fixes some Cargo.lock issues cargoRoot = "src"; - cargoHash = "sha256-GqSk6ZjY34esHGBmaY7sbFjQI6q9e4J3Qu87tFEW6O0="; cargoLock = { # Fixes some other Cargo.lock issues lockFile = "${finalAttrs.src}/${finalAttrs.cargoRoot}/Cargo.lock"; @@ -43,7 +41,6 @@ rustPlatform.buildRustPackage (finalAttrs: { strictDeps = true; nativeBuildInputs = [ - wrapGAppsHook4 rustPlatform.bindgenHook # fixes clang issues pkg-config ]; @@ -82,10 +79,12 @@ rustPlatform.buildRustPackage (finalAttrs: { runHook postInstall ''; - preFixup = '' - gappsWrapperArgs+=( - --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ libGL ]}" \ - ) + postFixup = '' + old_rpath="$(patchelf --print-rpath $out/bin/jellyfin-desktop)" + patchelf \ + --set-rpath "$old_rpath:${lib.makeLibraryPath [ libGL ]}" \ + --add-needed libGL.so \ + $out/bin/jellyfin-desktop ''; doCheck = false; @@ -95,14 +94,6 @@ rustPlatform.buildRustPackage (finalAttrs: { homepage = "https://github.com/jellyfin/jellyfin-desktop"; license = lib.licenses.gpl2Only; mainProgram = "jellyfin-desktop"; - # TODO: add myself once this goes on nixpkgs. - maintainers = with lib.maintainers; [ - { - email = "hey+dev@xaltsc.dev"; - name = "xaltsc"; - github = "xaltsc"; - githubId = 41400742; - } - ]; + maintainers = with lib.maintainers; [ xaltsc ]; }; }) From ab81d0524d73f6923e4cf2e50e9979c9fb64ce11 Mon Sep 17 00:00:00 2001 From: xaltsc Date: Mon, 22 Jun 2026 21:40:27 +0200 Subject: [PATCH 5/5] flake: add home module Closes #531 --- dev/nix/home/default.nix | 126 +++++++++++++++++++++++++++++++++++++++ flake.lock | 51 +++++++++++++--- flake.nix | 2 + 3 files changed, 171 insertions(+), 8 deletions(-) create mode 100644 dev/nix/home/default.nix diff --git a/dev/nix/home/default.nix b/dev/nix/home/default.nix new file mode 100644 index 000000000..f9fd694e9 --- /dev/null +++ b/dev/nix/home/default.nix @@ -0,0 +1,126 @@ +{ inputs, config, ... }: +let + packages = config.flake.packages; +in +{ + imports = [ inputs.home-manager.flakeModules.home-manager ]; + flake.homeModules = rec { + default = jellyfin-desktop; + jellyfin-desktop = + { + config, + lib, + pkgs, + ... + }: + let + cfg = config.programs.jellyfin-desktop; + inherit (lib) + mkEnableOption + mkOption + mkIf + types + literalExpression + ; + + inherit (types) nullOr; + + jsonFormat = pkgs.formats.json { }; + + in + { + options.programs.jellyfin-desktop = { + enable = mkEnableOption "Enable jellyfin-desktop"; + package = mkOption { + description = "Package for jellyfin-desktop"; + type = types.package; + default = packages.${pkgs.stdenv.hostPlatform.system}.jellyfin-desktop; + defaultText = literalExpression ".packages.$system.jellyfin-desktop"; + }; + settings = + let + warningSuffix = "(if set, this option will overwrite settings on each generation)"; + in + (lib.mapAttrs + ( + _: v: + v + // { + type = nullOr v.type; + description = "${v.description} ${warningSuffix}."; + default = null; + } + ) + { + serverUrl = mkOption { + description = "Server URL"; + type = types.str; + example = "https://myserver.mydomain.tld"; + }; + + transparentTitlebar = mkOption { + description = "Whether to enable transparent title bar"; + type = types.bool; + example = true; + }; + + hideScrollbar = mkOption { + description = "Whether to hide scrollbar"; + type = types.bool; + example = true; + }; + + deviceName = mkOption { + description = "Device Name"; + type = types.str; + example = "myhost (jellyfin-desktop)"; + }; + + } + ); + extraConfig = mkOption { + description = '' + Extra configuration to append to `settings.json`. + Translated from nix to JSON. + Values defined here overwrite those in settings. + ''; + type = jsonFormat.type; + default = { }; + example = { + someOption = true; + someOtherOption = false; + }; + }; + }; + + config = mkIf cfg.enable { + home.packages = [ + # don't use the overlay as there's already a "jellyfin-desktop" package on nixpkgs. + cfg.package + ]; + + home.activation.mergeJellyfinDesktopConfiguration = + let + nonNullSettings = (lib.attrsets.filterAttrs (_: v: v != null) cfg.settings) // cfg.extraConfig; + newSettingsFile = pkgs.writeText "jfnd-settings.json" (builtins.toJSON nonNullSettings); + target = "${config.xdg.configHome}/jellyfin-desktop/settings.json"; + jq = lib.getExe pkgs.jq; + in + (mkIf (nonNullSettings != { }) ( + lib.hm.dag.entryAfter [ "writeBoundary" ] '' + if [ -f "${target}" ]; then + ${jq} -s '.[0] * .[1]' "${target}" "${newSettingsFile}" > "${target}.hm-tmp.json" + chmod --reference="${target}" "${target}.hm-tmp.json" + chown --reference="${target}" "${target}.hm-tmp.json" + $DRY_RUN_CMD mv "${target}.hm-tmp.json" "${target}" + else + $DRY_RUN_CMD mkdir -p "$(dirname "${target}")" + $DRY_RUN_CMD cp "${newSettingsFile}" "${target}" + $DRY_RUN_CMD chmod u+rw "${target}" + fi + '' + )); + }; + }; + }; +} diff --git a/flake.lock b/flake.lock index 56a464a03..e6483d347 100644 --- a/flake.lock +++ b/flake.lock @@ -18,6 +18,24 @@ "type": "github" } }, + "home-manager": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1782233665, + "narHash": "sha256-h/xOtrByoA/Ak1lWHn0O1lVZz4qWYbwOSLQ8YSwQO0I=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "062581938b4a378a82dfbb294b494808157153a1", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, "import-tree": { "locked": { "lastModified": 1778781969, @@ -35,16 +53,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1781577229, - "narHash": "sha256-lrp67w8AulE9Ks53n27I45ADSzbOCn4H+CNW1Ck8B+8=", + "lastModified": 1781607440, + "narHash": "sha256-rxO+uc/KFbSJp+pgyXRuAX6QlG9hJdnt0BXpEQRXY+U=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "567a49d1913ce81ac6e9582e3553dd90a955875f", + "rev": "3e41b24abd260e8f71dbe2f5737d24122f972158", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } @@ -66,11 +84,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1781808408, - "narHash": "sha256-0sOb6OIaD/K1zHxBhpmlKvkADfe0n8+l4Jj2e1Q0r3w=", + "lastModified": 1782116945, + "narHash": "sha256-G3tw/IXmaH6IQ2upZvhuN9sG8CkuX+BLuJDpE8hz0Ds=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e8210c649915deed7080033cdbabcc19e40bb899", + "rev": "34268251cf5547d39063f2c5ea9a196246f7f3a6", "type": "github" }, "original": { @@ -80,11 +98,28 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1781577229, + "narHash": "sha256-lrp67w8AulE9Ks53n27I45ADSzbOCn4H+CNW1Ck8B+8=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "567a49d1913ce81ac6e9582e3553dd90a955875f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "flake-parts": "flake-parts", + "home-manager": "home-manager", "import-tree": "import-tree", - "nixpkgs": "nixpkgs", + "nixpkgs": "nixpkgs_2", "nixpkgs-stable": "nixpkgs-stable" } } diff --git a/flake.nix b/flake.nix index 224176eb7..d57a644ae 100644 --- a/flake.nix +++ b/flake.nix @@ -7,6 +7,8 @@ flake-parts.url = "github:hercules-ci/flake-parts"; import-tree.url = "github:denful/import-tree"; + + home-manager.url = "github:nix-community/home-manager"; }; outputs =