nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
7.18k stars 1.85k forks source link

bug: mpv renderOption str length passed as value #5853

Open Neuro-NX opened 2 months ago

Neuro-NX commented 2 months ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

config option in programs.mpv are not being correctly parsed and formatted.

{
  programs.mpv = {
    config = {
      geometry = "50%x50%";
      osc = false;
    };
  };
}

result:

geometry=%7%50%x50%
osc=%2%no

The string length of the value is being passed in the output, which it shouldn't.

I think the culprit is

...
in "%${length}%${rendered}";

I think it is because the escape character % is being enclosed within double-quotes, thereby read as a string?

Maintainer CC

@thiagokokada @chuangzhu

System information

- system: `"x86_64-linux"`
- host os: `Linux 6.6.51, NixOS 24.05 (Uakari), 24.05.20240914.8f7492c`
- multi-user?: `yes`
- sandbox: `yes`
- version: `nix-env (Nix) 2.18.5`
- channels(root): `"nixos-24.05"`
- nixpkgs: `/nix/store/-source`
Neuro-NX commented 2 months ago

So it turns out that, if the option KEY contains a seperator character - or _ then this issue occurs. Options with a single string format the KEY/VALUE pair correctly.

I resolved this by enclosing any option with such characters in double-quotes.

Neuro-NX commented 2 months ago

Can someone reproduce this bug? It only affects the config option for some reason.

djl commented 1 month ago

Just ran into this myself but slightly differently. This happens with every config option, not just ones with - or _ in the key.

After more digging I found out that this is actually valid mpv.conf syntax so it's not a bug after all.