diff options
Diffstat (limited to '')
-rwxr-xr-x | pkgs/by-name/fu/fupdate-flake/fupdate-flake.sh | 10 | ||||
-rw-r--r-- | pkgs/by-name/fu/fupdate-flake/package.nix | 9 | ||||
-rwxr-xr-x | pkgs/by-name/fu/fupdate-sys/fupdate-sys.sh | 19 | ||||
-rw-r--r-- | pkgs/by-name/fu/fupdate/Cargo.lock | 16 | ||||
-rw-r--r-- | pkgs/by-name/fu/fupdate/Cargo.toml | 4 | ||||
-rw-r--r-- | pkgs/by-name/fu/fupdate/flake.lock | 6 | ||||
-rw-r--r-- | pkgs/by-name/fu/fupdate/src/main.rs | 20 |
7 files changed, 47 insertions, 37 deletions
diff --git a/pkgs/by-name/fu/fupdate-flake/fupdate-flake.sh b/pkgs/by-name/fu/fupdate-flake/fupdate-flake.sh index 6d343995..f63d7de0 100755 --- a/pkgs/by-name/fu/fupdate-flake/fupdate-flake.sh +++ b/pkgs/by-name/fu/fupdate-flake/fupdate-flake.sh @@ -6,7 +6,9 @@ info() { echo "Info: $1" } dbg() { - [ -n "$DEBUG_ENABLE" ] && echo "Debug: $1" + if [ "${DEBUG_ENABLE-unset}" != "unset" ]; then + echo "Debug: $1" >&2 + fi } die() { echo "Error: $1" @@ -37,7 +39,7 @@ upfind() { while search_result=$(fd "$search_string" "$current_directory/" --max-depth 1) - dbg "Debugging upfind - search in $current_directory gives: $search_result" + dbg "upfind - search in $current_directory gives: $search_result" [ -z "$search_result" ] && [ "$current_directory" != "/" ] do current_directory=$(dirname "$current_directory"); done @@ -58,7 +60,7 @@ upfind() { get_storage_path() { update_script="$(realpath "$1")" - storage_path="$XDG_DATE_HOME/fupdate-flake/$update_script" + storage_path="$XDG_DATA_HOME/fupdate-flake/$update_script" echo "$storage_path" } @@ -177,4 +179,6 @@ main() { fi } +main + # vim: ft=sh diff --git a/pkgs/by-name/fu/fupdate-flake/package.nix b/pkgs/by-name/fu/fupdate-flake/package.nix index d2784169..5b2d7d29 100644 --- a/pkgs/by-name/fu/fupdate-flake/package.nix +++ b/pkgs/by-name/fu/fupdate-flake/package.nix @@ -7,19 +7,22 @@ bat-extras, # For `batgrep` bat, # used by batgrep gnused, # required by batgrep + git, }: writeShellApplication { name = "fupdate-flake"; - tetx = builtins.readFile ./fupdate-flake.sh; + text = builtins.readFile ./fupdate-flake.sh; - inheritPath = false; + # The `update.sh` script might actually want to keep the path. + inheritPath = true; runtimeInputs = [ coreutils fd gnugrep - bat-extras # For `batgrep` + bat-extras.batgrep bat # Used by `batgrep` gnused # Required by `batgrep` + git ]; } diff --git a/pkgs/by-name/fu/fupdate-sys/fupdate-sys.sh b/pkgs/by-name/fu/fupdate-sys/fupdate-sys.sh index 38debf44..28e09f3d 100755 --- a/pkgs/by-name/fu/fupdate-sys/fupdate-sys.sh +++ b/pkgs/by-name/fu/fupdate-sys/fupdate-sys.sh @@ -13,10 +13,12 @@ die() { fi } print() { - printf "%s" "$*" + # shellcheck disable=SC2059 + printf "$*" } println() { - printf "%s\n" "$*" + # shellcheck disable=SC2059 + printf "$*\n" } eprint() { >&2 print "$@" @@ -24,7 +26,7 @@ eprint() { eprintln() { >&2 println "$@" } -if [ -n "$NO_COLOR" ]; then +if [ "${NO_COLOR-unset}" != "unset" ]; then error() { eprintln "==> ERROR:" "$*" } @@ -71,7 +73,6 @@ else fi # }}} - NAME="update-sys" help() { cat <<EOF @@ -106,7 +107,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 +116,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 +150,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/Cargo.lock b/pkgs/by-name/fu/fupdate/Cargo.lock index 4b160d08..0e90eb40 100644 --- a/pkgs/by-name/fu/fupdate/Cargo.lock +++ b/pkgs/by-name/fu/fupdate/Cargo.lock @@ -54,15 +54,15 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f" +checksum = "e16d2d3311acee920a9eb8d33b8cbc1787ce4a264e85f964c2404b969bdcd487" [[package]] name = "clap" -version = "4.5.35" +version = "4.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8aa86934b44c19c50f87cc2790e19f54f7a67aedb64101c2e1a2e5ecfb73944" +checksum = "eccb054f56cbd38340b380d4a8e69ef1f02f1af43db2f0cc817a4774d80ae071" dependencies = [ "clap_builder", "clap_derive", @@ -70,9 +70,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.35" +version = "4.5.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2414dbb2dd0695280da6ea9261e327479e9d37b0630f6b53ba2a11c60c679fd9" +checksum = "efd9466fac8543255d3b1fcad4762c5e116ffe808c8a3043d4263cd4fd4862a2" dependencies = [ "anstream", "anstyle", @@ -154,9 +154,9 @@ checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" [[package]] name = "proc-macro2" -version = "1.0.94" +version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" dependencies = [ "unicode-ident", ] diff --git a/pkgs/by-name/fu/fupdate/Cargo.toml b/pkgs/by-name/fu/fupdate/Cargo.toml index c86afe2b..c172df8d 100644 --- a/pkgs/by-name/fu/fupdate/Cargo.toml +++ b/pkgs/by-name/fu/fupdate/Cargo.toml @@ -6,8 +6,8 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -anyhow = "1.0.97" -clap = { version = "4.5.35", features = ["derive"] } +anyhow = "1.0.98" +clap = { version = "4.5.37", features = ["derive"] } clap_complete = { version = "4.5.47", features = ["unstable-dynamic"] } [profile.release] diff --git a/pkgs/by-name/fu/fupdate/flake.lock b/pkgs/by-name/fu/fupdate/flake.lock index eb3616c8..07eb6b21 100644 --- a/pkgs/by-name/fu/fupdate/flake.lock +++ b/pkgs/by-name/fu/fupdate/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1744096231, - "narHash": "sha256-kUfx3FKU1Etnua3EaKvpeuXs7zoFiAcli1gBwkPvGSs=", + "lastModified": 1745377448, + "narHash": "sha256-jhZDfXVKdD7TSEGgzFJQvEEZ2K65UMiqW5YJ2aIqxMA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b2b0718004cc9a5bca610326de0a82e6ea75920b", + "rev": "507b63021ada5fee621b6ca371c4fca9ca46f52c", "type": "github" }, "original": { diff --git a/pkgs/by-name/fu/fupdate/src/main.rs b/pkgs/by-name/fu/fupdate/src/main.rs index 850eaf87..759f65ec 100644 --- a/pkgs/by-name/fu/fupdate/src/main.rs +++ b/pkgs/by-name/fu/fupdate/src/main.rs @@ -12,7 +12,7 @@ fn main() -> Result<(), anyhow::Error> { let args = CliArgs::parse(); - let other = args.command.first().map_or("flake", String::as_str); + let command = args.command.first().map_or("flake", String::as_str); { let args = if args.command.len() > 1 { @@ -21,13 +21,19 @@ fn main() -> Result<(), anyhow::Error> { &[] }; - let status = Command::new(format!("fupdate-{other}")) - .args(args) - .status() - .with_context(|| format!("Failed to execute `fupdate-{other}`"))?; + // println!("Running: `fupdate-{command} {}`", args.join(" ")); - if !status.success() { - bail!("Command `fupdate-{other}` failed!"); + let mut child = Command::new(format!("fupdate-{command}")) + .args(args) + .spawn() + .with_context(|| format!("Failed to spawn `fupdate-{command}`"))?; + + if !child + .wait() + .with_context(|| format!("Failed to wait for `fupdate-{command}` to finish"))? + .success() + { + bail!("Command `fupdate-{command} {}` failed!", args.join(" ")); } } |