This directory contains configuration for the NixOS system environment.
This document focuses on aspects that are unique to this dotfiles. Detailed usage instructions for NixOS itself can be found in the official docs.
Directory | Contents |
---|---|
profiles |
Contains profiles |
machines |
Contains configuration for each host |
A profile refers to a NixOS module targeting a specific use case.
The configuration for NixOS is chosen based on the hostname unless a specific
one is chosen via the command line. Configuration for each host are defined in
machines
, so make sure to add hosts as necessary.
Add them to this file. Here's an example of how this
might look like for a host named pod042
:
pod042 = mkNixOS {
modules = [{
dotfiles.profiles = {
laptop.enable = true;
interactive.username = "yorha2b";
};
users.mutableUsers = false;
# NOTE: Maybe use https://github.com/ryantm/agenix
users.users.yorha2b.passwordFile = "/run/secrets/hashed-login-password";
system.stateVersion = "21.11";
}];
};
mkNixOS
is a wrapper for nixosSystem
that bundles custom
NixOS modules in this dotfiles repository.
There's also an importNixOS
function that allows you to split out the
configuration into a separate file. To use this, replace mkNixOS
with the
below:
pod042 = importNixOS ./pod042.nix { };
Then move the configuration into pod042.nix
:
{
dotfiles.profiles = {
laptop.enable = true;
interactive.username = "yorha2b";
};
users.mutableUsers = false;
# NOTE: Maybe use https://github.com/ryantm/agenix
users.users.yorha2b.passwordFile = "/run/secrets/hashed-login-password";
system.stateVersion = "21.11";
}
Finally, it's also possible to place host configuration in a separate repository
by creating a new Nix flake that takes this repository as input. See the
description in the templates
directory for more details.
It's possible to try out the current configuration in a test VM. For example, to
run the ci
machine in a VM, run the following command:
nixos-rebuild build-vm --flake '.#ci'
result/bin/run-nixos-vm
To clean up afterwards:
rm result nixos.qcow2
This dotfiles introduces a few additional options for NixOS. Here's some of the interesting ones:
- dotfiles.profiles.desktop.enable
- Configures a desktop environment.
- dotfiles.profiles.desktop.desktop
- Choose a desktop environment to use. Currently available options are Gnome and KDE.
- dotfiles.profiles.hardware.enable
- Configuration for bare metal.
- dotfiles.profiles.hardware.hidpi.enable
- Configuration for HiDPI displays.
- dotfiles.profiles.laptop.enable
- Configuration for laptops.
- dotfiles.profiles.network.enable
- Network related configuration.