How to use a nixpkgs package module special input boolean flag?

I am looking at

and my package declaration

  environment.systemPackages = [

I need to enable enableSonos = true but how do I pass this to the package module?

Well, to answer the question, instead of pkgs.mkchromecast you would use (pkgs.mkchromecast.override { enableSonos = true; }) (note the parentheses).

But it’s enabled already? The default is true.

Ah, I guessed so but, what I dont understand is how the other parameters are in NixOS/nixpkgs/blob/da4024d0ead5d7820f6bd15147d3fe2a0c0cec73/pkgs/applications/networking/mkchromecast/default.nix#L15
are determined. I think I got some fundamental problems in understanding such a Nix expression and then using override

Files like that are imported something like callPackage ./pkgs/applications/networking/mkchromecast {}. The callPackage function takes care of pulling values for all the arguments from pkgs, so e.g. pkgs.ffmpeg will be passed as the ffmpeg argument automatically. The {} argument can contain overrides, but you can also use the resulting .override function to provide overrides. Any argument that callPackage can’t pull from pkgs (such as enableSonos) will result in an error unless that argument has a default (which is what the ? true syntax does).

1 Like

Strange, so hypothetically whenever enableSonos becomes a new package in nixpkgs, than this file will somehow crash
because its no more a simple boolean? What would happen then? Isnt that a bit implicit behavior?

Yea. It’s a good thing enableSonos is a very unlikely name for a package :stuck_out_tongue: