Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipewire not applying extra config after upgrade #298158

Closed
mjjs opened this issue Mar 22, 2024 · 5 comments · Fixed by #299299
Closed

Pipewire not applying extra config after upgrade #298158

mjjs opened this issue Mar 22, 2024 · 5 comments · Fixed by #299299

Comments

@mjjs
Copy link
Contributor

mjjs commented Mar 22, 2024

Describe the bug

After I migrated from using environment.etc."pipewire<...>" to services.pipewire.extraConfig, (see #282377) Pipewire isn't applying the configuration I have defined in my nix config. In my case, I am trying to create a null sink.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Define a null sink in the configuration file (see below)
  2. Run nixos-rebuild switch
  3. Possibly reboot. (not sure if necessary)
  4. Observe no null sink being created (for example with pactl list short sinks)

Expected behavior

A null sink should be created.

Additional context

My Pipewire configuration is as follows:

  environment.systemPackages = with pkgs; [
    pulseaudio
  ];

  # Enable sound with pipewire.
  sound.enable = true;

  # Optional but recommended
  security.rtkit.enable = true;

  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
  };

  services.pipewire.extraConfig.pipewire = {
    "10-obs-only-sink" = {
        context.objects = [
            {
                factory = "adapter";
                args = {
                    factory.name     = "support.null-audio-sink";
                    node.name        = "OBS-only";
                    media.class      = "Audio/Sink";
                    node.description = "Output for OBS";
                    audio.position   = "FL,FR";
                };
            }
        ];
    };
  };

And before the upgrade the sink part was

  environment.etc."pipewire/pipewire.conf.d/10-obs-only-sink.conf".text = ''
  {
    "context.objects" = [
        {
            factory = "adapter",
            args = {
                "factory.name"     = "support.null-audio-sink",
                "node.name"        = "OBS-only",
                "media.class"      = "Audio/Sink",
                "node.description" = "Output for OBS",
                "audio.position"   = "FL,FR"
            }
        }
    ]
  }
  '';

I can see the config files are being created:

$ ls -1 /etc/pipewire/pipewire.conf.d
10-obs-only-sink.conf

and Pipewire seems to recognise them as well:

$ pw-config 
{
  "config.path": "/nix/store/xhq6515qr3sk5kd83jgs3k3gn3q1mvks-pipewire-1.0.4/share/pipewire/pipewire.conf",
  "override.2.0.config.path": "/etc/pipewire/pipewire.conf.d/10-obs-only-sink.conf",
}

Let me know if you need any extra information.

Notify maintainers

@K900
@hcsch since it was your PR

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 6.6.22, NixOS, 24.05 (Uakari), 24.05pre600876.20f77aa09916`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.2`
 - channels(root): `"nixos"`
 - channels(mjs): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Add a 👍 reaction to issues you find important.

@mjjs mjjs added the 0.kind: bug Something is broken label Mar 22, 2024
@eclairevoyant
Copy link
Contributor

the easier way is probably not trying to nixify the pipewire-json:

services.pipewire.configPackages = [
  (pkgs.writeTextDir "share/pipewire/foo/bar.conf" ''
    -- contents here
  '')
];

so you can keep it as a string

@mjjs
Copy link
Contributor Author

mjjs commented Mar 22, 2024

the easier way is probably not trying to nixify the pipewire-json:

services.pipewire.configPackages = [
  (pkgs.writeTextDir "share/pipewire/foo/bar.conf" ''
    -- contents here
  '')
];

so you can keep it as a string

Thanks a lot. I tried creating the pipewire config the way you described, rebooted, and now it works as before. From my POV, this can be closed, but I'm not sure if that's desired as this looks like a regression.

@eclairevoyant
Copy link
Contributor

I'd definitely say that the new methods need documentation.

@eclairevoyant eclairevoyant added 9.needs: documentation and removed 0.kind: bug Something is broken labels Mar 22, 2024
@hcsch
Copy link
Contributor

hcsch commented Mar 22, 2024

This is a bit of an issue with how PipeWire has dotted attribute names. They way you translated the config into a nix attrset creates nested objects whereas PipeWire expects flat ones:

{
  "context": {
    "objects": [
      {
        "args": {
          "audio": {
            "position": "FL,FR"
          },
          "factory": {
            "name": "support.null-audio-sink"
          },
          "media": {
            "class": "Audio/Sink"
          },
          "node": {
            "description": "Output for OBS",
            "name": "OBS-only"
          }
        },
        "factory": "adapter"
      }
    ]
  }
}

To get what you'd want, you'd have to use the following:

services.pipewire.extraConfig.pipewire = {
  "10-obs-only-sink" = {
    "context.objects" = [
      {
        factory = "adapter";
        args = {
          "factory.name"     = "support.null-audio-sink";
          "node.name"        = "OBS-only";
          "media.class"      = "Audio/Sink";
          "node.description" = "Output for OBS";
          "audio.position"   = "FL,FR";
        };
      }
    ];
  };
};

Perhaps extraConfig would be better off just taking strings after all. I'm not sure a warning in the description would be enough to prevent confusion when people convert their configs to nix attrsets, though I can write something about this in the NixOS wiki and perhaps extend the description of the option. @K900 what do you think about that?

@eclairevoyant
Copy link
Contributor

eclairevoyant commented Mar 22, 2024

A short but reasonably self-explanatory example in the description example field should suffice. The wiki is unaffiliated/unofficial, so not an effective place to document this stuff.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants