Hosts Directory#
This directory contains host-specific configurations for different machines.
Structure#
Each host has its own subdirectory with the following files:
default.nix- Main configuration file for the hosthardware-configuration.nix- Hardware-specific configuration (generated by nixos-generate-config)
Current Hosts#
- laptop - Dell Inspiron 3501
Adding a New Host#
- Create a new directory under
hosts/with your hostname - Copy your hardware configuration:
sudo nixos-generate-config --show-hardware-config > hosts/YOUR-HOST/hardware-configuration.nix - Create a
default.nixusing the template below - Add the host to
flake.nixin thenixosConfigurationssection
Template default.nix#
{ config, pkgs, ... }:
{
imports = [
./hardware-configuration.nix
../../modules/desktop.nix # Optional: Remove if not needed
../../modules/packages.nix
../../modules/services.nix
../../modules/gaming.nix # Optional: Remove if not needed
];
# Boot configuration
boot = {
loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
kernelPackages = pkgs.linuxPackages_latest;
};
# Networking
networking = {
hostName = "YOUR-HOSTNAME-HERE";
networkmanager.enable = true;
};
# Timezone and locale
time.timeZone = "Europe/London";
i18n.defaultLocale = "en_GB.UTF-8";
# Console configuration
console = {
font = "Lat2-Terminus16";
keyMap = "uk";
};
# Sound
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
};
# User configuration
users.users.YOUR-USERNAME = {
isNormalUser = true;
description = "YOUR-DESCRIPTION";
extraGroups = [ "networkmanager" "wheel" "audio" "video" ];
shell = pkgs.zsh;
};
# Enable zsh system-wide
programs.zsh.enable = true;
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
# Enable flakes
nix.settings.experimental-features = [ "nix-command" "flakes" ];
# System version
system.stateVersion = "25.11";
}
Adding to flake.nix#
Add your new host to the nixosConfigurations section:
YOUR-HOSTNAME = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./hosts/YOUR-HOSTNAME
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.YOUR-USERNAME = import ./home/home.nix;
}
];
};
Building a Specific Host#
To build and switch to a specific host configuration:
sudo nixos-rebuild switch --flake .#YOUR-HOSTNAME
For the laptop:
sudo nixos-rebuild switch --flake .#laptop