Nix environment packages overrides impossible?

I want to install spotifyd with optional PulseAudio support. From what I learned from Environment reference, each package supports only stability and version attributes. It means I cannot override the withPulseAudio attribute to true.

Does that mean that to enable this I have to create my own flake, add it to public Github and use it the same way I installed gimme-aws-creds from their github?

ahh ofc there is inline, I was blind

 88   inline.packages.spotifyd = { system, ...}:
 89   let
 90       nixpkgs = builtins.getFlake "github:NixOS/nixpkgs/2c6ae7132ca558f1052da0eececed3cad191b883";
 91   in
 92       nixpkgs.legacyPackages.${system}.spotifyd.override { withPulseAudio = true ; };

Although this fetches nixpkgs directly, can’t nixpkgs-flox be passed somehow like a system?

Disclaimer: we are currently reworking the environment file format so the answer to this might look somewhat different soon.

For the time being:

The function here is in fact called with a context that is a superset of nixpkgs to provide, inline package definitions.
Think of the function in a way like default.nix files in nixpkgs if you have worked with those.
The nixpkgs used should match nixpkgs-flox

Thus you should be able to override spotifyd like this:

inline.packages.spotifyd = { spotifyd }: spotifyd.override { withPulseAudio = true ; };

Note that the nixpkgs you get here will be locked to the version of when the environment was created or for project environments, the version locked by the project.

2 Likes