1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2024-12-14 11:57:55 +00:00

mpv: add scriptOpts option, fix tests (#3491)

This commit is contained in:
Chuang Zhu 2023-03-21 18:33:36 +08:00 committed by GitHub
parent a8f5ca239f
commit e386ec640e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 53 additions and 18 deletions

4
.github/CODEOWNERS vendored
View file

@ -203,8 +203,8 @@ Makefile @thiagokokada
/modules/programs/micro.nix @MForster
/tests/modules/programs/micro @MForster
/modules/programs/mpv.nix @tadeokondrak @thiagokokada
/tests/modules/programs/mpv @thiagokokada
/modules/programs/mpv.nix @tadeokondrak @thiagokokada @chuangzhu
/tests/modules/programs/mpv @thiagokokada @chuangzhu
/modules/programs/mu.nix @KarlJoad

View file

@ -34,6 +34,12 @@ let
listsAsDuplicateKeys = true;
};
renderScriptOptions = generators.toKeyValue {
mkKeyValue =
generators.mkKeyValueDefault { mkValueString = renderOption; } "=";
listsAsDuplicateKeys = true;
};
renderProfiles = generators.toINI {
mkKeyValue =
generators.mkKeyValueDefault { mkValueString = renderOptionValue; } "=";
@ -85,6 +91,27 @@ in {
'';
};
scriptOpts = mkOption {
description = ''
Script options added to
<filename>$XDG_CONFIG_HOME/mpv/script-opts/</filename>. See
<citerefentry>
<refentrytitle>mpv</refentrytitle>
<manvolnum>1</manvolnum>
</citerefentry>
for the full list of options of builtin scripts.
'';
type = types.attrsOf mpvOptions;
default = { };
example = {
osc = {
scalewindowed = 2.0;
vidscale = false;
visibility = "always";
};
};
};
config = mkOption {
description = ''
Configuration written to
@ -184,7 +211,13 @@ in {
(mkIf (cfg.bindings != { }) {
xdg.configFile."mpv/input.conf".text = renderBindings cfg.bindings;
})
{
xdg.configFile = mapAttrs' (name: value:
nameValuePair "mpv/script-opts/${name}.conf" {
text = renderScriptOptions value;
}) cfg.scriptOpts;
}
]);
meta.maintainers = with maintainers; [ tadeokondrak thiagokokada ];
meta.maintainers = with maintainers; [ tadeokondrak thiagokokada chuangzhu ];
}

View file

@ -1,5 +1,5 @@
{
# Temporarily commented until fixed for recent changes in Nixpkgs.
# mpv-example-settings = ./mpv-example-settings.nix;
# mpv-invalid-settings = ./mpv-invalid-settings.nix;
mpv-example-settings = ./mpv-example-settings.nix;
mpv-invalid-settings = ./mpv-invalid-settings.nix;
}

View file

@ -0,0 +1,3 @@
scalewindowed=2.000000
vidscale=no
visibility=always

View file

@ -18,6 +18,14 @@
cache-default = 4000000;
};
scriptOpts = {
osc = {
scalewindowed = 2.0;
vidscale = false;
visibility = "always";
};
};
profiles = {
fast = { vo = "vdpau"; };
"protocol.dvd" = {
@ -38,6 +46,9 @@
assertFileContent \
home-files/.config/mpv/input.conf \
${./mpv-example-settings-expected-bindings}
assertFileContent \
home-files/.config/mpv/script-opts/osc.conf \
${./mpv-example-settings-expected-osc-opts}
'';
};

View file

@ -10,24 +10,12 @@
nixpkgs.overlays = [
(self: super: {
mpv-unwrapped = pkgs.runCommandLocal "mpv" {
version = "0";
passthru = {
lua.luaversion = "0";
luaEnv = "/dummy";
vapoursynthSupport = false;
};
} ''
mkdir -p $out/bin $out/Applications/mpv.app/Contents/MacOS
touch $out/bin/{,u}mpv $out/Applications/mpv.app/Contents/MacOS/mpv
chmod 755 $out/bin/{,u}mpv $out/Applications/mpv.app/Contents/MacOS/mpv
'';
mpvDummy = config.lib.test.mkStubPackage { };
mpvScript =
pkgs.runCommandLocal "mpvScript" { scriptName = "something"; }
"mkdir $out";
})
];
test.stubs.mpvDummy = { };
test.asserts.assertions.expected = [
''