added show-trace option to rebuild

This commit is contained in:
Leyla Becker 2024-10-03 15:38:03 +02:00
parent ff295dc7ac
commit 89c8c729fa

View file

@ -7,6 +7,8 @@ else
preserve_result=false preserve_result=false
fi fi
show_trace=false
while [ $# -gt 0 ]; do while [ $# -gt 0 ]; do
case "$1" in case "$1" in
--target*|-t*) --target*|-t*)
@ -31,6 +33,9 @@ while [ $# -gt 0 ]; do
--no-preserve-result) --no-preserve-result)
preserve_result=false preserve_result=false
;; ;;
--show-trace)
show_trace=true
;;
--help|-h) --help|-h)
echo "--help -h: print this message" echo "--help -h: print this message"
echo "--target -t: set the target system to rebuild on" echo "--target -t: set the target system to rebuild on"
@ -39,6 +44,7 @@ while [ $# -gt 0 ]; do
echo "--user -u: set the user to rebuild flake as on the target system" echo "--user -u: set the user to rebuild flake as on the target system"
echo "--preserve-result: do not remove the generated result folder after building" echo "--preserve-result: do not remove the generated result folder after building"
echo "--no-preserve-result: remove any result folder after building" echo "--no-preserve-result: remove any result folder after building"
echo "--show-trace: show trace on builds"
exit 0 exit 0
;; ;;
*) *)
@ -54,15 +60,20 @@ flake=${flake:-$target}
mode=${mode:-switch} mode=${mode:-switch}
user=${user:-$USER} user=${user:-$USER}
# path: prefixes on rebuilds here make nix not treat this flake like it has a git repo so we can command="nixos-rebuild $mode --use-remote-sudo --flake .#$flake"
# access secret files in the submodule this is kinda bad and we should find a way to not need it
if [[ "$target" == "$(hostname)" ]]; if [[ "$target" != "$(hostname)" ]];
then then
nixos-rebuild $mode --use-remote-sudo --flake .#$flake command="$command --target-host $user@$target"
else
nixos-rebuild $mode --use-remote-sudo --target-host $user@$target --flake .#$flake
fi fi
if [[ "$show_trace" = true ]];
then
command="$command --show-trace"
fi
$command
if [ -d "result" ]; if [ -d "result" ];
then then
if [[ "$preserve_result" == "false" ]]; if [[ "$preserve_result" == "false" ]];