diff options
author | EuAndreh <eu@euandre.org> | 2023-02-26 17:51:47 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2023-02-26 17:51:47 -0300 |
commit | 53a69e0611e858e99ecefc3224c18a09d911d514 (patch) | |
tree | 025edf1a5478a5b9976dd787eb2813da37d06a9b /bin/reconfigure | |
parent | bin/upgrade: Fix call to timeout (diff) | |
download | dotfiles-53a69e0611e858e99ecefc3224c18a09d911d514.tar.gz dotfiles-53a69e0611e858e99ecefc3224c18a09d911d514.tar.xz |
git mv bin/upgrade bin/reconfigure
Diffstat (limited to 'bin/reconfigure')
-rwxr-xr-x | bin/reconfigure | 82 |
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 |