feat(packages/rebuild): improve rebuild script
This commit is contained in:
parent
aa8420c261
commit
0a071aed3d
2 changed files with 28 additions and 7 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
result
|
||||||
|
*.qcow2
|
|
@ -2,13 +2,32 @@
|
||||||
pkgs.writeShellScriptBin "rebuild" # sh
|
pkgs.writeShellScriptBin "rebuild" # sh
|
||||||
''
|
''
|
||||||
if [ ! -f "flake.nix" ]; then
|
if [ ! -f "flake.nix" ]; then
|
||||||
echo "flake.nix not found in current directory. exiting..."
|
echo "Error: flake.nix not found in the current directory. Exiting."
|
||||||
exit 1
|
exit 1 # Indicate an error
|
||||||
fi
|
fi
|
||||||
|
|
||||||
git add . && \
|
echo "--- building the new config... ---"
|
||||||
nixos-rebuild switch --flake . --use-remote-sudo && \
|
git add .
|
||||||
${pkgs.cowsay}/bin/cowsay -f elephant "Opening a test shell. Type exit 1 to abort and exit to commit your changes." && \
|
nixos-rebuild test --flake . --use-remote-sudo || {
|
||||||
$SHELL && \
|
echo "Error: nixos-rebuild switch failed. Check the output for details."
|
||||||
git commit -a
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "--- diffing... ---"
|
||||||
|
git diff HEAD --color=always --stat --patch
|
||||||
|
|
||||||
|
echo "--- opening test shell... ---"
|
||||||
|
${pkgs.cowsay}/bin/cowsay -f elephant "Entering a test shell. Type 'exit 1' to abort changes and 'exit' to commit."
|
||||||
|
PS1="Test shell> " $SHELL || {
|
||||||
|
${pkgs.cowsay}/bin/cowsay -f satanic "You aborted."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "--- adding the built configuration to the bootloader... ---"
|
||||||
|
nixos-rebuild switch --flake . --use-remote-sudo || {
|
||||||
|
echo "Error: nixos-rebuild switch failed. Check the output for details."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
git commit
|
||||||
|
exit 0
|
||||||
''
|
''
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue