This is my personal nixos configuration. It is an attempt at a modular nix config structure to support multiple machines and even users. I've taken a fair amount of inspiration from EmergentMind's config, as well as a heap of others I can't recall. However, this config is separated from the home configuration; it is only a system config! I use it in conjunction with my home manager config found in my dotfiles repo.
This config:
- Is just a NixOS system config, very barebones and no user config (apart from initial setup)
- Uses flakes
- Uses the unstable channel for nixpkgs
- Is meant to be used with home manager as a standalone, non-root utility
Tip
Feel free to take inspiration from this config as I have from others.
As a reminder to myself and as a resource to anyone seeking inspiration, here is the bootstrapping process:
-
Get an ISO from here
-
Follow the installation steps, with or without a desktop environment (we'll install our own in a moment anyway)
-
If it wasn't in your ISO of choice, fetch git using nixpkgs, like so:
$ nix-shell -p git
...or add it to the default nixos config and rebuild:
# configuration.nix environment.systemPackages = [ pkgs.git ];
$ sudo nixos-rebuild switch
-
Move to where you want your config. It can be anywhere, I currently have it in
~/nixos-config
(meaning I would run git clone in~/
) -
Clone the repo:
$ git clone [email protected]:otytlandsvik/nixos-config.git
-
Create a host specific config to bootstrap the new host under
nixos-config/hosts
. Simply copy another config as a template and setup specifics accordingly
Warning
Remember to copy the hardware-configuration.nix
file that NixOS generated for your system! It should be at /etc/nixos/
- If you need another user, create one by using
nixos/config/hosts/common/users/ole
as a template - Add the new host as an output in the flake
- Rebuild referencing this new output (as an example, if the new output was
hostname
):$ sudo nixos-rebuild switch --flake .#hostname
Note
The .
here specifies the cwd. It must be a path to the directory containing the flake.nix
file, followed by #hostname
$ exec sway
to start it. That's it for the system config!
To bootrap the home configuration for my user, follow the steps in my dotfiles repo.