Skip to content

bryaneduarr/dot-files.nix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

47 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dot-Files for Nix and NixOS

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)

Quick Setup

Simply run the included setup script to install this configuration automatically:

./setup.sh

The script will guide through architecture selection and configuration options for your system.

Overview

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.

Configuration Structure

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

Key Components

  • 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.

How to Use This Configuration

Prerequisites

  • Windows 10/11 with WSL2 enabled.
  • Basic understanding of Nix/NixOS concepts.

Step 1: Install NixOS-WSL

  1. Download the latest NixOS-WSL tarball from the releases page

  2. Import the tar file into WSL:

    wsl --import NixOS .\NixOS\ .\nixos-wsl.tar.gz --version 2
  3. Start the NixOS instance:

    wsl -d NixOS

Step 2: Clone This Configuration

  1. Once inside the NixOS-WSL instance, clone this repository:

    git clone https://github.com/bryaneduarr/dot-files.nix.git
    cd dot-files.nix
  2. When using with different user settings, update the configuration:

    • In flake.nix: Change wsl.defaultUser to your desired username.
    • In modules/users.nix: Update the user configuration with your details.
    • In home/programs/git.nix: Update Git username and email.

Step 3: Apply the Configuration

  1. Build and switch to the new configuration:

    sudo nixos-rebuild switch --flake ~/dot-files.nix#nixos
  2. Exit and restart WSL to ensure all changes take effect:

    wsl -t NixOS
    wsl -d NixOS

Step 4: Set Up the User

  1. Set a password for your user:

    sudo passwd bryaneduarr  # Replace with your username.
  2. Switch to your user account:

    su bryaneduarr  # Replace with your username.

Alias Commands Usage

Updating the System

The configuration includes an update function. Simply run:

update

This is equivalent to:

sudo nixos-rebuild switch --flake ~/dot-files.nix#nixos

Adding New Packages

  1. System packages: Add to the appropriate module in modules/.
  2. 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
  ];
}

About

Dot Files for Nix and NixOS

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published