feat(packages/rebuild): make test shell not open by default=
This commit is contained in:
parent
052bd8bbae
commit
1c355a30f5
1 changed files with 30 additions and 8 deletions
|
@ -1,6 +1,22 @@
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
pkgs.writeShellScriptBin "rebuild" # sh
|
pkgs.writeShellScriptBin "rebuild" # sh
|
||||||
''
|
''
|
||||||
|
TEST_SHELL=false
|
||||||
|
REMOTE_HOSTS=()
|
||||||
|
|
||||||
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case "$1" in
|
||||||
|
--test-shell | -t)
|
||||||
|
TEST_SHELL=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
REMOTE_HOSTS+="$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
if [ ! -f "flake.nix" ]; then
|
if [ ! -f "flake.nix" ]; then
|
||||||
echo "Error: flake.nix not found in the current directory. Exiting."
|
echo "Error: flake.nix not found in the current directory. Exiting."
|
||||||
exit 1 # Indicate an error
|
exit 1 # Indicate an error
|
||||||
|
@ -8,9 +24,13 @@ pkgs.writeShellScriptBin "rebuild" # sh
|
||||||
|
|
||||||
git add .
|
git add .
|
||||||
|
|
||||||
if [ $# -gt 0 ]; then
|
if [ ''${#REMOTE_HOSTS[@]} -gt 0 ]; then
|
||||||
for arg in "$@"; do
|
for host in "$REMOTE_HOSTS[@]"; do
|
||||||
nixos-rebuild switch --flake .#"$arg" --target-host "$arg" --use-remote-sudo
|
echo "Rebuilding $host..."
|
||||||
|
nixos-rebuild switch --flake .#"$host" --target-host "$host" --use-remote-sudo || {
|
||||||
|
echo "Error: nixos-rebuild switch failed for $host. Check the output."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
done
|
done
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
@ -24,11 +44,13 @@ pkgs.writeShellScriptBin "rebuild" # sh
|
||||||
|
|
||||||
git diff HEAD --color=always --stat --patch
|
git diff HEAD --color=always --stat --patch
|
||||||
|
|
||||||
(export PS1="Test shell> "
|
if "$TEST_SHELL"; then
|
||||||
exec ${pkgs.bash}/bin/bash) || {
|
(export PS1="Test shell> "
|
||||||
${pkgs.cowsay}/bin/cowsay "You aborted."
|
exec ${pkgs.bash}/bin/bash) || {
|
||||||
exit 1
|
${pkgs.cowsay}/bin/cowsay "You aborted."
|
||||||
}
|
exit 1
|
||||||
|
}
|
||||||
|
fi
|
||||||
|
|
||||||
export NIXOS_LABEL="$(date +%d%m%y\ %H:%M:%S)"
|
export NIXOS_LABEL="$(date +%d%m%y\ %H:%M:%S)"
|
||||||
nh os boot . || {
|
nh os boot . || {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue