Using the templates
Turn the example hosts into a configuration for a new machine or user.
The flake ships three template outputs next to the real hosts. They use the same profiles as Asgard and Niflheim, so a new machine starts from a working setup rather than from scratch.
| Template | Use it for |
|---|---|
nixosConfigurations.example-nixos | A new NixOS machine |
homeConfigurations."example-user@generic-linux" | A user environment on Arch, Fedora, Ubuntu, and so on |
homeConfigurations."example-user@macbook" | A user environment on macOS |
example-nixos has placeholder disk and boot values (/dev/sda with GRUB). It
must not be applied unchanged.
Before applying
- Replace every
example-*name: the user account in the host file, theusers/example-user/directory, and the output name inflake.nix. - Replace the Git and jj identity in
modules/home/vcs/default.nix. - For NixOS, replace the template's
hardware-configuration.nixwith one that describes the real machine. - Keep
system.stateVersionandhome.stateVersionat the release the machine was first installed with. They control compatibility defaults, not package versions.
Applying
# NixOS: configures the operating system and the user
sudo nixos-rebuild switch --flake .#example-nixos
# Linux or macOS: configures only the current user's home directory
nix run github:nix-community/home-manager -- switch \
--flake .#example-user@generic-linuxAdding a new host
- Create
hosts/nixos/<name>/orhosts/home/<name>.nix. - Publish the host's settings with
_module.args.settings, eitherdefaultSettingsunchanged or with overrides layered on throughlib.recursiveUpdate. See Settings and themes. - Import profiles, not individual modules, unless a feature really belongs to that one machine.
- Add the output to
flake.nixwithnixpkgs.lib.nixosSystemorconfigLib.mkHome.
External applications on macOS
Some macOS applications are installed outside Nix on purpose. Install Karabiner-Elements with its official installer (the Karabiner module only manages its JSON file), and install Raycast with its official installer or Homebrew. Home Manager replaced the Raycast app bundle on every activation, which lost or broke its databases and extensions, so it is no longer managed here.
Last updated on