feat(chromium-hevc): enhance GPU configuration options and streamline desktop item creation
This commit is contained in:
@@ -5,25 +5,43 @@
|
||||
cfg = config.chiasson.system.chromiumHevc;
|
||||
in
|
||||
{
|
||||
options.chiasson.system.chromiumHevc.enable = lib.mkEnableOption ''
|
||||
options.chiasson.system.chromiumHevc = {
|
||||
enable = lib.mkEnableOption ''
|
||||
VA-API packages for Chromium HEVC (Intel iHD + optional NVIDIA nvidia-vaapi-driver).
|
||||
Pair with `wisdomBrowsersChromiumHevc` on the user side.
|
||||
'';
|
||||
|
||||
gpu = lib.mkOption {
|
||||
type = lib.types.enum [
|
||||
"intel"
|
||||
"nvidia"
|
||||
];
|
||||
default = "intel";
|
||||
description = ''
|
||||
VA-API stack for the `*-hevc` browser launchers. Use **intel** for Jellyfin
|
||||
(Chromium + nvidia-vaapi-driver is unsupported upstream and fails with
|
||||
`failed Initialize()ing the frame pool` in Jellyfin). **nvidia** adds the
|
||||
nvidia-vaapi-driver and keep renderD129 + VaapiOnNvidiaGPUs for experiments only.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
hardware.graphics.enable = lib.mkDefault true;
|
||||
hardware.graphics.extraPackages = lib.mkAfter (
|
||||
with pkgs;
|
||||
[ nvidia-vaapi-driver ]
|
||||
lib.optionals (cfg.gpu == "nvidia") [
|
||||
pkgs.nvidia-vaapi-driver
|
||||
]
|
||||
);
|
||||
};
|
||||
};
|
||||
|
||||
flake.homeManagerModules.wisdomBrowsersChromiumHevc =
|
||||
{ config, lib, pkgs, ... }:
|
||||
{ config, lib, pkgs, osConfig ? { }, ... }:
|
||||
let
|
||||
root = config.chiasson.home;
|
||||
cfg = config.chiasson.home.browsers.chromiumHevc;
|
||||
gpu = lib.attrByPath [ "chiasson" "system" "chromiumHevc" "gpu" ] "intel" osConfig;
|
||||
|
||||
browserCatalog = {
|
||||
"google-chrome" = {
|
||||
@@ -53,7 +71,6 @@
|
||||
intel = {
|
||||
driver = "iHD";
|
||||
drmDevice = "/dev/dri/renderD128";
|
||||
nvdBackend = "direct";
|
||||
enableFeatures = [
|
||||
"VaapiVideoDecodeLinuxGL"
|
||||
"VaapiVideoDecoder"
|
||||
@@ -69,7 +86,6 @@
|
||||
nvidia = {
|
||||
driver = "nvidia";
|
||||
drmDevice = "/dev/dri/renderD129";
|
||||
nvdBackend = "direct";
|
||||
enableFeatures = [
|
||||
"VaapiVideoDecoder"
|
||||
"VaapiIgnoreDriverChecks"
|
||||
@@ -85,21 +101,17 @@
|
||||
};
|
||||
};
|
||||
|
||||
activeGpu = gpuProfiles.${cfg.vaapi.gpu};
|
||||
|
||||
mkChromiumHevc =
|
||||
packageName:
|
||||
let
|
||||
spec = browserCatalog.${packageName};
|
||||
browser = spec.package;
|
||||
launcherName = spec.launcher;
|
||||
activeGpu = gpuProfiles.${gpu};
|
||||
enableFeatures = lib.concatStringsSep "," activeGpu.enableFeatures;
|
||||
disableFeatures = lib.concatStringsSep "," activeGpu.disableFeatures;
|
||||
desktopItem = pkgs.makeDesktopItem {
|
||||
name = launcherName;
|
||||
|
||||
mkDesktopItem =
|
||||
spec:
|
||||
pkgs.makeDesktopItem {
|
||||
name = spec.launcher;
|
||||
desktopName = spec.desktopName;
|
||||
genericName = "Web Browser";
|
||||
exec = "${launcherName} %U";
|
||||
exec = "${spec.launcher} %U";
|
||||
icon = spec.icon;
|
||||
categories = [
|
||||
"Network"
|
||||
@@ -113,6 +125,14 @@
|
||||
"x-scheme-handler/https"
|
||||
];
|
||||
};
|
||||
|
||||
mkChromiumHevc =
|
||||
packageName:
|
||||
let
|
||||
spec = browserCatalog.${packageName};
|
||||
browser = spec.package;
|
||||
launcherName = spec.launcher;
|
||||
desktopItem = mkDesktopItem spec;
|
||||
in
|
||||
pkgs.runCommand launcherName
|
||||
{
|
||||
@@ -126,7 +146,7 @@
|
||||
makeWrapper ${browser}/bin/${spec.binary} $out/bin/${launcherName} \
|
||||
--set LIBVA_DRIVER_NAME ${lib.escapeShellArg activeGpu.driver} \
|
||||
--set LIBVA_DRM_DEVICE ${lib.escapeShellArg activeGpu.drmDevice} \
|
||||
--set NVD_BACKEND ${lib.escapeShellArg activeGpu.nvdBackend} \
|
||||
--set NVD_BACKEND direct \
|
||||
--add-flags "--enable-features=${enableFeatures}" \
|
||||
--add-flags "--disable-features=${disableFeatures}" \
|
||||
${lib.concatMapStringsSep " " (a: "--add-flags ${lib.escapeShellArg a}") cfg.extraCommandLineArgs}
|
||||
@@ -136,50 +156,30 @@
|
||||
'';
|
||||
|
||||
selectedPackages = lib.filter (
|
||||
name:
|
||||
let
|
||||
spec = browserCatalog.${name};
|
||||
in
|
||||
lib.meta.availableOn pkgs.stdenv.hostPlatform spec.package
|
||||
name: lib.meta.availableOn pkgs.stdenv.hostPlatform browserCatalog.${name}.package
|
||||
) cfg.packages;
|
||||
|
||||
wrappers = map mkChromiumHevc selectedPackages;
|
||||
in
|
||||
{
|
||||
options.chiasson.home.browsers.chromiumHevc = {
|
||||
enable = lib.mkEnableOption ''
|
||||
enable =
|
||||
lib.mkEnableOption ''
|
||||
`google-chrome-hevc`: Chromium with VA-API HEVC for Jellyfin / MSE playback.
|
||||
|
||||
Default GPU is **Intel** (`vaapi.gpu = "intel"`): Chromium + NVIDIA VA-API is
|
||||
unsupported upstream (`nvidia-vaapi-driver` README) and fails with
|
||||
`failed Initialize()ing the frame pool` in Jellyfin.
|
||||
|
||||
GPU stack comes from `chiasson.system.chromiumHevc.gpu` (default **intel**).
|
||||
Requires `chiasson.system.chromiumHevc.enable` on NixOS.
|
||||
'' // {
|
||||
''
|
||||
// {
|
||||
default = true;
|
||||
};
|
||||
|
||||
packages = lib.mkOption {
|
||||
type = lib.types.listOf (
|
||||
lib.types.enum (lib.attrNames browserCatalog)
|
||||
);
|
||||
type = lib.types.listOf (lib.types.enum (lib.attrNames browserCatalog));
|
||||
default = if pkgs.stdenv.hostPlatform.isAarch64 then [ "chromium" ] else [ "google-chrome" ];
|
||||
description = "Chromium-based browsers to wrap.";
|
||||
};
|
||||
|
||||
vaapi.gpu = lib.mkOption {
|
||||
type = lib.types.enum [
|
||||
"intel"
|
||||
"nvidia"
|
||||
];
|
||||
default = "intel";
|
||||
description = ''
|
||||
VA-API stack for `google-chrome-hevc`. Use **intel** for Jellyfin (Chromium +
|
||||
nvidia-vaapi-driver is unsupported and hits frame-pool init errors). **nvidia**
|
||||
keeps renderD129 + VaapiOnNvidiaGPUs for experiments only.
|
||||
'';
|
||||
};
|
||||
|
||||
extraCommandLineArgs = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [ ];
|
||||
|
||||
Reference in New Issue
Block a user