From 8fa7344435dbf81accb0751b48fc4bd776a201ff Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Mon, 21 Sep 2026 12:15:03 +0200 Subject: Add always-on ~/.bash_profile bootstrap for login shells NixOS and most other Linux distros don't ship a ~/.bash_profile that sources ~/.bashrc, so login shells miss the user's bash config. Adds a home-manager activation script that creates one only when absent, on every platform, without ever touching a pre-existing .bash_profile. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01BBSd4VBfoKHjE1HR3P8kmn --- modules/home/bash-profile.nix | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 modules/home/bash-profile.nix (limited to 'modules/home/bash-profile.nix') diff --git a/modules/home/bash-profile.nix b/modules/home/bash-profile.nix new file mode 100644 index 0000000..30114ba --- /dev/null +++ b/modules/home/bash-profile.nix @@ -0,0 +1,21 @@ +{ config, lib, pkgs, ... }: +let + bashProfileContent = pkgs.writeText "bash_profile" '' + # Written once by home-manager (modules/home/bash-profile.nix) so login + # shells actually source ~/.bashrc — NixOS and other Linux distros don't + # ship a ~/.bash_profile that does this by default. Only created if it + # didn't already exist; home-manager never touches it again after that, + # so it's yours to edit. + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi + ''; +in +{ + home.activation.bashProfile = lib.hm.dag.entryAfter [ "writeBoundary" ] '' + BASH_PROFILE=${lib.escapeShellArg "${config.home.homeDirectory}/.bash_profile"} + if [ ! -e "$BASH_PROFILE" ]; then + $DRY_RUN_CMD ${pkgs.coreutils}/bin/install -m 644 ${bashProfileContent} "$BASH_PROFILE" + fi + ''; +} -- cgit v1.3