summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pkgs/by-name/fu/fupdate-sys2/.envrc14
-rw-r--r--pkgs/by-name/fu/fupdate-sys2/.gitignore12
-rw-r--r--pkgs/by-name/fu/fupdate-sys2/Cargo.lock381
-rw-r--r--pkgs/by-name/fu/fupdate-sys2/Cargo.toml83
-rw-r--r--pkgs/by-name/fu/fupdate-sys2/package.unstable.nix56
l---------pkgs/by-name/fu/fupdate-sys2/result1
-rw-r--r--pkgs/by-name/fu/fupdate-sys2/src/cli.rs84
-rw-r--r--pkgs/by-name/fu/fupdate-sys2/src/main.rs193
-rwxr-xr-xpkgs/by-name/fu/fupdate-sys2/update.sh14
9 files changed, 838 insertions, 0 deletions
diff --git a/pkgs/by-name/fu/fupdate-sys2/.envrc b/pkgs/by-name/fu/fupdate-sys2/.envrc
new file mode 100644
index 00000000..a3d4f9bf
--- /dev/null
+++ b/pkgs/by-name/fu/fupdate-sys2/.envrc
@@ -0,0 +1,14 @@
+#!/usr/bin/env sh
+
+# 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>.
+
+
+pre_cache_load rust
diff --git a/pkgs/by-name/fu/fupdate-sys2/.gitignore b/pkgs/by-name/fu/fupdate-sys2/.gitignore
new file mode 100644
index 00000000..f255eebd
--- /dev/null
+++ b/pkgs/by-name/fu/fupdate-sys2/.gitignore
@@ -0,0 +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>.
+
+/target
+.direnv
diff --git a/pkgs/by-name/fu/fupdate-sys2/Cargo.lock b/pkgs/by-name/fu/fupdate-sys2/Cargo.lock
new file mode 100644
index 00000000..85a1abd5
--- /dev/null
+++ b/pkgs/by-name/fu/fupdate-sys2/Cargo.lock
@@ -0,0 +1,381 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+# 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>.
+version = 4
+
+[[package]]
+name = "anstream"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d"
+dependencies = [
+ "anstyle",
+ "anstyle-parse",
+ "anstyle-query",
+ "anstyle-wincon",
+ "colorchoice",
+ "is_terminal_polyfill",
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle"
+version = "1.0.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"
+
+[[package]]
+name = "anstyle-parse"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e"
+dependencies = [
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle-query"
+version = "1.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
+dependencies = [
+ "windows-sys",
+]
+
+[[package]]
+name = "anstyle-wincon"
+version = "3.0.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
+dependencies = [
+ "anstyle",
+ "once_cell_polyfill",
+ "windows-sys",
+]
+
+[[package]]
+name = "anyhow"
+version = "1.0.105"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2cb931c189b85683d69a5cfad41d4d418671e1ac413dd209f3f2fc31e3cfd902"
+
+[[package]]
+name = "bitflags"
+version = "2.13.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
+
+[[package]]
+name = "cfg-if"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"
+
+[[package]]
+name = "clap"
+version = "4.6.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "50066ca966813ca8957ee15361752f19424a8ff620dbe9c8993d9f99d99b04b3"
+dependencies = [
+ "clap_builder",
+ "clap_derive",
+]
+
+[[package]]
+name = "clap_builder"
+version = "4.6.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a0ed97c96ef4efb3cc84e09fa388df4463e7cc3224ec38d7b1d9e45749333590"
+dependencies = [
+ "anstream",
+ "anstyle",
+ "clap_lex",
+ "strsim",
+]
+
+[[package]]
+name = "clap_complete"
+version = "4.6.12"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6a35200383f20018d41c14d1ab19c1727c697f544492143f7d93aa39f0187848"
+dependencies = [
+ "clap",
+ "clap_lex",
+ "is_executable",
+ "shlex",
+]
+
+[[package]]
+name = "clap_derive"
+version = "4.6.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b4c174f11f949b9ca8c60580925e282b9cbd5454750e506f08648b2038080cd7"
+dependencies = [
+ "heck",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "clap_lex"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e0921b3876b3a1df8a1c9f912e7f94342458022c2e84288015893d83c4d62a79"
+
+[[package]]
+name = "colorchoice"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
+
+[[package]]
+name = "errno"
+version = "0.3.15"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776"
+dependencies = [
+ "libc",
+ "windows-sys",
+]
+
+[[package]]
+name = "fastrand"
+version = "2.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
+
+[[package]]
+name = "fupdate-sys"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "clap",
+ "clap_complete",
+ "serde_json",
+ "tempfile",
+]
+
+[[package]]
+name = "getrandom"
+version = "0.4.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
+dependencies = [
+ "cfg-if",
+ "libc",
+ "r-efi",
+]
+
+[[package]]
+name = "heck"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
+
+[[package]]
+name = "is_executable"
+version = "1.0.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "82cb6a9f675da968c63b6208c641b9dca58fc0133ae53375736b1767b0cab8bd"
+dependencies = [
+ "windows-sys",
+]
+
+[[package]]
+name = "is_terminal_polyfill"
+version = "1.70.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
+
+[[package]]
+name = "itoa"
+version = "1.0.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
+
+[[package]]
+name = "libc"
+version = "0.2.191"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
+
+[[package]]
+name = "linux-raw-sys"
+version = "0.12.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"
+
+[[package]]
+name = "memchr"
+version = "2.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
+
+[[package]]
+name = "once_cell"
+version = "1.21.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
+
+[[package]]
+name = "once_cell_polyfill"
+version = "1.70.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.107"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.47"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "r-efi"
+version = "6.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
+
+[[package]]
+name = "rustix"
+version = "1.1.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e5e76742e5294153d4dde1207dbec5bdd81eef6fabdc0d2118babadabfd858aa"
+dependencies = [
+ "bitflags",
+ "errno",
+ "libc",
+ "linux-raw-sys",
+ "windows-sys",
+]
+
+[[package]]
+name = "serde"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
+dependencies = [
+ "serde_core",
+]
+
+[[package]]
+name = "serde_core"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.154"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
+dependencies = [
+ "itoa",
+ "memchr",
+ "serde",
+ "serde_core",
+ "zmij",
+]
+
+[[package]]
+name = "shlex"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
+
+[[package]]
+name = "strsim"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
+
+[[package]]
+name = "syn"
+version = "3.0.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "tempfile"
+version = "3.27.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
+dependencies = [
+ "fastrand",
+ "getrandom",
+ "once_cell",
+ "rustix",
+ "windows-sys",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
+
+[[package]]
+name = "utf8parse"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
+
+[[package]]
+name = "windows-link"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
+
+[[package]]
+name = "windows-sys"
+version = "0.61.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
+name = "zmij"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
diff --git a/pkgs/by-name/fu/fupdate-sys2/Cargo.toml b/pkgs/by-name/fu/fupdate-sys2/Cargo.toml
new file mode 100644
index 00000000..5577fdae
--- /dev/null
+++ b/pkgs/by-name/fu/fupdate-sys2/Cargo.toml
@@ -0,0 +1,83 @@
+# 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>.
+
+[package]
+name = "fupdate-sys"
+version = "0.1.0"
+edition = "2024"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
+anyhow = "1.0.105"
+clap = { version = "4.6.10", features = ["derive"] }
+clap_complete = { version = "4.6.12", features = ["unstable-dynamic"] }
+serde_json = "1.0.154"
+tempfile = "3.27.0"
+
+[profile.release]
+lto = true
+codegen-units = 1
+panic = "abort"
+split-debuginfo = "off"
+
+[lints.rust]
+# rustc lint groups https://doc.rust-lang.org/rustc/lints/groups.html
+warnings = "warn"
+future_incompatible = { level = "warn", priority = -1 }
+let_underscore = { level = "warn", priority = -1 }
+nonstandard_style = { level = "warn", priority = -1 }
+rust_2018_compatibility = { level = "warn", priority = -1 }
+rust_2018_idioms = { level = "warn", priority = -1 }
+rust_2021_compatibility = { level = "warn", priority = -1 }
+unused = { level = "warn", priority = -1 }
+# rustc allowed-by-default lints https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html
+# missing_docs = "warn"
+macro_use_extern_crate = "warn"
+meta_variable_misuse = "warn"
+missing_abi = "warn"
+missing_copy_implementations = "warn"
+missing_debug_implementations = "warn"
+non_ascii_idents = "warn"
+noop_method_call = "warn"
+single_use_lifetimes = "warn"
+trivial_casts = "warn"
+trivial_numeric_casts = "warn"
+unreachable_pub = "warn"
+unsafe_op_in_unsafe_fn = "warn"
+unused_crate_dependencies = "warn"
+unused_import_braces = "warn"
+unused_lifetimes = "warn"
+unused_qualifications = "warn"
+variant_size_differences = "warn"
+
+[lints.rustdoc]
+# rustdoc lints https://doc.rust-lang.org/rustdoc/lints.html
+broken_intra_doc_links = "warn"
+private_intra_doc_links = "warn"
+missing_crate_level_docs = "warn"
+private_doc_tests = "warn"
+invalid_codeblock_attributes = "warn"
+invalid_rust_codeblocks = "warn"
+bare_urls = "warn"
+
+[lints.clippy]
+# clippy allowed by default
+dbg_macro = "warn"
+# clippy categories https://doc.rust-lang.org/clippy/
+all = { level = "warn", priority = -1 }
+correctness = { level = "warn", priority = -1 }
+suspicious = { level = "warn", priority = -1 }
+style = { level = "warn", priority = -1 }
+complexity = { level = "warn", priority = -1 }
+perf = { level = "warn", priority = -1 }
+pedantic = { level = "warn", priority = -1 }
+missing_panics_doc = "allow"
+missing_errors_doc = "allow"
diff --git a/pkgs/by-name/fu/fupdate-sys2/package.unstable.nix b/pkgs/by-name/fu/fupdate-sys2/package.unstable.nix
new file mode 100644
index 00000000..aa478d56
--- /dev/null
+++ b/pkgs/by-name/fu/fupdate-sys2/package.unstable.nix
@@ -0,0 +1,56 @@
+# 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>.
+{
+ rustPlatform,
+ installShellFiles,
+ makeWrapper,
+ lib,
+ # Dependencies
+ git,
+ nixos-rebuild-ng,
+ efivar,
+}: let
+ binPath = [
+ git
+ nixos-rebuild-ng
+ efivar
+ ];
+in
+ rustPlatform.buildRustPackage (finalAttrs: {
+ pname = "fupdate-sys";
+ version = "0.1.0";
+
+ src = ./.;
+ cargoLock = {
+ lockFile = ./Cargo.lock;
+ };
+
+ buildInputs = [];
+
+ nativeBuildInputs = [
+ installShellFiles
+ makeWrapper
+ ];
+
+ postInstall = ''
+ installShellCompletion --cmd fupdate-sys \
+ --bash <(COMPLETE=bash $out/bin/fupdate-sys) \
+ --fish <(COMPLETE=fish $out/bin/fupdate-sys) \
+ --zsh <(COMPLETE=zsh $out/bin/fupdate-sys)
+
+ # We want to discover the `bootctl` from the environment
+ wrapProgram $out/bin/fupdate-sys \
+ --prefix PATH : ${lib.makeBinPath binPath} \
+ '';
+
+ meta = {
+ mainProgram = "fupdate-sys";
+ };
+ })
diff --git a/pkgs/by-name/fu/fupdate-sys2/result b/pkgs/by-name/fu/fupdate-sys2/result
new file mode 120000
index 00000000..085c4a4c
--- /dev/null
+++ b/pkgs/by-name/fu/fupdate-sys2/result
@@ -0,0 +1 @@
+/nix/store/bybpj9jk4ml8grv8sgvm9xkd4zm87q44-fupdate-sys-0.1.0 \ No newline at end of file
diff --git a/pkgs/by-name/fu/fupdate-sys2/src/cli.rs b/pkgs/by-name/fu/fupdate-sys2/src/cli.rs
new file mode 100644
index 00000000..cf8a796e
--- /dev/null
+++ b/pkgs/by-name/fu/fupdate-sys2/src/cli.rs
@@ -0,0 +1,84 @@
+// 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>.
+
+use core::fmt;
+use std::{ffi::OsStr, process::Command};
+
+use clap::{Parser, ValueEnum};
+use clap_complete::{CompletionCandidate, engine::ArgValueCompleter};
+
+/// This is a Nix flake update manager.
+#[derive(Parser, Debug)]
+#[command(author, version, about)]
+pub struct CliArgs {
+ /// The branch to update from.
+ #[arg(short, long, add = ArgValueCompleter::new(get_branches))]
+ pub branch: Option<String>,
+
+ /// The mode to update with.
+ #[arg(short, long, default_value_t = Mode::Switch)]
+ pub mode: Mode,
+
+ /// Don't actually make changes.
+ #[arg(short, long)]
+ pub dry_run: bool,
+}
+
+#[derive(Debug, Clone, Copy, ValueEnum)]
+pub enum Mode {
+ Switch,
+ Boot,
+ Test,
+ Build,
+ DryBuild,
+ DryActivate,
+ Edit,
+ Repl,
+ BuildVm,
+ BuildVmWithBootloader,
+}
+
+impl fmt::Display for Mode {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(f, "{}", format!("{self:?}").to_lowercase())
+ }
+}
+
+fn get_branches(current: &OsStr) -> Vec<CompletionCandidate> {
+ let mut output = vec![];
+
+ let Some(current) = current.to_str() else {
+ return output;
+ };
+
+ let Ok(git_output) = Command::new("git")
+ .args(["branch", "--list", "--format", "'%(refname:short)'"])
+ .current_dir("/etc/nixos")
+ .output()
+ else {
+ return output;
+ };
+
+ if !git_output.status.success() {
+ return output;
+ }
+
+ let Ok(possible) = String::from_utf8(git_output.stdout) else {
+ return output;
+ };
+
+ for possible in possible.trim().split('\n') {
+ if possible.starts_with(current) {
+ output.push(CompletionCandidate::new(possible));
+ }
+ }
+
+ output
+}
diff --git a/pkgs/by-name/fu/fupdate-sys2/src/main.rs b/pkgs/by-name/fu/fupdate-sys2/src/main.rs
new file mode 100644
index 00000000..d2dd19f3
--- /dev/null
+++ b/pkgs/by-name/fu/fupdate-sys2/src/main.rs
@@ -0,0 +1,193 @@
+// 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>.
+
+use std::{
+ ops::Deref,
+ process::{Command, Stdio},
+ thread,
+};
+
+use anyhow::{Result, bail};
+use clap::{CommandFactory, Parser};
+use serde_json::Value;
+use tempfile::NamedTempFile;
+
+pub mod cli;
+
+use crate::cli::CliArgs;
+
+macro_rules! cmd {
+ ($dry_run:expr, $name:literal, $($arg:expr),*) => {{
+ eprintln!("# \x1b[1;96m{}\x1b[0m {}", $name, [$($arg),*].join(" "));
+
+ if $dry_run {
+ String::new()
+ } else {
+ let output = Command::new($name)
+ .args([
+ $($arg),*
+ ])
+ .stdout(Stdio::piped())
+ .stderr(Stdio::inherit())
+ .current_dir("/etc/nixos")
+ .output()?;
+
+ if !output.status.success() {
+ bail!("`\x1b[1;96m{}\x1b[0m {}` failed.", $name, [$($arg),*].join(" "));
+ }
+
+ String::from_utf8(output.stdout)?
+ }
+ }};
+}
+
+fn msg(message: &'static str) {
+ eprintln!("\x1b[1;96m==>\x1b[0m\x1b[1;93m {message}\x1b[0m");
+}
+fn msg2(message: impl Deref<Target = str>) {
+ eprintln!("\x1b[1;96m ->\x1b[0m\x1b[1;93m {}\x1b[0m", &*message);
+}
+
+fn main() -> Result<(), anyhow::Error> {
+ clap_complete::CompleteEnv::with_factory(CliArgs::command).complete();
+
+ let args = CliArgs::parse();
+
+ msg("Starting system update...");
+ cmd!(args.dry_run, "git", "remote", "update", "origin", "--prune");
+
+ if let Some(branch) = args.branch {
+ cmd!(args.dry_run, "git", "switch", &branch);
+ msg2(format!("Switched to branch '{branch}'"));
+ }
+
+ msg2("Updating git repository...");
+ cmd!(args.dry_run, "git", "pull", "--rebase");
+
+ let handle = thread::spawn(get_remote_default_branch);
+
+ msg2("Updating system...");
+ cmd!(
+ args.dry_run,
+ "nixos-rebuild",
+ args.mode.to_string().as_str()
+ );
+
+ let remote_default_branch = handle.join().unwrap()?;
+ cmd!(args.dry_run, "git", "switch", &remote_default_branch);
+ msg2(format!("Switched to branch '{remote_default_branch}'"));
+
+ msg("Setting oneshot boot entry to new generation..");
+
+ let new_generation = {
+ let base = cmd!(false, "bootctl", "list", "--json=short");
+
+ let json: Value = serde_json::from_str(&base)?;
+
+ let mut nixos_generations = vec![];
+ for part in json.as_array().unwrap() {
+ if part.get("sortKey").map(Value::as_str) == Some(Some("lanza")) {
+ nixos_generations.push(part.get("id").unwrap().as_str().unwrap().to_owned());
+ }
+ }
+
+ nixos_generations.first().unwrap().to_owned()
+ };
+
+ let last_used_variable_name = {
+ let mut name = None;
+ let all = cmd!(false, "efivar", "--list");
+
+ for line in all.trim().lines() {
+ if line.contains("LoaderEntryLastBooted") {
+ name = Some(line.to_owned());
+ }
+ }
+
+ name.unwrap()
+ };
+ let data_file = {
+ use std::io::Write;
+
+ let mut named = NamedTempFile::new()?;
+
+ let mut data = Vec::with_capacity(new_generation.len() * 2);
+ for ch in new_generation.chars() {
+ data.push(ch as u8);
+ data.push(b'\0');
+ }
+
+ data.push(b'\0');
+ data.push(b'\0');
+
+ named.write_all(data.as_slice())?;
+
+ let str = cmd!(
+ false,
+ "hexdump",
+ "-C",
+ named.path().as_os_str().to_str().unwrap()
+ );
+ eprintln!("{str}");
+
+ named
+ };
+ cmd!(
+ args.dry_run,
+ "efivar",
+ "--name",
+ &last_used_variable_name,
+ "--write",
+ "--datafile",
+ data_file.path().as_os_str().to_str().unwrap()
+ );
+
+ data_file.close()?;
+
+ msg("Finished Update!");
+
+ Ok(())
+}
+
+fn get_remote_default_branch() -> Result<String> {
+ let mut final_output = None;
+
+ let output = cmd!(false, "git", "remote", "show", "origin");
+ for line in output.trim().lines() {
+ if line.contains("HEAD") {
+ let base = line.split(':').skip(1).take(1).last().unwrap();
+ let base = base.replacen(" *", "", 1);
+ let base = base
+ .chars()
+ .rev()
+ .collect::<String>()
+ .replacen(" *", "", 1)
+ .chars()
+ .rev()
+ .collect::<String>()
+ .trim()
+ .to_owned();
+
+ final_output = Some(base);
+ }
+ }
+
+ Ok(final_output.unwrap())
+}
+
+#[cfg(test)]
+mod test {
+ use clap::CommandFactory;
+
+ #[test]
+ fn verify_cli() {
+ super::CliArgs::command().debug_assert();
+ }
+}
diff --git a/pkgs/by-name/fu/fupdate-sys2/update.sh b/pkgs/by-name/fu/fupdate-sys2/update.sh
new file mode 100755
index 00000000..5ad524e8
--- /dev/null
+++ b/pkgs/by-name/fu/fupdate-sys2/update.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# 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>.
+
+[ "$1" = "upgrade" ] && cargo upgrade --incompatible allow --pinned allow --recursive true
+cargo update --recursive