2021-02-14 05:38:20 +03:00
|
|
|
# Overrides
|
2021-04-27 04:29:05 +03:00
|
|
|
Each NixOS host follows one channel. But many times it is useful to get packages
|
|
|
|
or modules from different channels.
|
2021-02-14 05:38:20 +03:00
|
|
|
|
2021-04-27 04:29:05 +03:00
|
|
|
This is what the overrides are for. You can make use of the `overrides.nix` to
|
|
|
|
override specific packages to be pulled from other channels. Any overlay may get
|
|
|
|
`channels` as their first argument.
|
2021-02-14 05:38:20 +03:00
|
|
|
|
|
|
|
## Example
|
|
|
|
|
|
|
|
### Packages
|
|
|
|
The override packages are defined as a regular overlay with an extra arguement
|
2021-04-27 04:29:05 +03:00
|
|
|
`channels`. This refers to all channels defined in `flake.nix`.
|
2021-02-14 05:38:20 +03:00
|
|
|
|
2021-04-27 04:29:05 +03:00
|
|
|
Pulling the manix package from the latest flake:
|
2021-02-14 05:38:20 +03:00
|
|
|
```nix
|
2021-04-27 04:29:05 +03:00
|
|
|
channels: final: prev: {
|
|
|
|
inherit (pkgs.latest) manix;
|
2021-02-14 05:38:20 +03:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Modules
|
|
|
|
|
2021-04-27 04:29:05 +03:00
|
|
|
You can also pull modules from other channels. All modules have access to the
|
|
|
|
`modulesPath` for each channel as `<channelName>ModulesPath`. And you can use
|
|
|
|
`disabledModules` to remove modules from the current channel.
|
2021-02-14 05:38:20 +03:00
|
|
|
|
2021-04-27 04:29:05 +03:00
|
|
|
Pulling the zsh module from the latest flake:
|
2021-02-14 05:38:20 +03:00
|
|
|
```nix
|
2021-04-27 04:29:05 +03:00
|
|
|
{ latestModulesPath }: {
|
|
|
|
modules = [ "${latestModulesPath}/programs/zsh/zsh.nix" ];
|
|
|
|
disabledModules = [ "programs/zsh/zsh.nix" ];
|
2021-02-14 05:38:20 +03:00
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
> ##### _Note:_
|
2021-04-27 04:29:05 +03:00
|
|
|
> Sometimes a modules name will change from one branch to another.
|
2021-02-14 05:38:20 +03:00
|
|
|
|
|
|
|
[nixpkgs-modules]: https://github.com/NixOS/nixpkgs/tree/master/nixos/modules
|