My personal Home Lab / Home Server powered by Nix
To test things out, you can install the Home Lab config into a test VM.
These instructions will guide you on how to create a test VM and install a test version of the Home Lab to it.
-
Build an installer iso:
nix build -L .#installer-iso -
In
libvirt, create a Linux VM. Most of the default settings should just work. Make sure you set the boot ISO to./result/iso/nixos-installer-x86_64-linux.iso. -
Boot the VM. It'll eventually land on a page showing you network information
-
Install NixOS using
nixos-anywhere:nixos-anywhere --flake .#homelab-test root@nixos-installer.local
First, figure out the IP address of your VM:
virsh -c qemu:///system net-dhcp-leases defaultOpen you system /etc/hosts file and add the following values:
# Homelab dev
{VM IP Address} home.dotboris.io
{VM IP Address} traefik.dotboris.io
{VM IP Address} feeds.dotboris.io
{VM IP Address} netdata.dotboris.io
From there, you'll be able to access the various web apps by pointing your
browser to https://{host}.dotboris.io. You'll need to accept the self-signed
HTTPS certificate.
Once you're done remember to comment out the entries in your hosts file.
There are custom package in this repo. Some of these packages pull source from other places like GitHub. These are pinned to specific versions and hashes. Updating those packages means updating those versions and hashes. There's tooling in place to automate this:
nix run .#update-packagesThis will update all packages in the flake with passthru.updateScript = ...;.
If you want to update a package, add the following to the derivation.
{self, ...}: {
perSystem = {pkgs, ...}: {
packages.my-package = pkgs.stdenv.mkDerivation rec {
pname = "my-package";
version = "...";
passthru.updateScript = self.lib.updateScript {inherit pkgs pname;};
};
};
}You can also update a single package by running nix run .#{pname}.updateScript.
nix flake update -LMost of the time you don't need to reboot. Services with new versions gets rebooted automatically and other programs get the the update when they're closed and re-opened.
There are a few packages that require a reboot. They're core components of the system that can't just be restarted. They are:
- The Linux kernel
- SystemD
You can figure out what changed through the following steps:
- SSH into the machine
- Run:
nix profile diff-closures --profile /nix/var/nix/profiles/system
If the packages mentioned above have been updated, you need to reboot.
Some modules come with tests that either run in VMs or containers. Container tests are faster to run but come with limitations such as not being able to run SUID binaries like sudo.
To run container tests you must be on Linux and have the following in your /etc/nix/nix.conf:
experimental-features = auto-allocate-uids cgroups
extra-system-features = uid-range
auto-allocate-uids = trueYou can run individual tests through:
nix build -L .#checks.x86_64-linux.test-standard-backupsIf the test has already passed and won't run, pass the --rebuild flag.