aboutsummaryrefslogtreecommitdiff
path: root/bin/reconfigure
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2023-02-26 17:51:47 -0300
committerEuAndreh <eu@euandre.org>2023-02-26 17:51:47 -0300
commit53a69e0611e858e99ecefc3224c18a09d911d514 (patch)
tree025edf1a5478a5b9976dd787eb2813da37d06a9b /bin/reconfigure
parentbin/upgrade: Fix call to timeout (diff)
downloaddotfiles-53a69e0611e858e99ecefc3224c18a09d911d514.tar.gz
dotfiles-53a69e0611e858e99ecefc3224c18a09d911d514.tar.xz
git mv bin/upgrade bin/reconfigure
Diffstat (limited to 'bin/reconfigure')
-rwxr-xr-xbin/reconfigure82
1 files changed, 82 insertions, 0 deletions
diff --git a/bin/reconfigure b/bin/reconfigure
new file mode 100755
index 0000000..70911ba
--- /dev/null
+++ b/bin/reconfigure
@@ -0,0 +1,82 @@
+#!/bin/sh
+set -eu
+
+usage() {
+ cat <<-'EOF'
+ Usage:
+ reconfigure
+ reconfigure -h
+ EOF
+}
+
+help() {
+ cat <<-'EOF'
+
+ Options:
+ -h, --help show this message
+
+
+ Switches the system:
+ - reconfigure the Guix "home" environment;
+ - Guix "system" if it exists;
+ - NixOS if it exists.
+
+
+ Examples:
+
+ Just use it:
+
+ $ reconfigure
+ EOF
+}
+
+
+for flag in "$@"; do
+ case "$flag" in
+ --)
+ break
+ ;;
+ --help)
+ usage
+ help
+ exit
+ ;;
+ *)
+ ;;
+ esac
+done
+
+while getopts 'h' flag; do
+ case "$flag" in
+ h)
+ usage
+ help
+ exit
+ ;;
+ *)
+ usage >&2
+ exit 2
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+
+HOSTNAME="$(hostname)"
+
+if [ -e /run/current-system/configuration.scm ]; then
+ pass show "$(hostname)"/andreh |
+ head -n1 |
+ sudo -ES guix system -v3 reconfigure /run/current-system/configuration.scm
+fi
+
+TWO_HOURS='7200'
+
+timeout "$TWO_HOURS" \
+ guix home -v3 reconfigure ~/.guix-home/configuration.scm
+
+if [ -e /etc/nixos/configuration.nix ]; then
+ pass show "$HOSTNAME"/andreh |
+ head -n1 |
+ sudo -S nixos-rebuild switch --upgrade
+fi