diff options
| author | 2026-09-21 12:15:03 +0200 | |
|---|---|---|
| committer | 2026-09-21 12:15:03 +0200 | |
| commit | 8fa7344435dbf81accb0751b48fc4bd776a201ff (patch) | |
| tree | a7a8eba960c20480cf4541b3456793128ae5b3e4 /modules/home/bash-profile.nix | |
| parent | 57d9646b8094d0ca37af087d14ae677698e4efab (diff) | |
| download | desktop-flake-8fa7344435dbf81accb0751b48fc4bd776a201ff.tar.gz desktop-flake-8fa7344435dbf81accb0751b48fc4bd776a201ff.tar.bz2 desktop-flake-8fa7344435dbf81accb0751b48fc4bd776a201ff.zip | |
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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BBSd4VBfoKHjE1HR3P8kmn
Diffstat (limited to 'modules/home/bash-profile.nix')
| -rw-r--r-- | modules/home/bash-profile.nix | 21 |
1 files changed, 21 insertions, 0 deletions
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 @@ | |||
| 1 | { config, lib, pkgs, ... }: | ||
| 2 | let | ||
| 3 | bashProfileContent = pkgs.writeText "bash_profile" '' | ||
| 4 | # Written once by home-manager (modules/home/bash-profile.nix) so login | ||
| 5 | # shells actually source ~/.bashrc — NixOS and other Linux distros don't | ||
| 6 | # ship a ~/.bash_profile that does this by default. Only created if it | ||
| 7 | # didn't already exist; home-manager never touches it again after that, | ||
| 8 | # so it's yours to edit. | ||
| 9 | if [ -f "$HOME/.bashrc" ]; then | ||
| 10 | . "$HOME/.bashrc" | ||
| 11 | fi | ||
| 12 | ''; | ||
| 13 | in | ||
| 14 | { | ||
| 15 | home.activation.bashProfile = lib.hm.dag.entryAfter [ "writeBoundary" ] '' | ||
| 16 | BASH_PROFILE=${lib.escapeShellArg "${config.home.homeDirectory}/.bash_profile"} | ||
| 17 | if [ ! -e "$BASH_PROFILE" ]; then | ||
| 18 | $DRY_RUN_CMD ${pkgs.coreutils}/bin/install -m 644 ${bashProfileContent} "$BASH_PROFILE" | ||
| 19 | fi | ||
| 20 | ''; | ||
| 21 | } | ||
