diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..5dfce65 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,77 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Repository Purpose + +This repository contains a Nix home-manager flake configuration for setting up a user environment on a Linux system. It's designed for user `tbingmann` and includes configurations for Nix itself, Bash, direnv, Git, and other utilities. The configuration ensures Nix is properly installed and configured with experimental features enabled. + +## Code Architecture + +- **flake.nix**: The main Nix flake configuration file that defines inputs (dependencies) and outputs. It sets up the home-manager configuration for user `tbingmann`. +- **home.nix**: Contains the actual home-manager configuration including: + - User information + - Nix installation and configuration with flakes support + - Package installations + - Bash configuration and customizations with Nix PATH setup + - Direnv setup + - Git configuration + +## Common Commands + +### Applying Configuration Changes + +After making changes to the configuration: + +```bash +# If home-manager is not installed +nix run github:nix-community/home-manager/release-25.05 -- switch --flake .#tbingmann + +# If home-manager is installed +home-manager switch --flake .#tbingmann +``` + +### Direct Installation from Git Repository + +```bash +# If home-manager is not installed +nix --no-write-lock-file run github:nix-community/home-manager/release-25.05 -- switch --flake 'git+https://g.t1.xyz/tb/nix-ebay-home.git#tbingmann' + +# If home-manager is installed +home-manager --no-write-lock-file switch --flake 'git+https://g.t1.xyz/tb/nix-ebay-home.git#tbingmann' +``` + +### Checking Configuration Validity + +To validate configuration changes without applying them: + +```bash +home-manager build --flake .#tbingmann +``` + +### Debugging Issues + +For more detailed information when troubleshooting: + +```bash +home-manager switch --flake .#tbingmann --debug +``` + +## Configuration Guidelines + +When modifying this repository: + +1. Update packages in the `home.packages` section of `home.nix` +2. Customize Bash settings in the `programs.bash` section +3. Add or modify program configurations under the `programs` attribute +4. Adjust Nix configuration in the `nix` section if needed +5. Ensure the username (`tbingmann`) is consistent throughout the configuration + +## Nix Configuration Details + +The configuration includes: + +1. **Installation of Nix packages**: The `nix` package itself, `nixpkgs-fmt`, and `nix-direnv` +2. **Nix experimental features**: Enables both `nix-command` and `flakes` by default +3. **PATH configuration**: Sets up proper Nix paths in the Bash environment +4. **direnv integration**: Configured to work with Nix for project-specific environments \ No newline at end of file diff --git a/home.nix b/home.nix index 57b43b2..36d8bd2 100644 --- a/home.nix +++ b/home.nix @@ -4,126 +4,61 @@ # Home Manager needs a bit of information about you and the paths it should manage home.username = "tbingmann"; home.homeDirectory = "/home/tbingmann"; - + # Basic configuration home.stateVersion = "25.05"; # Let Home Manager install and manage itself programs.home-manager.enable = true; + # Nix configuration + nix = { + enable = true; + package = pkgs.nix; + settings = { + experimental-features = ["nix-command" "flakes"]; + warn-dirty = false; + }; + }; + # Packages to install home.packages = with pkgs; [ - # Basic utilities - coreutils - curl - wget - htop - ripgrep - fd - jq - tree ]; # Bash configuration programs.bash = { enable = true; enableCompletion = true; - - # Shell aliases - shellAliases = { - ll = "ls -la"; - ".." = "cd .."; - "..." = "cd ../.."; - "grep" = "grep --color=auto"; - "rm" = "rm -i"; - "cp" = "cp -i"; - "mv" = "mv -i"; - }; - + # Bash initialization initExtra = '' - # Custom prompt - PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' - - # Additional bash customizations - export EDITOR=vim - export PATH="$HOME/.local/bin:$PATH" - - # History settings - export HISTSIZE=10000 - export HISTFILESIZE=10000 - export HISTCONTROL=ignoreboth:erasedups - - # Custom functions - function mkcd() { - mkdir -p "$1" && cd "$1" - } + # Ensure Nix paths are properly set up + export PATH="$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:$PATH" + export NIX_PATH="$HOME/.nix-defexpr/channels:nixpkgs=$HOME/.nix-defexpr/channels/nixpkgs" + + # Source nix environment if it exists and not already sourced + if [ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ] && [ -z "$NIX_SOURCED" ]; then + export NIX_SOURCED=1 + . "$HOME/.nix-profile/etc/profile.d/nix.sh" + fi ''; - + # History configuration historyControl = [ "erasedups" "ignoredups" "ignorespace" ]; - historyFileSize = 10000; - historySize = 10000; + historyFileSize = 1000000; + historySize = 1000000; }; # Direnv configuration programs.direnv = { enable = true; nix-direnv.enable = true; - + # Add hook to .bashrc enableBashIntegration = true; - - # Configuration - config = { - whitelist = { - prefix = [ - "$HOME/projects" - "$HOME/work" - ]; - }; - }; - }; - - # Git configuration (useful with direnv) - programs.git = { - enable = true; - userName = "tbingmann"; - userEmail = "tbingmann@example.com"; # Replace with actual email - - # Basic configuration - extraConfig = { - core.editor = "vim"; - init.defaultBranch = "main"; - pull.rebase = false; - }; - }; - - # Create default .envrc template in home directory - home.file.".envrc-template" = { - text = '' - # This is a template .envrc file for use with direnv - # Copy this to your project directory and customize as needed - - # Load environment variables from .env file if it exists - if [ -f .env ]; then - dotenv - fi - - # Example: Set project-specific environment variables - # export PROJECT_ROOT=$(pwd) - # export PATH=$PROJECT_ROOT/bin:$PATH - - # Example: Use Nix shell - # use nix - - # Example: Use flake - # use flake - ''; - executable = false; }; }