diff options
Diffstat (limited to '')
-rwxr-xr-x | pkgs/by-name/fu/fupdate-sys/fupdate-sys.sh | 29 | ||||
-rw-r--r-- | pkgs/by-name/fu/fupdate-sys/package.nix | 9 |
2 files changed, 27 insertions, 11 deletions
diff --git a/pkgs/by-name/fu/fupdate-sys/fupdate-sys.sh b/pkgs/by-name/fu/fupdate-sys/fupdate-sys.sh index 38debf44..4ec3e9e8 100755 --- a/pkgs/by-name/fu/fupdate-sys/fupdate-sys.sh +++ b/pkgs/by-name/fu/fupdate-sys/fupdate-sys.sh @@ -1,5 +1,15 @@ #!/usr/bin/env dash +# nixos-config - My current NixOS configuration +# +# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de> +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This file is part of my nixos-config. +# +# You should have received a copy of the License along with this program. +# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. + # FIXME(@bpeetz): Ideally I could replace this script with a deployment tool. Thus we # would have the same tool on the server as I use in my config. <2025-04-14> @@ -13,10 +23,12 @@ die() { fi } print() { - printf "%s" "$*" + # shellcheck disable=SC2059 + printf "$*" } println() { - printf "%s\n" "$*" + # shellcheck disable=SC2059 + printf "$*\n" } eprint() { >&2 print "$@" @@ -24,7 +36,7 @@ eprint() { eprintln() { >&2 println "$@" } -if [ -n "$NO_COLOR" ]; then +if [ "${NO_COLOR-unset}" != "unset" ]; then error() { eprintln "==> ERROR:" "$*" } @@ -71,7 +83,6 @@ else fi # }}} - NAME="update-sys" help() { cat <<EOF @@ -106,7 +117,7 @@ while [ "$#" -gt 0 ]; do help 0 ;; "--branch" | "-b") - if [ -n "$2" ]; then + if [ "${2-unset}" != "unset" ]; then BRANCH="$2" else error "$1 requires an argument" @@ -115,7 +126,7 @@ while [ "$#" -gt 0 ]; do shift 2 ;; "--mode" | "-m") - if [ -n "$2" ]; then + if [ "${2-unset}" != "unset" ]; then MODE="$2" else error "$1 requires an argument" @@ -149,11 +160,7 @@ trap cleanup EXIT git remote show origin | grep 'HEAD' | cut -d':' -f2 | sed -e 's/^ *//g' -e 's/ *$//g' >"$default_branch" & msg2 "Updating system..." -if [ -n "$MODE" ]; then - nixos-rebuild "$MODE" -else - nixos-rebuild switch -fi +nixos-rebuild "${MODE-switch}" git switch "$(cat "$default_branch")" >/dev/null 2>&1 && msg2 "Switched to branch '$(cat "$default_branch")'" msg "Finished Update!" diff --git a/pkgs/by-name/fu/fupdate-sys/package.nix b/pkgs/by-name/fu/fupdate-sys/package.nix index be692d12..7fd4674b 100644 --- a/pkgs/by-name/fu/fupdate-sys/package.nix +++ b/pkgs/by-name/fu/fupdate-sys/package.nix @@ -1,3 +1,12 @@ +# nixos-config - My current NixOS configuration +# +# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de> +# SPDX-License-Identifier: GPL-3.0-or-later +# +# This file is part of my nixos-config. +# +# You should have received a copy of the License along with this program. +# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. { writeShellApplication, # Dependencies |