Skip to content

Rishabh5321/dotfiles

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NixOS Logo

Rishabh's Flakes

My personal NixOS configurations, managed with Nix Flakes for reproducibility and modularity.

Repo Size NixOS Unstable License: MIT Last Commit Check and Build Flake Config Status

🖼️ Showcase

✨ Philosophy

This project aims to create a highly modular and reusable NixOS setup for all my machines. The core principles are:

  • Reproducibility: Nix Flakes ensure that every machine has the exact same configuration, defined declaratively.
  • Modularity: Configurations are broken down into small, reusable modules (./modules) that can be mixed and matched for different hosts.
  • Simplicity: The structure is designed to be easy to understand and manage, with a clear separation between system-level (configuration.nix) and user-level (home.nix) settings.
  • Automation: GitHub Actions are used to automatically check, build, and format the code, ensuring quality and consistency.

📂 Directory Structure

The repository is organized to separate concerns, making it easy to manage configurations for different machines and purposes.

.
├── containers/   # Nix definitions for containerized services (Plex, Sonarr, etc.)
├── hosts/        # Host-specific configurations. Each subdirectory is a unique machine.
│   └── dell/     # Example host configuration for a machine named 'dell'
│       ├── configuration.nix  # Main NixOS configuration for this host
│       ├── home.nix           # Home Manager configuration for the user on this host
│       └── ...                # Other host-specific files (e.g., hardware-configuration.nix)
├── modules/      # Reusable modules for system and user configurations
│       ├── desktop/  # Desktop Enviornments/ Window manager
│       ├── system/   # System-level modules (boot, networking, security, etc.)
│       └── user/     # Home Manager modules (shell, editors, browsers, etc.)
├── overlays/     # Custom Nixpkgs overlays to modify or add packages
├── pkgs/         # Custom packages built with Nix
├── flake.nix     # The heart of the project, defining inputs and outputs
└── README.md     # This file

🚀 Usage

Prerequisites

  • A machine with Nix installed, with support for Flakes enabled.
  • Git to clone the repository.

Installation

  1. Clone this repository to your local machine:

    git clone --depth 1 https://github.com/Rishabh5321/dotfiles
    cd dotfiles
  2. IMPORTANT: Before deploying, you must create a new host directory under ./hosts/ that matches your machine's hostname. You will also need to generate a hardware-configuration.nix specific to your hardware.

    # 1. Get your machine's hostname
    hostname
    
    # 2. Create a directory for your host
    mkdir -p hosts/$(hostname)
    
    # 3. Generate a hardware configuration for your new machine
    sudo nixos-generate-config --show-hardware-config > hosts/$(hostname)/hardware-configuration.nix
    
    # 4. Create your main configuration.nix and home.nix.
    #    You can copy from an existing host to get started.
    cp hosts/dell/configuration.nix hosts/$(hostname)/
    cp hosts/dell/home.nix hosts/$(hostname)/
  3. Apply the configuration. The flake is set up to automatically detect any directory in ./hosts as a valid nixosConfiguration.

    # Replace <hostname> with your machine's actual hostname
    sudo nixos-rebuild switch --flake .#<hostname>

    For example, to deploy the dell configuration:

    sudo nixos-rebuild switch --flake .#dell

flake.nix Details

Inputs

This flake pulls in several external dependencies to build the system. Key inputs include:

  • nixpkgs: The primary Nix package set, tracking nixos-unstable-small.
  • home-manager: Manages user-level dotfiles and packages.
  • stylix: For system-wide theming and styling.
  • sops-nix / agenix: (Future goal) For managing secrets securely.
  • And various other flakes for specific applications and themes.

Outputs

The flake provides the following outputs:

  • nixosConfigurations: The main output. It dynamically generates a NixOS configuration for every host defined in the hosts/ directory.
  • formatter: Provides a consistent code formatter (nixpkgs-fmt) for the entire project. You can run it with nix fmt.
  • overlays: Custom overlays defined in the overlays/ directory.

License

This project is licensed under the MIT License. See the LICENSE file for details.