Add moduleWithSystem flake module parameter

This commit is contained in:
Robert Hensing 2022-07-19 18:34:15 +02:00
parent 608ed35022
commit e646df196a
3 changed files with 51 additions and 0 deletions

View file

@ -66,6 +66,24 @@ See [flake.parts](https://flake.parts/options.html)
- `getSystem`: function from system string to the `config` of the appropriate `perSystem`.
- `moduleWithSystem`: function that brings the `perSystem` module arguments.
This allows a module to reference the defining flake without introducing
global variables (which may conflict).
```nix
{ moduleWithSystem, ... }:
{
nixosModules.default = moduleWithSystem (
perSystem@{ config }: # NOTE: only explicit params will be in perSystem
nixos@{ ... }:
{
services.foo.package = perSystem.config.packages.foo;
imports = [ ./nixos-foo.nix ];
}
);
}
```
- `withSystem`: enter the scope of a system. Worked example:
```nix