Here are my NixOS configurations.
I'm using this for consistent configuration and portability from machine to machine with a small amount of changes (usually disks, partitions, or hardware changes)
The configurations allow for a base system to be installed, with a core amount of applications to operate, you could add to it, but I feel that this configuration shines when you pair it with something like Home Manager for discrete per-er configuration of their environment. Head on overto my Nix Home Manager | Dotfiles Repository to get an understanding on how I "daily drive" my userspace environments.
Highlights:
BTRFS subvolume implementation with hourly automatic snapshots
-
Impermanence toggled for a clean installation on each reboot
-
Toggled full disk encryption
-
Support for RAID configurations
-
Toggled options for hardware, applications, and features, like VPNs
-
Deployment of secrets using sops-nix
-
Much, much more
-
I
blewspent the summer of 2023 moving into this configuration after waving a fond farewell to near 2 decades of running Arch Linux. This, as with life, is still WIP. I documented the process on the Tired of IT! NixOS chapter on my website.
flake.nix
: Entrypoint for NixOS configurations.hosts
: Host Configurationscommon
: Shared configurations consumed by all hosts.secrets
: Secrets that are available to all users
<host_a>
: "host_a" specific hardware and host configurationsecrets
: Secrets that are specific to the 'host_a' host
...
: And so on as above with other hosts
lib
: Helpers, functions, libraries and timesaversmodules
: Modules that are specific to this implementation and allow for toggled configurationapplication
: Applications accessible to all users of systemcontainer
: Containers using some sort of OCI container enginefeatures
: Features such as virtualization, gaming, cross compilationfilesystem
: Encryption, impermanence, BTRFS optionshardware
: Bluetooth, Printing, Sound, Wirelessnetwork
: Firewalls and VPNsservice
: Miscellanious daemons
overlays
: Ammendments and updates to packages that exist in the nix ecospherepkgs
: Custom packages, services, scripts that are specific to this installationusers
: Individual User folders
Get your installer disc booted up and your disks partitioned. I took notes on how I did an install with BTRFS and encryption on my website. Once you have your partitions created and subvolumes mounted then we can continue..
- Generate your
hardware-configuration.nix
file.
nixos-generate-config --root /mnt --file /tmp
- Go ahead and clone this repository.
nix-shell -p git nixFlakes
git clone https://github.com/tiredofit/nixos-config.git /mnt/etc/nixos
-
Either create a new host entry in
flake.nix
and add associated bits to thehosts
folder or modify one of the existing hostshardware-configuration.nix
with what you generated above. That's kinda janky, but it'll get you started.. -
Install your new NixOS system
nixos-install --root /mnt --flake /mnt/etc/nixos#<host>
- Use the included deployment script on an Arch or NixOS system to:
- Add remove new hosts and templates
- Update Flake
- Update running system
- Generate SSH Key and AGE keys per host
- Update host / repository secrets
- Remotely install a new system based on configuration via SSH
- Build locally and remotely update an in place system via SSH
Features are toggleable via the host
configuration options. Have a look insie the modules/nixos
folder for options available.
For example to have a base AMD system using with an integrated GPU using BTRFS as a file system that allowed SSH, Docker, and a hardware webcam it would be configured as such:
host = {
hardware = {
cpu = "amd";
graphics = {
acceleration = true;
displayServer = "x";
gpu = "integrated-amd";
};
webcam.enable = true;
};
network = {
hostname = "samplehostname" ;
domainname = "tiredofit.ca" ;
};
role = server;
};
This very much relies on the modules/roles
folder and sets defaults per role, which can be overridden in each hosts unique configuration.
sudo nix flake update /etc/nixos/
sudo nixos-rebuild switch --flake /etc/nixos/#<host>
I document the process of getting encrypted secrets created and keeping up to date on my website. Tired of IT! Secrets Management.
Do you what you'd like and I hope that this inspires you for your own configurations as many others have myself attribution would be appreciated.