Declarative NixOS dot-files configuration for running NixOS on WSL2 and Nix with home-manager. This configuration provides a development environment in a declarative manner.
Currently tested on:
- NixOS with WSL2 (x64)
- Ubuntu 24.04 with WSL2 (x64, arm64)
Simply run the included setup script to install this configuration automatically:
./setup.shThe script will guide through architecture selection and configuration options for your system.
This configuration includes:
- Nix and NixOS System Configuration: Core system settings for WSL2.
- Home Manager Integration: User-specific package and dotfile management.
- Personal Neovim Configuration: Configured development environment.
- WSL2 Addition: Integration with Windows host system thanks to NixOS-WSL.
nix-config/
├── flake.nix # Main flake configuration with inputs and outputs
├── flake.lock # Lock file for reproducible builds
├── setup.sh # Automated installation script
├── README.md # This documentation
├── modules/ # System-level configuration modules
│ ├── system.nix # Core system configuration
│ └── users.nix # User management configuration
├── system-configs/ # Architecture-specific configurations
└── home/ # Home Manager configurations
├── default.nix # Main home configuration entry point
├── packages.nix # User package definitions
└── programs/ # Program-specific configurations
├── git.nix # Git configuration
└── zsh.nix # Zsh shell configuration
- flake.nix: Defines the flake inputs (nixpkgs, home-manager, nixos-wsl) and system configuration.
- setup.sh: Interactive script for automatic installation and configuration.
- modules/system.nix: Core system settings including experimental features and WSL2 configuration.
- modules/users.nix: User management, sudo configuration, and user definitions.
- system-configs/: Architecture-specific configurations for different systems.
- home/: User-specific Home Manager configurations organized by components.
- Windows 10/11 with WSL2 enabled.
- Basic understanding of Nix/NixOS concepts.
-
Download the latest NixOS-WSL tarball from the releases page
-
Import the tar file into WSL:
wsl --import NixOS .\NixOS\ .\nixos-wsl.tar.gz --version 2
-
Start the NixOS instance:
wsl -d NixOS
-
Once inside the NixOS-WSL instance, clone this repository:
git clone https://github.com/bryaneduarr/dot-files.nix.git cd dot-files.nix -
When using with different user settings, update the configuration:
- In
flake.nix: Changewsl.defaultUserto your desired username. - In
modules/users.nix: Update the user configuration with your details. - In
home/programs/git.nix: Update Git username and email.
- In
-
Build and switch to the new configuration:
sudo nixos-rebuild switch --flake ~/dot-files.nix#nixos -
Exit and restart WSL to ensure all changes take effect:
wsl -t NixOS wsl -d NixOS
-
Set a password for your user:
sudo passwd bryaneduarr # Replace with your username. -
Switch to your user account:
su bryaneduarr # Replace with your username.
The configuration includes an update function. Simply run:
updateThis is equivalent to:
sudo nixos-rebuild switch --flake ~/dot-files.nix#nixos- System packages: Add to the appropriate module in
modules/. - User packages: Add to
home/packages.nix.
Example of adding a new user package to home/packages.nix:
{ pkgs, ... }:
{
home.packages = with pkgs; [
# Existing packages...
git
neovim
# Add new package here
firefox
];
}