docs: document unstable packages with flakes

Add a flake-based example for using a secondary nixpkgs-unstable input from Home Manager modules, matching the existing channel-based FAQ guidance.

Show how standalone configurations pass the package set with extraSpecialArgs, and explain the equivalent home-manager.extraSpecialArgs path for NixOS and nix-darwin module users.

Document that separate package sets do not automatically inherit the primary package set's nixpkgs.config or overlays, and show how to pass those values when needed.
This commit is contained in:
Austin Horstman
2026-05-04 09:26:32 -05:00
parent e70904b3af
commit c3387b41c9

View File

@@ -3,22 +3,20 @@
If you are using a stable version of Nixpkgs but would like to install
some particular packages from Nixpkgs unstable -- or some other channel
-- then you can import the unstable Nixpkgs and refer to its packages
within your configuration. Something like
within your configuration.
With channels, something like
``` nix
{ pkgs, config, ... }:
let
pkgsUnstable = import <nixpkgs-unstable> {};
in
{
home.packages = [
pkgsUnstable.foo
];
# …
}
```
@@ -32,5 +30,82 @@ $ nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixpkgs-unstable
$ nix-channel --update
```
Note, the package will not be affected by any package overrides,
overlays, etc.
With flakes, add another Nixpkgs input and pass its packages to your
Home Manager modules. For example, a standalone Home Manager flake can
define the following. Replace 25.11 with the release branch your
configuration follows.
``` nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
home-manager.url = "github:nix-community/home-manager/release-25.11";
};
outputs =
{ nixpkgs, nixpkgs-unstable, home-manager, ... }:
let
# Replace this with the system of your Home Manager configuration.
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
pkgsUnstable = nixpkgs-unstable.legacyPackages.${system};
in
{
homeConfigurations.jdoe = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
extraSpecialArgs = { inherit pkgsUnstable; };
modules = [ ./home.nix ];
};
};
}
```
and then use the extra argument in `home.nix`:
``` nix
{ pkgsUnstable, ... }:
{
home.packages = [
pkgsUnstable.foo
];
}
```
When Home Manager is used as a NixOS or nix-darwin module, pass the
extra package set with `home-manager.extraSpecialArgs` in the system
configuration:
``` nix
outputs =
{ nixpkgs, nixpkgs-unstable, home-manager, ... }:
let
# Replace this with the system of your NixOS or nix-darwin configuration.
system = "x86_64-linux";
in
{
nixosConfigurations.hostname = nixpkgs.lib.nixosSystem {
inherit system;
modules = [
home-manager.nixosModules.home-manager
({ config, ... }: {
home-manager.extraSpecialArgs = {
pkgsUnstable = import nixpkgs-unstable {
inherit system;
config = config.nixpkgs.config;
overlays = config.nixpkgs.overlays;
};
# If you use a stock Nixpkgs configuration, you can use:
# pkgsUnstable = nixpkgs-unstable.legacyPackages.${system};
};
})
];
};
};
```
The nix-darwin setup is the same pattern with
`darwin.lib.darwinSystem` and
`home-manager.darwinModules.home-manager`.