How do I change the package used by a module?
By default Home Manager will install the package provided by your chosen
nixpkgs channel but occasionally you might end up needing to change
this package. This can typically be done in two ways.
-
If the module provides a
packageoption, such asprograms.beets.package, then this is the recommended way to perform the change. For example,programs.beets.package = pkgs.beets.override { pluginOverrides = { beatport.enable = false; }; };See Nix pill 17 for more information on package overrides. Alternatively, if you want to use the
beetspackage from Nixpkgs unstable, then a configuration like{ pkgs, config, ... }: let pkgsUnstable = import <nixpkgs-unstable> {}; in { programs.beets.package = pkgsUnstable.beets; # … }should work OK. With flakes, pass the unstable package set as described in How do I install packages from Nixpkgs unstable? and then use the extra module argument:
{ pkgsUnstable, ... }: { programs.beets.package = pkgsUnstable.beets; # … } -
If no
packageoption is available then you can typically change the relevant package using an overlay.For example, if you want to use the
programs.skimmodule but use theskimpackage from Nixpkgs unstable, then a configuration like{ pkgs, config, ... }: let pkgsUnstable = import <nixpkgs-unstable> {}; in { programs.skim.enable = true; nixpkgs.overlays = [ (_final: _prev: { skim = pkgsUnstable.skim; }) ]; # … }should work OK.
The same Home Manager overlay works in a flake-based standalone configuration if
pkgsUnstableis passed to the Home Manager module:{ pkgsUnstable, ... }: { programs.skim.enable = true; nixpkgs.overlays = [ (_final: _prev: { skim = pkgsUnstable.skim; }) ]; # … }This also works when Home Manager is used as a NixOS or nix-darwin module without
home-manager.useGlobalPkgs = true. Ifhome-manager.useGlobalPkgs = trueis enabled, Home Manager uses the system package set and thenixpkgs.*options inside Home Manager are disabled. In that case, put the overlay in the system configuration instead, for example:{ pkgsUnstable, ... }: { nixpkgs.overlays = [ (_final: _prev: { skim = pkgsUnstable.skim; }) ]; }In a flake-based NixOS or nix-darwin configuration, pass
pkgsUnstabletonixosSystemordarwinSystemwithspecialArgs.