Modules contains 1 or more of the following:
```
flake.modules.<class>.<feature> = {}
```
For example, our `modules/window-manager.nix` looks like this:
```nix
{
flake.modules.hjem.window-manager = { /* ... */ };
flake.modules.nixos.window-manager = { /* ... */ };
flake.modules.darwin.window-manager = { /* ... */ };
}
```
> [!NOTE]
> Note that `hjem` modules are automatically included in any host that uses the
> `hjem` module.
The `darwin` and `nixos` modules are then used in `modules/hosts.nix` like this:
```nix
{
# For NixOS systems:
flake.nixosConfigurations.hostName = inputs.os.lib.nixosSystem {
specialArgs = { inherit inputs; };
system = "x86_64-linux";
modules = with inputs.self.modules.nixos; [
# ... other packages
yubikey
];
};
# Or for Darwin systems:
flake.darwinConfigurations.hostName = inputs.os-darwin.lib.darwinSystem {
specialArgs = { inherit inputs; };
system = "x86_64-linux";
modules = with inputs.self.modules.darwin; [
# ... other packages
yubikey
];
};
}
```
This gives us fine-grained control over which hosts have access to which
features.
Any additional configuration for the hosts is defined in an inline module inside
the `modules = []` section of each host. This gives us the flexibility to define
configurations that are exclusive to the host and can't trivially be made a
module such as `hostName`, `operatingSystem` (for conditional modules) and
`secrets` configuration.
## myLib
There may be unfamiliar functions/helpers in some files - these come from
`modules/lib.nix`.
## Theming
I have a custom theming setup which can be seen in `modules/theme.nix`. It does
rely on a rebuild but it's a simple toggle between light/dark and gruvbox/pywal
modes by running shortcuts setup in Fuzzel. It automatically updates colour
schemes and refreshes necessary applications to apply changes.
The pywal mode generates colours from the current wallpaper.