This is my NixOS configuration for my systems with Nix Flake. If you want to grab something from here, feel free!
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).
assets/
: Useless picturesconfig/
: See hereflake/
: Stuff to be imported byflake.nix
configs.nix
: Declaration of configsusers.nix
: Declaration of home-manager configs/usersvars.nix
: Variables that are shared with configs, modules, etc. so they are declared in flake
hosts/
: Host-specific configslib/
: Helper functions (imported asmyLib
to flake)modules/
: See hereoverlays/
: Nix overlays (imported to flake)packages/
: Nix packages and scripts I won't bother moving into separate reposecrets/
: See hereusers/
: See hereflake.nix
: The root of this entire repodefault.nix
: Mostly there so I can uselib/
from REPLMakefile
: Command shortener, e.g.make nixos
for building NixOS configs,make home
for building Home Manager configs, etc.
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.
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.
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.
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.
See here.
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.
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>
.
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.
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
.
See here.
Here are some of the programs configured in this repo.
- Terminal Emulator: Kitty
- Terminal Multiplexer: Tmux
- Shell: Fish (details)
- Shell Prompt: Starship
- Resource Monitoring: Btop
- Browser: Brave
- Screen Recording: OBS
- Password Manager: Bitwarden
- File Manager: Dolphin
- Screenshot: Gripper
- Media Player: Mpv
- Painting: Krita
- Image Viewer: Gwenview
- PDF Viewer: Zathura
- Terminal Colorschemes: Catppuccin
- GTK Theme: Fluent GTK Theme
- Qt Theme: Materia KDE
- Font: Iosevka with Nerd Fonts
- File Syncing: Syncthing
- Key Remapper: Keymapper
- Secret Management: sops.nix
Dotfiles by other people that massively helped my Nix journey.
- https://github.com/librephoenix/nixos-config
- https://github.com/jakehamilton/config
- https://github.com/Misterio77/nix-config
- https://github.com/ryan4yin/nix-config
- https://github.com/hlissner/dotfiles
- https://github.com/fufexan/dotfiles
- Set up impermanence