pub-solar-os/doc/concepts/hosts.md

54 lines
1.6 KiB
Markdown
Raw Normal View History

2021-02-14 02:38:20 +00:00
# Hosts
Nix flakes contain an output called `nixosConfigurations` declaring an
attribute set of valid NixOS systems. To create hosts, you can use the
`nixos.hosts` argument and pass `modules` to each host. Host-specific modules
typically go in the `hosts` folder of the template.
2021-02-14 02:38:20 +00:00
Each host should follow a certain channel to define the `pkgs` of that host.
You can use the `nixos.hostDefaults` to set defaults and global modules for all
hosts.
2021-02-14 02:38:20 +00:00
For each host, the configuration automatically sets the `networking.hostName`
attribute to the name of the host. This is for convenience, since `nixos-rebuild`
automatically searches for a configuration matching the current systems hostname
if one is not specified explicitly.
2021-02-14 02:38:20 +00:00
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 02:26:27 +00:00
is best saved for [profile modules](./profiles.md).
2021-02-14 02:38:20 +00:00
2021-04-19 02:26:27 +00:00
This is a good place to import sets of profiles, called [suites](./suites.md),
2021-02-14 02:38:20 +00:00
that you intend to use on your machine.
Additionally, you can pass modules from [nixos-hardware][nixos-hardware] in the
`modules` argument for relevant hosts.
2021-02-14 02:38:20 +00:00
## Example
2021-02-15 00:41:15 +00:00
hosts/librem.nix:
2021-02-14 02:38:20 +00: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"; };
}
```
flake.nix
```nix
{
nixos.hosts.librem = {
system = "aarch64-linux";
modules = ./hosts/librem.nix;
};
}
```
2021-02-14 02:38:20 +00:00
[nixos-hardware]: https://github.com/NixOS/nixos-hardware