1
0
mirror of https://github.com/nix-community/home-manager synced 2024-06-28 17:38:33 +02: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;
writeBashScript = name: text: pkgs.writeTextFile {
inherit name text;
checkPhase = ''
${pkgs.stdenv.shell} -n $out
'';
};
in
{
@ -178,7 +185,7 @@ in
}
));
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
[[ -f ~/.profile ]] && . ~/.profile
@ -186,7 +193,7 @@ in
[[ -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"
${sessionVarsStr}
@ -194,7 +201,7 @@ in
${cfg.profileExtra}
'';
home.file.".bashrc".source = pkgs.writeShellScript "bashrc" ''
home.file.".bashrc".source = writeBashScript "bashrc" ''
${cfg.bashrcExtra}
# Commands that should be applied only for interactive shells.
@ -210,7 +217,7 @@ in
'';
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 \
home-files/.bash_logout \
${
pkgs.writeShellScript "logout-expected" ''
builtins.toFile "logout-expected" ''
clear-console
''
}

View File

@ -18,7 +18,7 @@ with lib;
assertFileContent \
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"
export V1="v1"