This repository contains my personal Nix configuration for two machines — a laptop and a homelab server. It uses Nix flakes, Home Manager (integrated as a NixOS module), and sops-nix for secrets. Everything is reproducible and deployable with a single command.
| Host | Machine | CPU | GPU | Role |
|---|---|---|---|---|
nixos |
HP Victus 15 | i5-12450H | RTX 2050 | Daily driver laptop (Hyprland + GNOME) |
homelab |
HP ENVY x360 | i5-6200U | Intel HD 520 | Home server (Jellyfin, *arr stack, Grafana) |
dotfiles/
├── flake.nix # Entry point — mkHost helper, one line per host
│
├── hosts/ # Per-machine config (ONLY host-specific stuff)
│ ├── nixos/ # Laptop — boot, audio, docker, LAMP, battery
│ └── homelab/ # Server — lid ignore, SSH, transcoding, firewall
│
├── modules/ # Shared & opt-in NixOS modules
│ ├── base.nix # Applied to ALL hosts (timezone, locale, git, tailscale)
│ ├── desktop/ # Laptop-only (gnome, kde, hyprland, nvidia)
│ └── server/ # Server-only (docker, jellyfin, monitoring, nginx)
│
├── home/ # Home Manager config (integrated into nixos-rebuild)
│ ├── default.nix # Entry point
│ ├── shell.nix # Zsh, aliases, oh-my-posh
│ ├── programs/ # alacritty, git, neovim, tmux, kitty, yazi
│ ├── wm/hyprland/ # Waybar, mako, scripts, swaync
│ └── themes/ # Prompt theme, wallpapers
│
└── secrets/ # sops-nix encrypted secrets
├── sops.nix
├── common/
└── homelab/
Enable flakes in your system (add to /etc/nixos/configuration.nix):
nix.settings.experimental-features = [ "nix-command" "flakes" ];git clone https://github.com/rahulgotrekiya/nix-configs.git ~/dotfiles
cd ~/dotfilesReplace the hardware config with your own:
cp /etc/nixos/hardware-configuration.nix hosts/nixos/hardware.nixBuild & apply - one command does everything (system + home-manager):
sudo nixos-rebuild switch --flake .#nixosFor the homelab (remotely via SSH):
nixos-rebuild switch --flake .#homelab --target-host neo@homelab --use-remote-sudoAdding a new machine is a 4-step process:
1. Create the host directory:
mkdir -p hosts/myhost2. Add hardware config:
# On the target machine:
nixos-generate-config --show-hardware-config > hosts/myhost/hardware.nix3. Create hosts/myhost/default.nix with only host-specific settings:
{ config, pkgs, meta, ... }:
{
imports = [ ./hardware.nix ];
# Only what's unique to this host goes here.
# Shared config (timezone, git, nix settings, tailscale)
# is automatically applied from modules/base.nix
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
system.stateVersion = "24.11";
}4. Add one entry to flake.nix:
nixosConfigurations = {
nixos = mkHost { hostname = "nixos"; homeModule = ./home; };
homelab = mkHost { hostname = "homelab"; user = "neo"; extraModules = [...]; };
myhost = mkHost { hostname = "myhost"; }; # ← just this line
};Then deploy:
sudo nixos-rebuild switch --flake .#myhostHome Manager is integrated as a NixOS module - no separate home-manager switch needed. When you run nixos-rebuild switch, it builds both system config and user environment atomically.
This is configured in flake.nix via the mkHost helper:
mkHost = { hostname, user ? "rahul", homeModule ? null, ... }:
lib.nixosSystem {
modules = [
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.${user} = import homeModule;
}
];
};Pass homeModule = ./home; to enable it for a host, or omit it for headless servers.
Thank you ❤️

