Skip to content

spitulax/nixos-config

Repository files navigation

spitulax's NixOS Config

This is my NixOS configuration for my systems with Nix Flake. If you want to grab something from here, feel free!

Screenshot

Structure

This is my first attempt at centralizing NixOS configuration. This repo starts out humbly before gradually turning into a mess. The current structure emerged slowly from me trying to refactor parts of the config one at a time and from old structure that's stuck from the dawn of this repo, so there was no planned structuring but I'm happy with this (for now).

REPL Tricks

Adding something to the flake's output means that it will be easily accessible from Nix REPL. The idea is that the REPL is the best place to just quickly test the configs. So I've added some things to the flake's output for easy access and also I've made so that if you load this flake in Nix REPL, configurations declared in ./flake/configs.nix are easily accessible by using nixos-<hostname> for NixOS configs or home-<username>-<hostname> for Home Manager configs. This makes searching for options and debugging much more convenient.

NixOS Config

Adding host config

In flake/configs.nix, add an attribute to nixosConfigurations using myLib.nixosConfig. The attribute name is the hostname and the config module for the host is located in hosts/<hostname> directory. You can add a user for the host from the users attribute set. See here for an example of host config module.

SSH Keys

A pair of SSH public keys are needed for a host if config.configs.openssh.addHostKeys is true. ssh-rsa.pub and ssh-ed25519.pub will be searched from keys/users/<username>. Host keys should not be password protected.

Host config module

The config module is just like any regular NixOS module. Importing nixosConfigModule from the flake's output makes the config easily customisable with pre-defined options. If something needs to be adjusted for a single host put the module inside the hosts/<hostname> directory and adjust the needed options like usual.

Adding nixosConfigModule options

See here.

Home Manager Config

Adding a user

A user also means a home-manager config/profile. One home-manager user/config can be used for multiple hosts. To add it, add an attribute to flake/users.nix using myLib.mkUser. config/home/<username>/ is automatically looked into for the config modules.

SSH Keys

By default a pair of SSH public keys are needed for a user, an ed25519 key and an rsa key that should be password protected. ssh-rsa.pub and ssh-ed25519.pub will be searched from keys/users/<username>.

Adding a user to a host

In flake/configs.nix, add an attribute to homeConfigurations using myLib.homeManagerConfig. The name of the attribute should be <username>@<hostname>. The module for each declared combination of user and host is located in users/<username>_<hostname> directory. See here for an example of user config module.

User config module

Just like NixOS config module, user config module is just like any regular home-manager module. But the users attribute set provides a home-manager module to simplify customisation just like what nixosConfigModule does. To use it, import users.<username>.homeManagerModule.

Adding homeManagerModule options

See here.

Components

Here are some of the programs configured in this repo.

Desktop

  • Display Manager: GDM
  • Window Manager (Wayland): Hyprland

CLI Tools

GUI Apps

Development

Misc

And More!

Cool Dotfiles

Dotfiles by other people that massively helped my Nix journey.

To-Do