.github | ||
docs | ||
hosts | ||
lib | ||
modules | ||
pkgs | ||
secrets | ||
shells | ||
templates | ||
users | ||
.editorconfig | ||
.envrc | ||
.gitattributes | ||
.gitignore | ||
.sops.yaml | ||
default.nix | ||
flake.lock | ||
flake.nix | ||
images.toml | ||
LICENSE | ||
Makefile | ||
README.adoc | ||
shell.nix | ||
treefmt.toml | ||
users.toml |
This is my NixOS config as a Nix flake.
I finally have some time trying to grok flakes and redo my NixOS config from scratch after leaving it for some time (because I have work and have to quickly set things up without me trying to debug how NixOS works). Here is the result.
Anyways, this project also has a dedicated website at https://foo-dogsquared.github.io/nixos-config.
Getting started
Caution
|
Despite being a NixOS system, it isn’t entirely reproducible to the point of installing this config will work out-of-the-box. It has some things needed in the first place to work like my external backup setup where it needs my SSH private keys to work in the first place. Nonetheless, the parts is it isn’t reproducible is only about 10% of this config. Everything else is fine and dandy. Oh right… Don’t expect everything is working in each commit but I’m doing my best to make them build successfully in each, yeah? Also, this configuration is expected to use under non-restricted evaluation mode. |
Hey there, fellow traveler! You’ve fell into the rabbit hole we call Nix where it leads to other rabbit holes such as functional package management, reproducibility, declarative systems, and immutable operating systems.
This is one of the many tickets to that rabbit hole, allow me to be your guide in this mark:[painful] wonderful declarative journey. Hope to see you on the other side!
Installation
Since this uses Nix flakes, you should have Nix v2.8 and above installed.
If you’re going to install one of my NixOS configs, be sure to download the unstable versions from their release page. As an additional option, you can also use my personalized NixOS installers which is primarily intended for me configs.
This primarily uses Nix flakes so you can have a preview of what’s available in my config.
nix flake show github:foo-dogsquared/nixos-config
It should export my NixOS configurations of my different hosts (of only one so far excluding VMs and VPSs ;p) among other things.
To install it, run the nixos-install --flake github:foo-dogsquared/nixos-config#ni
.
(Please see the respective appropriate host README for more information.)
The remote repo
For a complete overkill, we use a CI to further the configuration abomination. It uses GitHub workflows to enable things such as…
-
Automatically building my custom packages and sending them to my binary cache to easily distribute it for others.
-
Building my personalized NixOS installers and making a release out of it.
-
Testing the flake outputs (in progress lel).
Project structure
Last and foremost, we have the project directory — the environment you’ll be living in for the next year, tinkering your Nix configs. . It is required to be familiar with the workspace, after all. My configuration takes a lot of cues from devos (which is unfortunately is a lot to take if you’re just beginning to grok Nix as a whole).
My NixOS config should look like the following:
nixos-config
├── hosts/
├── lib/
├── modules/
├── pkgs/
├── scripts/
├── secrets/
├── shells/
├── templates/
├── users/
├── default.nix
├── flake.lock
├── flake.nix
├── images.toml
└── README.adoc
One of the more notable files here when first start looking is the ./images.toml
file where it contains a description of the images.
For more details, see [declarative-host-management].
Most of the said folders are related to a flake output attribute, see [whats-in-my-flake] for more details.
-
./hosts/
contain machine-specific configuration. This usually configures like the hardware setup, timezone, and users. Host configurations are also exported in the flakes inoutputs.nixosConfigurations
. -
./modules/
contain my custom modules including NixOS and home-manager modules. For more information, see the related documentation. -
./pkgs/
contains my custom packages. It is exported in the flakes atoutputs.packages
compiled through various systems. -
./scripts/
contains various scripts for various purposes. Should be self-explanatory. -
./secrets/
contains my cluster-wide secrets managed with sops and sops-nix. Take note, each component (e.g., hosts, modules, users) could have their own specific secrets. -
./shells/
contains my development shells for interacting with the usual type of projects. Setting this up can bring benefits outside of NixOS (unless you’re interacting with projects with any OpenGL-related stuff). [1] -
./templates/
contains my custom templates handy for quickly initializing for various types of projects. -
./users/
contains my home-manager configurations. It is exported in the flakes atoutputs.homeConfigurations
. For more information, see the related documentation.
TODO
In order of priority:
-
✓ Create custom modules.
-
✓ Create a themes system similar to this NixOS config.
-
✓ Create a good workflow for creating ISOs.
-
✓ Create development shells.
-
✓ Manage secrets with agenix.
-
❏ Create a good workflow for tests.
-
✓ Automate backups with NixOS config.
-
✓ Create custom packages and export it to flakes. (Maybe consider making it to upstream)
-
✓ Create cluser-wide configs.
-
✓ Create host-wide configs.
-
✓ Create user-specific configs with home-manager.
-
✓ Steal Get some ideas from this overengineered template.
-
✓ Make use of other established utilities such as digga, flake-utils-plus, and home-manager once I’m familiar to create my own Nix programs.
Out of scope:
-
Set most program configurations with Nix. This is especially applicable to programs I always use such as my text editor configs.
-
The reason: managing them can be chaotic when applied with Nix. The potential for it is pretty nice especially when seen with similar implementations such as Guix home environment. However, I don’t want to rebuild it every time I change it.
-
Plus, most of my applications are now installed using Flatpak anyways. It is a tad easier to manage configurations installed this way (e.g., just copy
~/.var
between your systems or make backups with it).
-
-
Migration of my dotfiles. I still use it on other non-NixOS systems.
-
To be a configuration framework. This is my personal configuration which means experimentation will always be here. Sudden changes can happen at any point.
Copyright
This project is licensed under MIT license.
I just chose it to make it easier to upstream parts of this project to nixpkgs and to make it easier to copy it without much problems (just don’t forget to add attribution as indicated from the license).
Please see ./LICENSE
for the full text.