1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-30 06:59:45 +01:00

bash: remove unnecessary shebang and executable bit for dotfiles (#2599)

This commit is contained in:
Tobias Happ 2022-01-01 18:06:55 +01:00 committed by GitHub
parent 89bdef7994
commit c2f151258a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 6 deletions

View file

@ -6,6 +6,13 @@ let
cfg = config.programs.bash; cfg = config.programs.bash;
writeBashScript = name: text: pkgs.writeTextFile {
inherit name text;
checkPhase = ''
${pkgs.stdenv.shell} -n $out
'';
};
in in
{ {
@ -178,7 +185,7 @@ in
} }
)); ));
in mkIf cfg.enable { in mkIf cfg.enable {
home.file.".bash_profile".source = pkgs.writeShellScript "bash_profile" '' home.file.".bash_profile".source = writeBashScript "bash_profile" ''
# include .profile if it exists # include .profile if it exists
[[ -f ~/.profile ]] && . ~/.profile [[ -f ~/.profile ]] && . ~/.profile
@ -186,7 +193,7 @@ in
[[ -f ~/.bashrc ]] && . ~/.bashrc [[ -f ~/.bashrc ]] && . ~/.bashrc
''; '';
home.file.".profile".source = pkgs.writeShellScript "profile" '' home.file.".profile".source = writeBashScript "profile" ''
. "${config.home.profileDirectory}/etc/profile.d/hm-session-vars.sh" . "${config.home.profileDirectory}/etc/profile.d/hm-session-vars.sh"
${sessionVarsStr} ${sessionVarsStr}
@ -194,7 +201,7 @@ in
${cfg.profileExtra} ${cfg.profileExtra}
''; '';
home.file.".bashrc".source = pkgs.writeShellScript "bashrc" '' home.file.".bashrc".source = writeBashScript "bashrc" ''
${cfg.bashrcExtra} ${cfg.bashrcExtra}
# Commands that should be applied only for interactive shells. # Commands that should be applied only for interactive shells.
@ -210,7 +217,7 @@ in
''; '';
home.file.".bash_logout" = mkIf (cfg.logoutExtra != "") { home.file.".bash_logout" = mkIf (cfg.logoutExtra != "") {
source = pkgs.writeShellScript "bash_logout" cfg.logoutExtra; source = writeBashScript "bash_logout" cfg.logoutExtra;
}; };
} }
); );

View file

@ -17,7 +17,7 @@ with lib;
assertFileContent \ assertFileContent \
home-files/.bash_logout \ home-files/.bash_logout \
${ ${
pkgs.writeShellScript "logout-expected" '' builtins.toFile "logout-expected" ''
clear-console clear-console
'' ''
} }

View file

@ -18,7 +18,7 @@ with lib;
assertFileContent \ assertFileContent \
home-files/.profile \ home-files/.profile \
${ ${
pkgs.writeShellScript "session-variables-expected" '' builtins.toFile "session-variables-expected" ''
. "/home/hm-user/.nix-profile/etc/profile.d/hm-session-vars.sh" . "/home/hm-user/.nix-profile/etc/profile.d/hm-session-vars.sh"
export V1="v1" export V1="v1"