Compare commits

..

2 Commits

Author SHA1 Message Date
Olivier 5f7e9cada5 refactor(desktop): clean up options formatting and simplify slice logic
Refactor `modules/desktop/options.nix` to improve code readability by
expanding the `optPath` list definition and simplifying the
`wisdomSimpleSlice` configuration logic.

Also apply minor style fixes to `modules/wisdom/filebrowsers/nemo.nix`
to ensure consistent spacing within list definitions.
2026-07-16 20:55:53 -03:00
Olivier c4a0eb0a98 feat(chromium-hevc): enhance GPU configuration options and streamline desktop item creation 2026-07-16 19:51:06 -03:00
3 changed files with 74 additions and 75 deletions
+11 -12
View File
@@ -1,8 +1,5 @@
{ lib, ... }: { { lib, ... }:
# Resolve `wisdom*` HM slices for NixOS `extraModules` (`self` is not an HM specialArg). {
# Slices are gated by `chiasson.home.*.enable`; hosts only flip toggles in `home.nix`.
# Lives here (not `modules/lib/`) because `hosts/desktop-home-base.nix` consumes it and
# fragment eval order requires the definition to sort before `hosts/`.
flake.lib.wisdomCatalogExtraModules = flake.lib.wisdomCatalogExtraModules =
self: self:
let let
@@ -14,22 +11,24 @@
in in
map (name: self.homeManagerModules.${name}) names; map (name: self.homeManagerModules.${name}) names;
# Thin HM slice: an `enable` toggle that adds packages to `home.packages`, skipping
# any not `availableOn` this platform. `packages` is a `pkgs -> [ drv ]` function so
# callers only name each package once (the helper owns the platform-gating). Used by
# the trivial single-package wisdom slices so they stay one declarative block instead
# of the repeated `root/cfg` + `mkIf (root.enable && cfg.enable)` boilerplate.
flake.lib.wisdomSimpleSlice = flake.lib.wisdomSimpleSlice =
{ path, default, description, packages }: { path, default, description, packages }:
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
let let
segs = lib.splitString "." path; segs = lib.splitString "." path;
optPath = [ "chiasson" "home" ] ++ segs ++ [ "enable" ]; optPath = [
"chiasson"
"home"
]
++ segs
++ [ "enable" ];
root = config.chiasson.home;
cfg = lib.getAttrFromPath segs root;
enabled = lib.getAttrFromPath optPath config; enabled = lib.getAttrFromPath optPath config;
in in
{ {
options = lib.setAttrByPath optPath (lib.mkEnableOption description // { inherit default; }); options = lib.setAttrByPath optPath (lib.mkEnableOption description // { inherit default; });
config = lib.mkIf (config.chiasson.home.enable && enabled) { config = lib.mkIf (root.enable && enabled) {
home.packages = lib.filter (lib.meta.availableOn pkgs.stdenv.hostPlatform) (packages pkgs); home.packages = lib.filter (lib.meta.availableOn pkgs.stdenv.hostPlatform) (packages pkgs);
}; };
}; };
+45 -45
View File
@@ -5,25 +5,43 @@
cfg = config.chiasson.system.chromiumHevc; cfg = config.chiasson.system.chromiumHevc;
in 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). VA-API packages for Chromium HEVC (Intel iHD + optional NVIDIA nvidia-vaapi-driver).
Pair with `wisdomBrowsersChromiumHevc` on the user side. 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 { config = lib.mkIf cfg.enable {
hardware.graphics.enable = lib.mkDefault true; hardware.graphics.enable = lib.mkDefault true;
hardware.graphics.extraPackages = lib.mkAfter ( hardware.graphics.extraPackages = lib.mkAfter (
with pkgs; lib.optionals (cfg.gpu == "nvidia") [
[ nvidia-vaapi-driver ] pkgs.nvidia-vaapi-driver
]
); );
}; };
}; };
flake.homeManagerModules.wisdomBrowsersChromiumHevc = flake.homeManagerModules.wisdomBrowsersChromiumHevc =
{ config, lib, pkgs, ... }: { config, lib, pkgs, osConfig ? { }, ... }:
let let
root = config.chiasson.home; root = config.chiasson.home;
cfg = config.chiasson.home.browsers.chromiumHevc; cfg = config.chiasson.home.browsers.chromiumHevc;
gpu = lib.attrByPath [ "chiasson" "system" "chromiumHevc" "gpu" ] "intel" osConfig;
browserCatalog = { browserCatalog = {
"google-chrome" = { "google-chrome" = {
@@ -53,7 +71,6 @@
intel = { intel = {
driver = "iHD"; driver = "iHD";
drmDevice = "/dev/dri/renderD128"; drmDevice = "/dev/dri/renderD128";
nvdBackend = "direct";
enableFeatures = [ enableFeatures = [
"VaapiVideoDecodeLinuxGL" "VaapiVideoDecodeLinuxGL"
"VaapiVideoDecoder" "VaapiVideoDecoder"
@@ -69,7 +86,6 @@
nvidia = { nvidia = {
driver = "nvidia"; driver = "nvidia";
drmDevice = "/dev/dri/renderD129"; drmDevice = "/dev/dri/renderD129";
nvdBackend = "direct";
enableFeatures = [ enableFeatures = [
"VaapiVideoDecoder" "VaapiVideoDecoder"
"VaapiIgnoreDriverChecks" "VaapiIgnoreDriverChecks"
@@ -85,21 +101,17 @@
}; };
}; };
activeGpu = gpuProfiles.${cfg.vaapi.gpu}; activeGpu = gpuProfiles.${gpu};
mkChromiumHevc =
packageName:
let
spec = browserCatalog.${packageName};
browser = spec.package;
launcherName = spec.launcher;
enableFeatures = lib.concatStringsSep "," activeGpu.enableFeatures; enableFeatures = lib.concatStringsSep "," activeGpu.enableFeatures;
disableFeatures = lib.concatStringsSep "," activeGpu.disableFeatures; disableFeatures = lib.concatStringsSep "," activeGpu.disableFeatures;
desktopItem = pkgs.makeDesktopItem {
name = launcherName; mkDesktopItem =
spec:
pkgs.makeDesktopItem {
name = spec.launcher;
desktopName = spec.desktopName; desktopName = spec.desktopName;
genericName = "Web Browser"; genericName = "Web Browser";
exec = "${launcherName} %U"; exec = "${spec.launcher} %U";
icon = spec.icon; icon = spec.icon;
categories = [ categories = [
"Network" "Network"
@@ -113,6 +125,14 @@
"x-scheme-handler/https" "x-scheme-handler/https"
]; ];
}; };
mkChromiumHevc =
packageName:
let
spec = browserCatalog.${packageName};
browser = spec.package;
launcherName = spec.launcher;
desktopItem = mkDesktopItem spec;
in in
pkgs.runCommand launcherName pkgs.runCommand launcherName
{ {
@@ -126,7 +146,7 @@
makeWrapper ${browser}/bin/${spec.binary} $out/bin/${launcherName} \ makeWrapper ${browser}/bin/${spec.binary} $out/bin/${launcherName} \
--set LIBVA_DRIVER_NAME ${lib.escapeShellArg activeGpu.driver} \ --set LIBVA_DRIVER_NAME ${lib.escapeShellArg activeGpu.driver} \
--set LIBVA_DRM_DEVICE ${lib.escapeShellArg activeGpu.drmDevice} \ --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 "--enable-features=${enableFeatures}" \
--add-flags "--disable-features=${disableFeatures}" \ --add-flags "--disable-features=${disableFeatures}" \
${lib.concatMapStringsSep " " (a: "--add-flags ${lib.escapeShellArg a}") cfg.extraCommandLineArgs} ${lib.concatMapStringsSep " " (a: "--add-flags ${lib.escapeShellArg a}") cfg.extraCommandLineArgs}
@@ -136,50 +156,30 @@
''; '';
selectedPackages = lib.filter ( selectedPackages = lib.filter (
name: name: lib.meta.availableOn pkgs.stdenv.hostPlatform browserCatalog.${name}.package
let
spec = browserCatalog.${name};
in
lib.meta.availableOn pkgs.stdenv.hostPlatform spec.package
) cfg.packages; ) cfg.packages;
wrappers = map mkChromiumHevc selectedPackages; wrappers = map mkChromiumHevc selectedPackages;
in in
{ {
options.chiasson.home.browsers.chromiumHevc = { options.chiasson.home.browsers.chromiumHevc = {
enable = lib.mkEnableOption '' enable =
lib.mkEnableOption ''
`google-chrome-hevc`: Chromium with VA-API HEVC for Jellyfin / MSE playback. `google-chrome-hevc`: Chromium with VA-API HEVC for Jellyfin / MSE playback.
Default GPU is **Intel** (`vaapi.gpu = "intel"`): Chromium + NVIDIA VA-API is GPU stack comes from `chiasson.system.chromiumHevc.gpu` (default **intel**).
unsupported upstream (`nvidia-vaapi-driver` README) and fails with
`failed Initialize()ing the frame pool` in Jellyfin.
Requires `chiasson.system.chromiumHevc.enable` on NixOS. Requires `chiasson.system.chromiumHevc.enable` on NixOS.
'' // { ''
// {
default = true; default = true;
}; };
packages = lib.mkOption { packages = lib.mkOption {
type = lib.types.listOf ( type = lib.types.listOf (lib.types.enum (lib.attrNames browserCatalog));
lib.types.enum (lib.attrNames browserCatalog)
);
default = if pkgs.stdenv.hostPlatform.isAarch64 then [ "chromium" ] else [ "google-chrome" ]; default = if pkgs.stdenv.hostPlatform.isAarch64 then [ "chromium" ] else [ "google-chrome" ];
description = "Chromium-based browsers to wrap."; 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 { extraCommandLineArgs = lib.mkOption {
type = lib.types.listOf lib.types.str; type = lib.types.listOf lib.types.str;
default = [ ]; default = [ ];