- Nix 100%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| .forgejo/workflows | ||
| home | ||
| hosts | ||
| modules | ||
| secrets | ||
| users | ||
| .sops.yaml | ||
| configuration.nix | ||
| flake.lock | ||
| flake.nix | ||
| LICENSE | ||
| README.md | ||
NixOS Configuration
My personal NixOS flake supporting multi-host, multi-user, multi-DE. Each host loading the modules it needs.
[NOTE] If you plan on using it, be careful of removing my ssh keys, autoupdates from this repository...
Design
The flake uses mkHost helper that reads hosts/<host>/users.nix to setup the user config and DE if needed. it import only the strict necessary modules / configs.
Each user's config is split into three layers:
| Layer | Path | What goes here |
|---|---|---|
| shell | users/<user>/home.nix |
Shell, git, anything usable headless |
| DE common | home/common.nix + modules/desktop/common.nix |
Common apps for all desktop users |
| DE custom | users/<user>/desktop/<de>.nix |
User's own DE settings and theming |
Repository Structure
NixOS/
├── flake.nix # mkHost helper + nixosConfigurations outputs
├── configuration.nix # shared system config
│
├── hosts/
│ └── laptop_01/
│ ├── default.nix # host-specific hardware + services
│ ├── hardware-configuration.nix
│ ├── users.nix # where to add the users of a host
│ └── modules/
│ └── gpu-env.nix # NVIDIA Prime env vars + CUDA btop
│
├── modules/
│ ├── users.nix # defines users option
│ └── desktop/
│ ├── sddm.nix # display manager, loaded if desktop is present
│ ├── common.nix # common config for all DE users
│ ├── hyprland-noctalia/
│ │ ├── system.nix # hyprland programs
│ │ └── home.nix # UWSM env, Hyprland config, Noctalia
│ ├── kde/
│ │ ├── system.nix # kde programs
│ │ └── home.nix
│ └── programs/
│ ├── firefox-system.nix # programs specific configs
│ └── firefox-home.nix
│
├── home/
│ └── common.nix # headless only fish, starship, btop
│
└── users/
├── charon/
│ ├── system.nix # NixOS user declaration
│ ├── home.nix # minimal home (username, stateVersion)
│ └── desktop/
│ ├── default.nix # DE layer: personal packages
│ ├── firefox.nix
│ └── hyprland-noctalia.nix # DE specific configuration
└── peppa/
├── system.nix # minimal configuration for a user
└── home.nix
How to Use :
This repository is a working repository, you can use it as an example nixos configuration.
For a Template : https://git.self-privacy.eu/Homelab/NixOS-Template
Adding a host :
To add a new host (machine/VM) to this NixOS flake:
1. Create the host directory:
mkdir -p hosts/<hostname>/
Where <hostname> is your machine's identifier (e.g., vm_01, server-01, laptop_02)
2. Add the required configuration files:
| required | path | inside |
|---|---|---|
| Yes | hosts/<hostname>/default.nix |
System configuration (services, packages, settings) |
| Yes | hosts/<hostname>/users.nix |
Users that exist on this host and their desktop preferences |
| No | hosts/<hostname>/hardware-configuration.nix |
Auto-generated by nixos-generate-config for physical machines, add yours if you already have your config |
3. Register the host in the flake:
Open flake.nix and add:
#flake.nix
...
in {
nixosConfigurations.<hostname> = mkHost "<hostname>";
};
}
For example:
nixosConfigurations.vm_01 = mkHost "vm_01";
Adding a user :
The flake uses mkHost helper that reads hosts/<host>/users.nix
to setup the user config and DE if needed.
1. create the required user files:
| required | path | inside |
|---|---|---|
| Yes | users/<name>/system.nix |
NixOS user declaration |
| Yes | users/<name>/home.nix |
home-manager config |
| No, Only if you want a DE | users/<name>/desktop/default.nix users/<name>/desktop/<DE_name>.nix |
Desktop config such as kde, hyprland-noctalia... |
2. Register the user in the host's users.nix:
#hosts/<hostname>/users.nix
{
username = { desktop = null; }; # For headless
# OR
username = { desktop = "<DE_name>"; }; # For your DE, must match the .nix in the users/<name>/desktop/<DE_name>.nix
}
This setup allow for multi user, multi DE.