bash: generate files using writeShellScript
This ensures that the generated file is syntactically valid. Issue #2015
This commit is contained in:
parent
794d08a1d8
commit
e9b7d12e06
|
@ -169,9 +169,7 @@ in
|
||||||
}
|
}
|
||||||
));
|
));
|
||||||
in mkIf cfg.enable {
|
in mkIf cfg.enable {
|
||||||
home.file.".bash_profile".text = ''
|
home.file.".bash_profile".source = pkgs.writeShellScript "bash_profile" ''
|
||||||
# -*- mode: sh -*-
|
|
||||||
|
|
||||||
# include .profile if it exists
|
# include .profile if it exists
|
||||||
[[ -f ~/.profile ]] && . ~/.profile
|
[[ -f ~/.profile ]] && . ~/.profile
|
||||||
|
|
||||||
|
@ -179,9 +177,7 @@ in
|
||||||
[[ -f ~/.bashrc ]] && . ~/.bashrc
|
[[ -f ~/.bashrc ]] && . ~/.bashrc
|
||||||
'';
|
'';
|
||||||
|
|
||||||
home.file.".profile".text = ''
|
home.file.".profile".source = pkgs.writeShellScript "profile" ''
|
||||||
# -*- mode: sh -*-
|
|
||||||
|
|
||||||
. "${config.home.profileDirectory}/etc/profile.d/hm-session-vars.sh"
|
. "${config.home.profileDirectory}/etc/profile.d/hm-session-vars.sh"
|
||||||
|
|
||||||
${sessionVarsStr}
|
${sessionVarsStr}
|
||||||
|
@ -189,9 +185,7 @@ in
|
||||||
${cfg.profileExtra}
|
${cfg.profileExtra}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
home.file.".bashrc".text = ''
|
home.file.".bashrc".source = pkgs.writeShellScript "bashrc" ''
|
||||||
# -*- mode: sh -*-
|
|
||||||
|
|
||||||
${cfg.bashrcExtra}
|
${cfg.bashrcExtra}
|
||||||
|
|
||||||
# Commands that should be applied only for interactive shells.
|
# Commands that should be applied only for interactive shells.
|
||||||
|
@ -207,11 +201,7 @@ in
|
||||||
'';
|
'';
|
||||||
|
|
||||||
home.file.".bash_logout" = mkIf (cfg.logoutExtra != "") {
|
home.file.".bash_logout" = mkIf (cfg.logoutExtra != "") {
|
||||||
text = ''
|
source = pkgs.writeShellScript "bash_logout" cfg.logoutExtra;
|
||||||
# -*- mode: sh -*-
|
|
||||||
|
|
||||||
${cfg.logoutExtra}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
# -*- mode: sh -*-
|
|
||||||
|
|
||||||
clear-console
|
|
||||||
|
|
|
@ -16,7 +16,11 @@ with lib;
|
||||||
assertFileExists home-files/.bash_logout
|
assertFileExists home-files/.bash_logout
|
||||||
assertFileContent \
|
assertFileContent \
|
||||||
home-files/.bash_logout \
|
home-files/.bash_logout \
|
||||||
${./logout-expected.txt}
|
${
|
||||||
|
pkgs.writeShellScript "logout-expected" ''
|
||||||
|
clear-console
|
||||||
|
''
|
||||||
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +0,0 @@
|
||||||
# -*- mode: sh -*-
|
|
||||||
|
|
||||||
. "/home/hm-user/.nix-profile/etc/profile.d/hm-session-vars.sh"
|
|
||||||
|
|
||||||
export V1="v1"
|
|
||||||
export V2="v2-v1"
|
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,16 @@ with lib;
|
||||||
assertFileExists home-files/.profile
|
assertFileExists home-files/.profile
|
||||||
assertFileContent \
|
assertFileContent \
|
||||||
home-files/.profile \
|
home-files/.profile \
|
||||||
${./session-variables-expected.txt}
|
${
|
||||||
|
pkgs.writeShellScript "session-variables-expected" ''
|
||||||
|
. "/home/hm-user/.nix-profile/etc/profile.d/hm-session-vars.sh"
|
||||||
|
|
||||||
|
export V1="v1"
|
||||||
|
export V2="v2-v1"
|
||||||
|
|
||||||
|
|
||||||
|
''
|
||||||
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue