-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
276: Update core r=blaggacao a=Pacman99 Core is starting to get pretty stale. All the changes in `develop` are pretty stable and I think we should encourage updating to them. As most future updates can be done through [devlib](https://github.com/divnix/devlib), so once you switch to this version of the template. Updating to new changes will be much simpler (ie #91). Co-authored-by: Pacman99 <[email protected]> Co-authored-by: Pacman99 <[email protected]> Co-authored-by: David Arnold <[email protected]>
- Loading branch information
Showing
51 changed files
with
821 additions
and
1,362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,42 @@ | ||
# External Art | ||
When you need to use a module, overlay, or pass a value from one of your inputs | ||
to the rest of your NixOS configuration, [extern][extern] is where you do it. | ||
to the rest of your NixOS configuration, you can make use of a couple arguments. | ||
It is encouraged to add external art directly in your `flake.nix` so the file | ||
represents a complete dependency overview of your flake. | ||
|
||
Modules and overlays are self explanatory, and the `specialArgs` attribute is | ||
used to extend the arguments passed to all NixOS modules, allowing for | ||
arbitrary values to be passed from flake inputs to the rest of your | ||
configuration. | ||
## Overlays | ||
External overlays can directly be added to a channel's `overlays` list. | ||
|
||
## Home Manager | ||
There is also an `hmModules` attribute set for pulling home-manager modules in | ||
from the outside world: | ||
|
||
### Declare: | ||
flake.nix: | ||
```nix | ||
{ | ||
inputs.doom-emacs.url = "github:vlaci/nix-doom-emacs"; | ||
channels.nixos.overlays = [ inputs.agenix.overlay ]; | ||
} | ||
``` | ||
Upon exporting overlays, these overlays will be automatically filtered out by inspecting the `inputs` argument. | ||
|
||
extern/default.nix: | ||
## Modules | ||
There is a dedicated `nixos.hostDefaults.externalModules` argument for external | ||
modules. | ||
|
||
flake.nix: | ||
```nix | ||
with inputs; | ||
{ | ||
hmModules = { | ||
doom-emacs = doom-emacs.hmModule; | ||
}; | ||
nixos.hostDefaults.externalModules = [ inputs.agenix.nixosModules.age ]; | ||
} | ||
``` | ||
|
||
### Use: | ||
users/nixos/default.nix: | ||
## Home Manager | ||
Since there isn't a `hosts` concept for home-manager, externalModules is just a | ||
top-level argument in the `home` namespace. | ||
|
||
flake.nix: | ||
```nix | ||
{ hmModules, ... }: | ||
{ | ||
home-manager.users.nixos = { | ||
imports = [ hmModules.doom-emacs ] ; | ||
programs.doom-emacs.enable = true; | ||
}; | ||
home.externalModules = [ doom-emacs = doom-emacs.hmModule ]; | ||
} | ||
``` | ||
|
||
[extern]: https://github.com/divnix/devos/tree/core/extern/default.nix | ||
> ##### Note: | ||
> To avoid declaring "external" modules separately, which is obvious since they come from `inputs`, the optimal solution would be to automatically export modules that were created in | ||
> your flake. But this is not possible due to NixOS/nix#4740. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,41 @@ | ||
# Overrides | ||
By default, the NixOS systems are based on unstable. While it is trivial to | ||
change this to a stable release, or any other branch of nixpkgs by | ||
changing the flake url, sometimes all we want is a single package from another | ||
branch. | ||
Each NixOS host follows one channel. But many times it is useful to get packages | ||
or modules from different channels. | ||
|
||
This is what the overrides are for. By default, they are pulled directly from | ||
nixpkgs/master, but you can change the `override` flake input url to | ||
nixos-unstable, or even a specific sha revision. | ||
## Packages | ||
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. | ||
|
||
They are defined in the `extern/overrides.nix` file. | ||
You can add overlays to any channel to override packages from other channels. | ||
|
||
## Example | ||
|
||
### Packages | ||
The override packages are defined as a regular overlay with an extra arguement | ||
`pkgs`. This refers to the packages built from the `override` flake. | ||
|
||
Pulling the manix package from the override flake: | ||
Pulling the manix package from the `latest` channel: | ||
```nix | ||
{ | ||
packages = pkgs: final: prev: { | ||
inherit (pkgs) manix; | ||
}; | ||
channels: final: prev: { | ||
__dontExport = true; | ||
inherit (pkgs.latest) manix; | ||
} | ||
``` | ||
|
||
### Modules | ||
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. | ||
|
||
## Modules | ||
|
||
You can also pull modules from override. Simply specify their path relative to | ||
the nixpkgs [modules][nixpkgs-modules] directory. The old version will be added | ||
to `disabledModules` and the new version imported into the configuration. | ||
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. | ||
|
||
Pulling the zsh module from the override flake: | ||
Pulling the zsh module from the `latest` channel: | ||
```nix | ||
{ | ||
modules = [ "programs/zsh/zsh.nix" ]; | ||
{ latestModulesPath }: { | ||
modules = [ "${latestModulesPath}/programs/zsh/zsh.nix" ]; | ||
disabledModules = [ "programs/zsh/zsh.nix" ]; | ||
} | ||
``` | ||
|
||
> ##### _Note:_ | ||
> Sometimes a modules name will change from one branch to another. This is what | ||
> the `disabledModules` list is for. If the module name changes, the old | ||
> version will not automatically be disabled, so simply put it's old name in | ||
> this list to disable it. | ||
> Sometimes a modules name will change from one branch to another. | ||
[nixpkgs-modules]: https://github.com/NixOS/nixpkgs/tree/master/nixos/modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.