Skip to content
/ chenglab Public

a straightforward NixOS setup for my homelab and personal computers

License

Notifications You must be signed in to change notification settings

eh8/chenglab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

chenglab
chenglab
Homelab hardware: ThinkCenter M710q Tiny, Intel i5-7500T and 8GB RAM

nixos 24.05 blog post stars

Highlights

This repo contains the Nix configurations for my homelab, AMD Ryzen desktop, M1 MacBook Air, and work WSL setup.

  • ❄️ Nix flakes handle upstream dependencies and track latest stable release of Nixpkgs (currently 24.05)
  • 🏠 home-manager manages dotfiles
  • 🍎 nix-darwin manages MacBook
  • 🀫 sops-nix manages secrets
  • πŸ”‘ Remote initrd unlock system to decrypt drives on boot
  • 🌬️ Root on tmpfs aka impermanence
  • πŸ”’ Automatic Let's Encrypt certificate registration and renewal
  • 🧩 Tailscale, Nextcloud, Jellyfin, Homebridge, Scrypted, among other nice self-hosted applications
  • ⚑️ justfile contains useful aliases for many frequent and atrociously long nix commands
  • πŸ€– flake.lock updated daily via GitHub Action, servers are configured to automatically upgrade daily via modules/nixos/auto-update.nix
  • 🧱 Modular architecture promotes readability for me and copy-and-paste-ability for you
  • πŸ“¦ Custom ready-made tarball and ISO for installing NixOS-on-WSL and NixOS, respectively

Getting started

macOS

On macOS, this script will install nix using the Determinate Systems Nix installer and prompt you to install my configuration.

Important

You'll need to run this script as sudo or have sudo permissions.

bash -c "$(curl -fsSL https://raw.githubusercontent.com/eh8/chenglab/main/install.sh)"

NixOS (Linux)

Important

You'll need to run this script as sudo or have sudo permissions.

Warning

This script is primarily meant for my own use. Using it to install NixOS on your own hardware will fail. At minimum, you'll need to do the following before attemping installation:

  1. Create a configuration for your own device in the machines/ folder
  2. Retool your own sops-nix secrets or remove them entirely if you don't use sops-nix
  3. Add an entry to flake.nix referencing the configuration created in step 1

On Linux, running this script from the NixOS installation ISO will prepare your system for NixOS by partitioning drives and mounting them.

bash -c "$(curl -fsSL https://raw.githubusercontent.com/eh8/chenglab/main/install.sh)"

Tip

When installing NixOS onto a headless local server, place your own custom NixOS ISO file onto a USB drive with Ventoy. Ventoy can automatically load the NixOS ISO file, and you can enable connectivity by building your own custom ISO with your own personal SSH key. The custom ISO released in this repo is baked with my own key.

Windows Subsystem for Linux (WSL)

  1. Enable WSL if you haven't done already:
wsl --install --no-distribution
  1. Download nixos-wsl.tar.gz from the latest release.

  2. Import the tarball into WSL:

wsl --import NixOS $env:USERPROFILE\NixOS\ nixos-wsl.tar.gz
  1. You can now run NixOS:
wsl -d NixOS

Useful commands πŸ› οΈ

Install just to access the simple aliases below

Locally deploy changes

just deploy macos
just deploy MACHINE

Remote deployment

To remotely deploy MACHINE, which has an IP address of 10.0.10.2

just deploy MACHINE 10.0.10.2

Edit secrets

Make sure each machine's public key is listed as entry in .sops.yaml. To modify secrets/secrets.yaml:

just secrets-edit

Syncing sops keys for a new machine

just secrets-sync

Important caveats

Changing user passwords

To modify user password, first generate a hash

echo "password" | mkpasswd -m SHA-512 -s

Then run just edit-secrets to replace the existing decrypted hash with the one that you just generated. If you use a password manager, sure to update the new password as necessary.

Changing SSH keys

Make sure you update the public key as it appears across the repository.

Installation source

Make sure the Determinate Nix installer one-liner in install.sh is consistent with how it appears on the official website.

To-do

  1. Secure boot
  2. Binary caching
  3. Wireless remote unlocking

Frequently used resources

Helpful references