diff --git a/CLAUDE.md b/CLAUDE.md index 5dfce65..1540e8a 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -74,4 +74,5 @@ 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 +4. **direnv integration**: Configured to work with Nix for project-specific environments +5. **SSH support**: Configured to ensure Nix tools are available in both interactive and non-interactive SSH sessions diff --git a/home.nix b/home.nix index f4c3078..80ff7c3 100644 --- a/home.nix +++ b/home.nix @@ -29,11 +29,16 @@ # Set environment variables for all shells home.sessionVariables = { - NIX_PATH = "${config.home.homeDirectory}/.nix-defexpr/channels:nixpkgs=$HOME/.nix-defexpr/channels/nixpkgs"; - # Pre-set NIX_SOURCED to avoid duplicate sourcing - NIX_SOURCED = "1"; + NIX_PATH = "${config.home.homeDirectory}/.nix-defexpr/channels:nixpkgs=${config.home.homeDirectory}/.nix-defexpr/channels/nixpkgs"; }; + # Create SSH environment file for non-interactive sessions + # This helps with SSH commands that don't source profile files + home.file.".ssh/environment".text = '' + PATH=${config.home.homeDirectory}/.nix-profile/bin:/nix/var/nix/profiles/default/bin:$PATH + NIX_PATH=${config.home.homeDirectory}/.nix-defexpr/channels:nixpkgs=${config.home.homeDirectory}/.nix-defexpr/channels/nixpkgs + ''; + # Packages to install home.packages = with pkgs; [ eza @@ -44,19 +49,24 @@ enable = true; enableCompletion = true; - # Bash initialization - initExtra = '' - # Ensure Nix paths are properly set up + # This is sourced by both interactive and non-interactive shells + # Critical for SSH non-interactive sessions + profileExtra = '' + # Ensure Nix paths are properly set up for all shells 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 + # Source nix environment if it exists + if [ -e "$HOME/.nix-profile/etc/profile.d/nix.sh" ]; then . "$HOME/.nix-profile/etc/profile.d/nix.sh" fi ''; + # This is only sourced by interactive shells + initExtra = '' + # Additional interactive shell settings can go here + ''; + shellAliases = { "hm-up" = "nix run github:nix-community/home-manager/release-25.05 -- switch --no-write-lock-file --refresh --flake 'git+https://g.t1.xyz/tb/nix-ebay-home.git#tbingmann'"; };