nix-gaming icon indicating copy to clipboard operation
nix-gaming copied to clipboard

Module pipewireLowLatency causes build failure

Open LovingMelody opened this issue 11 months ago • 30 comments

Attempting to build on nixos-unstable with the services.pipewire.lowLatency.enable = true causes the build to failed due to the usage of environment.etc."pipewire/pipewire-pulse.d"

Error message:

mkdir: cannot create directory '/nix/store/mhzd8fy047lqcp72lmakmi7rlaap31zf-etc/etc/pipewire/pipewire-pulse.d': Permission denied

LovingMelody avatar Feb 26 '24 20:02 LovingMelody

The directory should be generated if not available, as per how environment.etc works. Do you use pipewire locally?

NotAShelf avatar Feb 27 '24 10:02 NotAShelf

I haven't tried it on my actual machine yet but I get the same error in the CI pipeline that updates my flake.lock - https://github.com/e-nikolov/nix-config/actions/runs/8061032114/job/22018053387?pr=421

Flake lock file updates:

• Updated input 'code-insiders':
    'github:e-nikolov/code-insiders-flake/d190c0f749d5b359f4166b251d18a7099ae698b8' (2024-02-25)
  → 'github:e-nikolov/code-insiders-flake/350229dfe0d6c15ef228ba14371a867e4770afc5' (2024-02-27)
• Updated input 'helix':
    'github:helix-editor/helix/cd02976fa3a55c2c1f01b95c40d178061968f797' (2024-02-26)
  → 'github:helix-editor/helix/f46a09ab4f945273c7baf32e58438b501914fabb' (2024-02-27)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/2a34566b67bef34c551f204063faeecc444ae9da' (2024-02-25)
  → 'github:nixos/nixpkgs/548a86b335d7ecd8b57ec617781f5e652ab0c38e' (2024-02-26)

The only relevant change seems to be the update to nixpkgs. So probably the latest batch of commits to nixpkgs-unstable broke this.

e-nikolov avatar Feb 27 '24 10:02 e-nikolov

Could you see if pointing your input at #162 resolves the issue?

NotAShelf avatar Feb 27 '24 11:02 NotAShelf

I get another error now - https://github.com/e-nikolov/nix-config/actions/runs/8063764183/job/22026253959?pr=421

error:
       … while calling the 'seq' builtin
         at /nix/store/km3kyvmrh30vsl7wqb1njqv3fylcfq9g-source/lib/modules.nix:322:18:
          321|         options = checked options;
          322|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          323|         _module = checked (config._module);
       … while calling the 'throw' builtin
         at /nix/store/km3kyvmrh30vsl7wqb1njqv3fylcfq9g-source/lib/modules.nix:[29](https://github.com/e-nikolov/nix-config/actions/runs/8063764183/job/22026253959?pr=421#step:6:30)8:18:
          297|                     ''
          298|             else throw baseMsg
             |                  ^
          299|         else null;
       error: The option `services.pipewire.extraConfig."99-lowlatency.conf"' does not exist. Definition values:
       - In `/nix/store/qdbzbfi8ns5n1vcw[42](https://github.com/e-nikolov/nix-config/actions/runs/8063764183/job/22026253959?pr=421#step:6:43)hwd8q9h6xh6cn6-source/flake.nix#nixosModules.pipewireLowLatency':
           {
             _type = "if";
             condition = true;
             content = <derivation 99-lowlatency.conf>;
           }
Error: Process completed with exit code 1.

e-nikolov avatar Feb 27 '24 11:02 e-nikolov

In case it's useful, I think these are the recent commits to nixpkgs that contain pipewire related changes:

  • https://github.com/NixOS/nixpkgs/commit/d596c9b4b56eab141b9bbfe5a4e84349549752de

  • https://github.com/NixOS/nixpkgs/commit/eb74747f38d83f83aa6aace76e3f76a76194b081

  • https://github.com/NixOS/nixpkgs/commit/92b9d11129f9134f4592d3c75cb6764c1c2cfece

Coming from those PRs:

  • https://github.com/NixOS/nixpkgs/pull/282377

  • https://github.com/NixOS/nixpkgs/pull/291513

e-nikolov avatar Feb 27 '24 11:02 e-nikolov

do you override nix-gaming's instance of nixpkgs?

NotAShelf avatar Feb 27 '24 11:02 NotAShelf

do you override nix-gaming's instance of nixpkgs?

Yes, I do

e-nikolov avatar Feb 27 '24 11:02 e-nikolov

https://github.com/NixOS/nixpkgs/commit/8ba76f8dd46043c2928f39da7491da8b3b335f24 added extraConfig, not sure why it wouldn't be available. I'll take another look

NotAShelf avatar Feb 27 '24 11:02 NotAShelf

oversight on my behalf, try now please

NotAShelf avatar Feb 27 '24 11:02 NotAShelf

Now I get

error: builder for '/nix/store/0l6zqvp6r82s2r8k7z4lxi9affjiz4dd-etc.drv' failed with exit code 1;
       last 1 log lines:
       > mkdir: cannot create directory '/nix/store/s53jbbchpcvnprqb8clq8vnr2h3s30fq-etc/etc/wireplumber/main.lua.d': Permission denied

e-nikolov avatar Feb 27 '24 11:02 e-nikolov

I'd really like to know why your /etc/wireplumber is not writable through etc.environment Using the exact same module, /etc/wireplumber/main.lua.d/99-alsa-lowlatency.lua is generated correctly for me.

NotAShelf avatar Feb 27 '24 12:02 NotAShelf

This is going to be a weird question, but do you have wireplumber enabled?

NotAShelf avatar Feb 27 '24 12:02 NotAShelf

I don't have anything about wireplumber in my nix-configs.

https://github.com/e-nikolov/nix-config/blob/43d06c243df9928fcfe686697580e316b245e7d5/preferences/nixos/audio.nix#L24-L41

I also haven't seen it mentioned in the docs for nix-gaming. Do I have to enable it? Things seemed to work fine until today.

e-nikolov avatar Feb 27 '24 12:02 e-nikolov

https://search.nixos.org/options?channel=23.11&show=services.pipewire.wireplumber.enable&from=0&size=50&sort=relevance&type=packages&query=wireplumber

should be enabled by defaulting according to the option docs

NotAShelf avatar Feb 27 '24 12:02 NotAShelf

https://github.com/NixOS/nixpkgs/blob/7d3c9aeca783e2af811a6dd5e97e88ce55babd9c/nixos/modules/services/desktops/pipewire/wireplumber.nix#L105

environment.etc.wireplumber.source = "${configs}/share/wireplumber";

I think one of the recent changes in nixpkgs-unstable creates the "/etc/wireplumber" directory and it somehow prevents the environment.etc option you added from creating the low-latency config.

Using the exact same module, /etc/wireplumber/main.lua.d/99-alsa-lowlatency.lua is generated correctly for me.

Do you by any chance have something like this in your flake:

inputs.nix-gaming.follows = "nixpkgs";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";

I think commit that causes the issue is only on nixpkgs-unstable and not on nixos-unstable yet.

e-nikolov avatar Feb 27 '24 13:02 e-nikolov

They also have:

pathsToLink = [ "/share/wireplumber" ];

and a new configPackages option.

Perhaps the correct way to add the low latency config is via a package that outputs to /share/wireplumber/99-alsa-lowlatency.lua and then adding it to configPackages?

e-nikolov avatar Feb 27 '24 13:02 e-nikolov

I am currently using nixos-unstable-small, though talking in the matrix chat they did indicate that this is an expected issue

Progress tracker for the PRs: https://nixpk.gs/pr-tracker.html?pr=291513 https://nixpk.gs/pr-tracker.html?pr=282377

LovingMelody avatar Feb 27 '24 14:02 LovingMelody

I follow nixpkgs-small for my nix-gaming input. Might be why I did not came across that warning.

NotAShelf avatar Feb 27 '24 14:02 NotAShelf

Perhaps the correct way to add the low latency config is via a package that outputs to /share/wireplumber/99-alsa-lowlatency.lua and then adding it to configPackages?

No, we should not need to ship a package to be able to provide rules.

NotAShelf avatar Feb 27 '24 14:02 NotAShelf

Looks like these changes have landed in nixpkgs-unstable. Providing a package would not be a clean solution, would also mean overrides just for changing settings.

LovingMelody avatar Feb 27 '24 20:02 LovingMelody

Updated nixpkgs @ https://github.com/fufexan/nix-gaming/pull/162. Should be good for a merge, but testing would be appreciated.

NotAShelf avatar Feb 27 '24 21:02 NotAShelf

Updated nixpkgs @ #162. Should be good for a merge, but testing would be appreciated.

Just tried it and I still have the build failure.

matt1432 avatar Feb 27 '24 22:02 matt1432

Are you overriding your nixpkgs input locally?

NotAShelf avatar Feb 28 '24 11:02 NotAShelf

https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/desktops/pipewire/wireplumber.nix#L101C1-L113C9

Okay what the hell, they are forcing us to provide configs as a package.

NotAShelf avatar Feb 28 '24 11:02 NotAShelf

As per https://github.com/NixOS/nixpkgs/pull/291946, we are no longer able to write to /etc/wireplumber and due to the lack of an extraConfig option, we are forced to ship a config package.

I've found that using writeTextDir is able to conform to the new format, and hopefully fixed it until another maintainer high on shroom decides they don't like how things, yknow, work.

Once again, testing is appreciated.

NotAShelf avatar Feb 28 '24 12:02 NotAShelf

It looks like your PR fixes it now, at least on my machine @NotAShelf

matt1432 avatar Feb 28 '24 16:02 matt1432

Same here

e-nikolov avatar Feb 28 '24 16:02 e-nikolov

Sorry for causing this breakage! By no means did I intend to make wireplumber harder to configure and an extraConfig option missing from my PR was a really unfortunate oversight on my part. I'm trying to get that fixed with https://github.com/NixOS/nixpkgs/pull/292115. I did try to think about how to not break environment.etc."wireplumber<...>", but couldn't figure anything out for that. A good extraConfig is also looking not quite as trivial as I'd hoped (with WirePlumber 0.4) if the .conf files should also be changeable and not just the <...>.lua.d/*.lua files.

From what I can tell an extraConfig option that allows adding of lua files to the lua.d dirs would be sufficient for your pipewireLowLatency module though, right?

Note: I added that assertion to at least get users with this breakage a slightly better error message. I maybe should have added a note on an extraConfig option coming in the near future. Though ideally that should have just been part of the original PR

hcsch avatar Feb 28 '24 16:02 hcsch

From what I understand, WirePlumber itself has gotten a breaking change and is moving the config files to /etc/pipewire. Which means we probably have to go back?

From what I can tell an extraConfig option that allows adding of lua files to the lua.d dirs would be sufficient for your pipewireLowLatency module though, right?

That is correct.

NotAShelf avatar Feb 28 '24 21:02 NotAShelf

NixOS/nixpkgs#292115 will add extraConfig, extraLuaConfig, and extraScripts options once it lands. I hope that'll make things more comfortable again for you

hcsch avatar Feb 29 '24 14:02 hcsch