A NixOS flake providing system configurations for my personal computers and servers.
This flake's structure is inspired by diogotcorreia's NixOS dotfiles and is organized into 8 primary directories:
hosts: Each host is defined in its own directory, automatically including all.nixfiles within it. This is where modules are enabled, profiles are imported, and per-host custom options are configured.modules: Modules that can be enabled and configured via options.profiles: Profiles don't have any options and are imported into each hosts' configuration. Unlike other NixOS configurations, profiles are meant to be a collection of modules, packages or both.lib: Helper functions and attributes. This also contains the logic that define's this structure.packages: Custom definitions of packages that are not available in nixpkgs, made available in pkgs.my.overlays: Custom nixpkgs overlays. Each file in this directory is automatically applied to the package set.secrets: Per-host encrypted secrets managed with agenix.config: Static assets and configuration files imported into the systems (wallpapers, certificates, equalizer presets, etc).
- Home Manager
- Gnome
- Nebula VPN
- Distrobox with pod pre-installation
- rclone mount
- Easyeffects presets
- Multi-arch compatibility
- My personal collection of forensic tools
Machines follow a specific naming convention based on the fictional solar system from ASTRONEER. Stationary systems (those with a static physical location) are named after planets and moons.
My daily driver for general use:
- Desktop: GNOME with my personal flavor of themes, plugins, and GUI apps.
- Virtualization: VMWare, KVM and Distrobox with pods for CTFs.
- Boot: Custom boot animation using Plymouth.
- Security: Uses fido2 for secrets, and skips secure boot on GRUB (workaround for now - what an hypocrisy).
- Gaming: Steam, Proton-GE, Hydra, Roblox - packed for procrastination.
- Discord: Equicord via Nixcord - thanks ang3lo-azevedo.
- Restic: Gotta keep in touch with my cloud storage.
The public-facing primary server and lighthouse machine, chosen for it's high bandwidth:
- Nebula VPN: The main lighthouse to assist me with NAT punching.
- Services: Hosts my personal and private services.
(Nothing else for now.)
Named after Calidor's moon, this machine serves as Calidor's instancer and wakes occasionally to assist sylva with heavy workloads.
- Mr. Soldier - Nothing for now, just part of the army.
calidor: Stationary Desktop - Built to hoard data and handle GPU-intensive tasks.
If you haven't already, boot into a NixOS live installer.
I strongly recommend using a graphical installer to use GUI tools to assist the process.
Use netboot.xyz if you don't have access to a bootable USB/ISO, but have a network connection.
- Establish a network connection.
- Partition your storage if you haven't already. (Use GParted if on a graphical installer)
- Mount the filesystem partition on
/mntand the boot partition on/mnt/boot. (Use GParted again orsudo mount /dev/sdXY /mnt && sudo mount /dev/sdXZ /mnt/boot, taking sdX as your storage device, Y as the number of the filesystem partition and Z as the number of the boot partition) - Make sure your system has an ssh key (Use
sudo ssh-keygen -t ed25519 -f /mnt/etc/ssh/ssh_host_ed25519_key) - Add this ssh key to secrets.nix and rekey the secrets in another machine (commit and push).
- Make sure you have git installed (or use
nix-shell -p git). - Clone this repository to a folder inside /mnt (such as /mnt/etc/<nixos-config>).
- Generate a hardware configuration using
nixos-generate-config --show-hardware-configand add it as ahardware.nixto the dedicated host's folder. - Run
sudo nixos-install --root /mnt --flake .#<hostname>.
If you haven't already, install NixOS using the dedicated graphical installer for ease.
- Establish a network connection.
- Make sure your system has an ssh key (use
sudo ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key) - Make sure you have git installed (or use
nix-shell -p git). - Clone this repository to a folder inside /mnt (such as /mnt/etc/<nixos-config>).
- Add this ssh key to secrets.nix and rekey the secrets in another machine (commit and push).
- Generate a hardware configuration using
nixos-generate-config --show-hardware-configand add it as ahardware.nixto the dedicated host's folder. - Run
sudo nixos-rebuild switch --flake .#<hostname>on the configuration's root folder.
Deploying through SSH (with secrets - nixrnl)
Warning: Do not use deploy-anywhere without setting up disko for that machine.
Start a shell with a development environment:
nix developAnd then run the following command to deploy a new machine:
deploy-anywhere .#<nixosConfiguration> root@<ip/hostname> [<sshHostKey>]Description of the arguments:
<nixosConfiguration>: The machine's hostname.<ip/hostname>: The IP address or hostname of the machine to deploy to.<sshHostKey>(Optional): The SSH host key of the machine to deploy to. This value should be the name of the secret in thesecrets/host-keysdirectory (without the.age). If omitted, the VM cannot have secrets using Agenix and will generate a new SSH host key.
After the deployment is complete, you should be able to SSH into the machine.
To deploy your flake using a custom live USB/ISO, you need to either create a copy or temporarily add installation-cd-graphical-calamares-gnome.nix or a similar installer to your host's configuration.
Also add this to the configuration, so the flake source is bundled:
isoImage.contents = [
{ source = ./.; target = "/nixos-config-source"; }
];// # TODO Implement a declarative creation of '<hostname>-live' config
Warning: Regarding agenix secrets, you must use a fido2 key or create the machine's ssh host key in advance, rekey the secrets, and transfer the key pair alongside the live USB/ISO. (Place it in the flake's root directory so it's bundled altogether, or just use an extra USB)
To create an ISO from a host configuration, you should run the following command:
nix build .#nixosConfigurations.<nixosConfiguration>.config.system.build.isoImageDescription of the arguments:
<nixosConfiguration>: The name of the configuration you edited or copied.
After the ISO is built, you can write it to a USB drive using the following command:
dd if=result/iso/<nixosConfiguration>.iso of=/dev/sdX status=progressThe installation is now identical to a manual installation:
- Establish a network connection.
- Partition your storage if you haven't already. (Use GParted if on a graphical installer)
- Mount the filesystem partition on
/mntand the boot partition on/mnt/boot. (Use GParted again orsudo mount /dev/sdXY /mnt && sudo mount /dev/sdXZ /mnt/boot, taking sdX as your storage device, Y as the number of the filesystem partition and Z as the number of the boot partition) - Make sure you have your fido2, or transfered ssh key in
/mnt/etc/ssh/ssh_host_ed25519_key. - Make sure you have git installed (or use
nix-shell -p git). - Generate a hardware configuration using and add it as a
hardware.nixto the dedicated host's folder, using:sudo nixos-generate-config --root /mnt --show-hardware-config > /nixos-config-source/hosts/<nixosConfiguration>/hardware.nix. - Run
sudo nixos-install --root /mnt --flake .#<nixosConfiguration>.
My configuration was heavily inspired by:
And it was also inspired by the following configurations:
