From 65d0e2d241519e010251aca29cf5d3a71fd84f2f Mon Sep 17 00:00:00 2001 From: Simon Bruder Date: Mon, 11 Jan 2021 22:53:35 +0100 Subject: [PATCH] mpv: add defaultProfiles option --- modules/programs/mpv.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/programs/mpv.nix b/modules/programs/mpv.nix index 5901f9d0..938435f3 100644 --- a/modules/programs/mpv.nix +++ b/modules/programs/mpv.nix @@ -12,6 +12,7 @@ let mpvOptions = with types; attrsOf mpvOptionDup; mpvProfiles = with types; attrsOf mpvOptions; mpvBindings = with types; attrsOf str; + mpvDefaultProfiles = with types; listOf str; renderOption = option: rec { @@ -45,6 +46,9 @@ let concatStringsSep "\n" (mapAttrsToList (name: value: "${name} ${value}") bindings); + renderDefaultProfiles = profiles: + renderOptions { profile = concatStringsSep "," profiles; }; + mpvPackage = if cfg.scripts == [ ] then pkgs.mpv else @@ -115,6 +119,16 @@ in { ''; }; + defaultProfiles = mkOption { + description = '' + Profiles to be applied by default. Options set by them are overridden + by options set in . + ''; + type = mpvDefaultProfiles; + default = [ ]; + example = [ "gpu-hq" ]; + }; + bindings = mkOption { description = '' Input configuration written to @@ -145,6 +159,8 @@ in { } (mkIf (cfg.config != { } || cfg.profiles != { }) { xdg.configFile."mpv/mpv.conf".text = '' + ${optionalString (cfg.defaultProfiles != [ ]) + (renderDefaultProfiles cfg.defaultProfiles)} ${optionalString (cfg.config != { }) (renderOptions cfg.config)} ${optionalString (cfg.profiles != { }) (renderProfiles cfg.profiles)} '';