NixOS/nixos-build.sh

35 lines
676 B
Bash

#!/usr/bin/env sh
# prompt user the option to abort and not doing anything
printf "Continue copying files and bulding config (y/n)? "
read -r choice
case "$choice" in
y|Y )
echo "copying files..."
cp -rv nixos /etc
;;
n|N )
echo "aborting..."
exit 0
;;
* )
echo "invalid"
exit 1
;;
esac
case "$1" in
"switch" | "boot" | "dry-run")
echo "building config..."
nixos-rebuild "$1"
;;
"upgrade")
echo "upgrading nixos..."
nixos-rebuild --upgrade switch
;;
* )
echo "no option specified, not building config..."
;;
esac
echo "done"