1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19: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;
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"