NixOS/nixos-build.sh

43 lines
912 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 dev /etc/nixos
cp -rv core /etc/nixos
cp -rv extra /etc/nixos
cp -rv users /etc/nixos
cp -rv *.nix /etc/nixos/
cp -rv games /etc/nixos/
cp -rv hardware /etc/nixos/
cp -rv system /etc/nixos/
;;
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"