2021-02-14 03:38:20 +01:00
|
|
|
# Hosts
|
|
|
|
|
|
|
|
Nix flakes contain an output called `nixosConfigurations` declaring an
|
|
|
|
attribute set of valid NixOS systems. To simplify the management and creation
|
2021-02-18 02:31:33 +01:00
|
|
|
of these hosts, devos automatically imports every _.nix_ file inside this
|
2021-02-14 03:38:20 +01:00
|
|
|
directory to the mentioned attribute set, applying the projects defaults to
|
|
|
|
each. The only hard requirement is that the file contain a valid NixOS module.
|
|
|
|
|
|
|
|
As an example, a file `hosts/system.nix` will be available via the flake
|
|
|
|
output `nixosConfigurations.system`. You can have as many hosts as you want
|
|
|
|
and all of them will be automatically imported based on their name.
|
|
|
|
|
|
|
|
For each host, the configuration automatically sets the `networking.hostName`
|
|
|
|
attribute to the name of the file minus the _.nix_ extension. This is for
|
|
|
|
convenience, since `nixos-rebuild` automatically searches for a configuration
|
|
|
|
matching the current systems hostname if one is not specified explicitly.
|
|
|
|
|
|
|
|
It is recommended that the host modules only contain configuration information
|
|
|
|
specific to a particular piece of hardware. Anything reusable across machines
|
2021-04-19 04:26:27 +02:00
|
|
|
is best saved for [profile modules](./profiles.md).
|
2021-02-14 03:38:20 +01:00
|
|
|
|
2021-04-19 04:26:27 +02:00
|
|
|
This is a good place to import sets of profiles, called [suites](./suites.md),
|
2021-02-14 03:38:20 +01:00
|
|
|
that you intend to use on your machine.
|
|
|
|
|
|
|
|
Additionally, this is the perfect place to import anything you might need from
|
|
|
|
the [nixos-hardware][nixos-hardware] repository.
|
|
|
|
|
2021-03-16 03:04:28 +01:00
|
|
|
> ##### _Note:_
|
2021-04-19 04:26:27 +02:00
|
|
|
> Set `nixpkgs.system` to the architecture of this host, default is "x86_64-linux".
|
2021-03-16 03:04:28 +01:00
|
|
|
> Keep in mind that not all packages are available for all architectures.
|
|
|
|
|
2021-02-14 03:38:20 +01:00
|
|
|
## Example
|
|
|
|
|
2021-02-15 01:41:15 +01:00
|
|
|
hosts/librem.nix:
|
2021-02-14 03:38:20 +01:00
|
|
|
```nix
|
|
|
|
{ suites, hardware, ... }:
|
|
|
|
{
|
|
|
|
imports = suites.laptop ++ [ hardware.purism-librem-13v3 ];
|
|
|
|
|
|
|
|
boot.loader.systemd-boot.enable = true;
|
|
|
|
boot.loader.efi.canTouchEfiVariables = true;
|
|
|
|
|
|
|
|
fileSystems."/" = { device = "/dev/disk/by-label/nixos"; };
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
[nixos-hardware]: https://github.com/NixOS/nixos-hardware
|