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

nixos/pulseaudio: make daemon.conf configurable #20888

Merged
merged 1 commit into from Jan 14, 2017

Conversation

sternenseemann
Copy link
Member

@sternenseemann sternenseemann commented Dec 4, 2016

Motivation for this change

There is no possibilty to adjust the behavior of the pulseadio daemon via the daemon.conf file at the moment.

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

This adds the following options:

  • pulseaudio.daemon.flat-volumes: wether to allow pulseaudio to adjust
    the sink volume based on playback volumes
  • pulseaudio.daemon.resample-method: set pulseaudios resampling method
  • pulseaudio.daemon.extraConfig: extra config for daemon.conf

Open question: Should we change the default value of flat-volumes?
The behavior has caused some controversy and Ubuntu as well as ArchLinux
chose to disable the feature.


Note: This is my first change involving nixos/modules and I am happy to receive suggestions to improve the code.

@mention-bot
Copy link

@sternenseemann, thanks for your PR! By analyzing the history of the files in this pull request, we identified @rickynils, @Profpatsch and @peterhoeg to be potential reviewers.

'';
};

extraConfig = mkOption {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of going through plaintext splicing, this should use an attribute set and apply a generator after applying all options.
#20903

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest just having one config option instead of reproducing misc options of the daemon and reference to the manpage of the daemon for values & defaults. Or alternatively generate the config automatically from the sources. :P

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Profpatsch, do you have an example of a module implementing this?

@@ -160,6 +167,31 @@ in {
if activated.
'';
};

resample-method = mkOption {
type = types.str;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nicer to use an enum - there are only 27 possible values.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sounds like a lot, who will keep this list up-to-date?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that’s why I propose just having a config and not copy items with potentially out-of-date defaults when upstream decides to change them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterhoeg I think it even might vary depending on different pulseaudio packages (and if it is just in the future).

Copy link
Member

@Profpatsch Profpatsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you have an example of a module implementing this?

A simple example would be

{ options.hardware.pulseaudio.daemon.config = mkOption {
    type = types.attrsOf types.unspecified;
    default = {};
    description = ''Config of the pulse daemon. See <literal>man pulse-daemon.conf</literal>.'';
  };

  config.environment.etc = [
    { target = "pulse/daemon.conf";
      text = lib.generators.toKeyValue {} config.hardware.pulseaudio.daemon.config; }
  ];
}

{
target = "asound.conf";
source = alsaConf;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{ target = "asound.conf";
  source = alsaConf; }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s not C#. :)

'';
};

extraConfig = mkOption {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest just having one config option instead of reproducing misc options of the daemon and reference to the manpage of the daemon for values & defaults. Or alternatively generate the config automatically from the sources. :P

@sternenseemann
Copy link
Member Author

I would be interested to hear opinions on @Profpatsch's proposal, it seems like a nice idea, but I think, we should stick with the common style across nixpkgs and roll out the change separately (maybe even on a larger scale).

@sternenseemann
Copy link
Member Author

Implemented @Profpatsch's suggestions.

This adds pulseaudio.daemon.config, which is a set of keys to values
which are directly translated to keys and values of pulseaudio's
daemon.conf, e. g.

    hardware.pulseaudio.daemon.config = { flat-volumes = "no"; }

becomes

    flat-volumes=no

in pulse/daemon.conf.
@Profpatsch Profpatsch merged commit 9f56dd9 into NixOS:master Jan 14, 2017
@sternenseemann sternenseemann deleted the pulse branch May 20, 2020 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants