2021-02-14 05:38:20 +03:00
# Overrides
2022-11-08 17:06:32 +03:00
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 19:38:20 +03:00
## Packages
2022-11-08 17:06:32 +03:00
2021-04-27 19:38:20 +03:00
You can make use of `overlays/overrides.nix` to override specific packages in the
default channel to be pulled from other channels. That file is simply an example
of how any overlay can get `channels` as their first argument.
2021-02-14 05:38:20 +03:00
2021-04-27 19:38:20 +03:00
You can add overlays to any channel to override packages from other channels.
2021-02-14 05:38:20 +03:00
2021-04-27 19:38:20 +03:00
Pulling the manix package from the `latest` channel:
2022-11-08 17:06:32 +03:00
2021-02-14 05:38:20 +03:00
```nix
2021-04-27 04:29:05 +03:00
channels: final: prev: {
2021-04-29 21:53:45 +03:00
__dontExport = true;
2021-04-27 04:29:05 +03:00
inherit (pkgs.latest) manix;
2021-02-14 05:38:20 +03:00
}
```
2021-04-29 21:53:45 +03:00
It is recommended to set the `__dontExport` property for override specific
overlays. `overlays/overrides.nix` is the best place to consolidate all package
overrides and the property is already set for you.
2021-04-27 19:38:20 +03:00
## Modules
2021-02-14 05:38:20 +03:00
2022-11-08 17:06:32 +03:00
You can also pull modules from other channels. All modules have access to the
2021-04-27 04:29:05 +03:00
`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-06-08 22:10:17 +03:00
To pull zsh module from the `latest` channel this code can be placed in any module, whether its your host file, a profile, or a module in ./modules etc:
2022-11-08 17:06:32 +03:00
2021-02-14 05:38:20 +03:00
```nix
2021-06-08 22:10:17 +03:00
{ latestModulesPath }:
{
2021-06-08 22:24:24 +03:00
imports = [ "${latestModulesPath}/programs/zsh/zsh.nix" ];
2021-04-27 04:29:05 +03:00
disabledModules = [ "programs/zsh/zsh.nix" ];
2021-02-14 05:38:20 +03:00
}
```
> ##### _Note:_
2022-11-08 17:06:32 +03:00
>
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