Skip to content

solomon-b/nixos-config

Repository files navigation

Nixos Homelab and Dotfiles

Structure

  • config: This folder contains all configurations. It is organized into the following subdirectories:
    • machines/personal-computers/: The entrypoints to desktop PCs.
    • machines/servers/: The entrypoints to servers.
    • profiles: Basic nixos module sets for virtual machines, physical machines, and PCs. These are imported into machine configurations to form a standard baseline for all my systems.
    • modules: Nixos configuration modules which constitute the profiles. Any machine unique configuration should go in the machines/ folder for the specific machine in question.
  • modules: Custom nixos and home-manager modules I use in my config.
  • installer: Custom nixos installer iso I use to quickly provision new machines.

Usage

Adding A New Machine

  1. Create a machine profile in config/machines. Import a non-existent ./hardware.nix file.
  2. Build a fresh boot disk:
nix build '.#nixos-iso'
  1. Boot the new machine off the iso.
  2. Generate a hardware config for the new machine:
ssh "root@${IP}" nixos-generate-config --no-filesystems --show-hardware-config > "config/machines/servers/${MACHINE}/hardware.nix"
  1. run the installer script:
./installer/install-server.sh
  1. Detach the boot disk and reboot.

You can use nixos-anywhere to provision a new phyiscal machine. Create a new machine under machines/personal-computers or machines/servers then boot your new machine with any linux boot disk that provides you ssh access to root.

A custom nixos install disk can be build with nix build '.#nixos-iso'. This ISO will include SSH public keys from config/modules/security/sshd/public-keys.nix as authorizedKeys for root.

Finally, run nix run '.#install-pc' or nix run '.#install-server' to provision the machine with nixos-anywhere. The script will prompt for the machine name and IP address.

NOTE: If you don't use the installer ISO and wish to deploy with colmena or provision with nixos-anywhere then be sure to provide your root user with an authorized SSH key.

Once you have your machine provisioned you can use colmena apply --on $MACHINE to deploy it.

Lastly, if you are deploying with colmena then you will either need a DNS entry for your machine names or you will need to tweak the mkMachine function and set the IP with deployment.targetHost.

Deployment

Deployments are done with colmena:

Build all servers:

$ colmena apply --on @server

Build a specific server:

$ colmena apply --on @sower

Build all PCs:

$ colmena apply --on @pc

Prior Art/Inspirations

About

Homelab managed wtih Nix Flakes

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published