#!/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