From 3d372cd1559ec6176a68984c536c33797590ce6e Mon Sep 17 00:00:00 2001 From: Miguel Palhas Date: Mon, 24 Aug 2026 12:13:38 +0100 Subject: [PATCH] feat(mpv): hardware decode with per-host hwdec mpv shipped as a bare package with no config, so every host decoded video in software. hwdec is the only vendor-specific part, so it is an option: auto-safe everywhere, overridden on NVIDIA hosts. Co-Authored-By: Claude --- home/common/programs/desktop/default.nix | 7 +++-- home/common/programs/mpv.nix | 36 ++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 home/common/programs/mpv.nix diff --git a/home/common/programs/desktop/default.nix b/home/common/programs/desktop/default.nix index 7679f2c..9186afe 100644 --- a/home/common/programs/desktop/default.nix +++ b/home/common/programs/desktop/default.nix @@ -4,14 +4,17 @@ ... }: { - imports = [ ./darkman.nix ]; + imports = [ + ./darkman.nix + # mpv is installed by programs.mpv there, not as a bare package here. + ../mpv.nix + ]; home = { packages = with pkgs; [ # various google-chrome thunar - mpv imv pavucontrol zathura diff --git a/home/common/programs/mpv.nix b/home/common/programs/mpv.nix new file mode 100644 index 0000000..044c627 --- /dev/null +++ b/home/common/programs/mpv.nix @@ -0,0 +1,36 @@ +{ + config, + lib, + ... +}: +let + cfg = config.custom.mpv; +in +{ + options.custom.mpv = { + hwdec = lib.mkOption { + type = lib.types.str; + default = "auto-safe"; + example = "nvdec-copy"; + description = '' + Value for mpv's `hwdec`. `auto-safe` only picks a decoder mpv considers + reliable for the running driver and falls back to software otherwise, + so it is correct on Intel (arrakis) and on hosts with no usable GPU + decoder (yolo). NVIDIA hosts override it. + ''; + }; + }; + + config = { + programs.mpv = { + enable = true; + + config = { + hwdec = cfg.hwdec; + vo = lib.mkDefault "gpu-next"; + save-position-on-quit = true; + keep-open = "yes"; + }; + }; + }; +}