mpv: support includes directives (#6391)

to allow mixing imperative and declarative config
the includes are at the end of the config
This commit is contained in:
Matthieu Coudron
2025-02-04 12:07:35 +01:00
committed by GitHub
parent 066ba0c5cf
commit 7abcf59a36
3 changed files with 25 additions and 0 deletions

View File

@@ -130,6 +130,19 @@ in {
'';
};
includes = mkOption {
type = types.listOf types.str;
default = [ ];
example = literalExpression ''
[
"~/path/to/config.inc";
"~/path/to/conditional.inc";
]
'';
description =
"List of configuration files to include at the end of mpv.conf.";
};
profiles = mkOption {
description = ''
Sub-configuration options for specific profiles written to
@@ -207,6 +220,14 @@ in {
home.packages = [ mpvPackage ];
programs.mpv.finalPackage = mpvPackage;
}
(mkIf (cfg.includes != [ ]) {
xdg.configFile."mpv/mpv.conf" = {
text = lib.mkAfter
(concatMapStringsSep "\n" (x: "include=${x}") cfg.includes);
};
})
(mkIf (cfg.config != { } || cfg.profiles != { }) {
xdg.configFile."mpv/mpv.conf".text = ''
${optionalString (cfg.defaultProfiles != [ ])

View File

@@ -11,3 +11,5 @@ vo=%5%vdpau
alang=%2%en
profile-desc=%26%profile for dvd:// streams
include=manual.conf

View File

@@ -16,6 +16,8 @@
# script-binding uosc/video #! Video tracks
'';
includes = [ "manual.conf" ];
config = {
force-window = true;
ytdl-format = "bestvideo+bestaudio";