diff --git a/Cargo.lock b/Cargo.lock index 3ca4d70..8e3fa5d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -143,7 +143,7 @@ dependencies = [ ] [[package]] -name = "boot-tree" +name = "bootvine" version = "0.1.0" dependencies = [ "clap", diff --git a/Cargo.toml b/Cargo.toml index ae45d16..9b4d70d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] edition = "2024" -name = "boot-tree" +name = "bootvine" version = "0.1.0" [lints.clippy] diff --git a/README.md b/README.md index a7e3d31..60522ad 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# boot-tree +# bootvine A live dependency tree of systemd jobs on the boot console, in the spirit of nix-output-monitor. It replaces the scrolling kernel and systemd lines with a @@ -8,7 +8,7 @@ tree of pending units and a timeline bar per row. - Linux with **systemd ≥ 246 as PID 1** (private socket `/run/systemd/private`, `Manager.SetShowStatus`). -- Runs as **root**, from the shipped `boot-tree.service`. +- Runs as **root**, from the shipped `bootvine.service`. - **libdbus-1** at runtime. - A **virtual terminal** (`CONFIG_VT`); the unit draws on `/dev/tty12`. - Optional: a **systemd-based initrd** (NixOS `boot.initrd.systemd`, dracut, or @@ -17,7 +17,7 @@ tree of pending units and a timeline bar per row. - Optional: a large console font on HiDPI screens, e.g. Terminus `ter-v32n` through the distro's console font setting. -No kernel parameters are needed: while it runs, boot-tree lowers the kernel +No kernel parameters are needed: while it runs, bootvine lowers the kernel console log level and turns systemd's status output off, and restores both when it hands the console over. @@ -41,37 +41,37 @@ The package ships everything a system needs under `lib/`: | File | Purpose | | --- | --- | -| `lib/systemd/system/boot-tree.service` | the unit, used in both the initrd and stage 2 | -| `lib/dracut/modules.d/90boot-tree/` | dracut module | -| `lib/initcpio/install/sd-boot-tree` | mkinitcpio hook | +| `lib/systemd/system/bootvine.service` | the unit, used in both the initrd and stage 2 | +| `lib/dracut/modules.d/90bootvine/` | dracut module | +| `lib/initcpio/install/sd-bootvine` | mkinitcpio hook | ### NixOS ```nix -inputs.boot-tree.url = "git+file:/home/wvhulle/Code/boot-tree?ref=refs/heads/main"; +inputs.bootvine.url = "git+https://codeberg.org/wvhulle/bootvine"; # in the host's modules: -boot-tree.nixosModules.default -{ services.boot-tree.enable = true; } +bootvine.nixosModules.default +{ services.bootvine.enable = true; } ``` With `boot.initrd.systemd.enable` the unit is added to the initrd as well. ### Other distributions -1. Install `boot-tree` to `/usr/bin` and the files above under `/usr/lib`. -2. `systemctl enable boot-tree.service`. +1. Install `bootvine` to `/usr/bin` and the files above under `/usr/lib`. +2. `systemctl enable bootvine.service`. 3. To start it in the initrd: - - dracut: `add_dracutmodules+=" boot-tree "` in `/etc/dracut.conf.d/boot-tree.conf`, + - dracut: `add_dracutmodules+=" bootvine "` in `/etc/dracut.conf.d/bootvine.conf`, then `dracut --force`; - - mkinitcpio: add `sd-boot-tree` after `systemd` in `HOOKS`, then + - mkinitcpio: add `sd-bootvine` after `systemd` in `HOOKS`, then `mkinitcpio -P`. To draw on another terminal, override `TTYPath=` with -`systemctl edit boot-tree.service`. +`systemctl edit bootvine.service`. ## Configuration -Colours come from `/etc/boot-tree.toml` (another path with `--config`). Every +Colours come from `/etc/bootvine.toml` (another path with `--config`). Every key is optional; these are the defaults: ```toml @@ -97,13 +97,13 @@ the start of boot: On NixOS set the roles as options; unset ones keep their defaults: ```nix -services.boot-tree.palette = { +services.bootvine.palette = { running = "light-yellow"; done = "light-green"; }; ``` -On dracut and mkinitcpio systems the hooks copy `/etc/boot-tree.toml` into the +On dracut and mkinitcpio systems the hooks copy `/etc/bootvine.toml` into the initramfs, so rebuild it after editing. ## Testing @@ -115,7 +115,7 @@ Commands assume the dev shell is active (`direnv allow` once; `.envrc` runs | --- | --- | | Unit and render snapshot tests | `cargo test` | | Scripted boot animation, no systemd needed | `cargo run --example demo` (`q` quits) | -| Live against your user manager | `nix run .#demo-units -- start`, then `nix run . -- --user --target boot-tree-demo.target --hold 3s` | +| Live against your user manager | `nix run .#demo-units -- start`, then `nix run . -- --user --target bootvine-demo.target --hold 3s` | | Boot a demo VM in a window | `env -u LD_LIBRARY_PATH nix run .#vm` | | Automated boot test with OCR | `nix build .#checks.x86_64-linux.boot` (screenshots in `result/`) | | Same test, interactively | `nix run .#checks.x86_64-linux.boot.driverInteractive`, then `test_script()` | diff --git a/demo/demo-units.nu b/demo/demo-units.nu index 43373a5..f5edec6 100755 --- a/demo/demo-units.nu +++ b/demo/demo-units.nu @@ -19,7 +19,7 @@ def "main start" [--units: path, --target: string] { install-units $units ^systemctl --user stop ...(unit-names $units) ^systemctl --user start --no-block $target - print $"started ($target); watch it with: boot-tree --user --target ($target) --hold 3s" + print $"started ($target); watch it with: bootvine --user --target ($target) --hold 3s" } def "main remove" [--units: path, --target: string] { @@ -29,5 +29,5 @@ def "main remove" [--units: path, --target: string] { } def main [--units: path, --target: string] { - print "usage: boot-tree-demo-units (start | remove)" + print "usage: bootvine-demo-units (start | remove)" } diff --git a/demo/host.nix b/demo/host.nix index b8fb0e6..cb4ceb2 100644 --- a/demo/host.nix +++ b/demo/host.nix @@ -18,13 +18,13 @@ let }; in { - networking.hostName = "boot-tree-demo"; + networking.hostName = "bootvine-demo"; system.stateVersion = "26.05"; boot.initrd.systemd = { enable = true; services.demo-initrd-probe = { - description = "boot-tree demo: slow initrd step"; + description = "bootvine demo: slow initrd step"; wantedBy = [ "initrd.target" ]; before = [ "initrd.target" ]; unitConfig.DefaultDependencies = false; @@ -35,7 +35,7 @@ in }; }; - services.boot-tree = { + services.bootvine = { enable = true; palette.running = "light-yellow"; }; diff --git a/demo/test.nix b/demo/test.nix index c66087a..78ddfde 100644 --- a/demo/test.nix +++ b/demo/test.nix @@ -1,6 +1,6 @@ { demoHost }: { - name = "boot-tree"; + name = "bootvine"; enableOCR = true; nodes.machine = @@ -27,18 +27,18 @@ machine.screenshot("stage-2") machine.wait_for_unit("greetd.service") - machine.wait_until_succeeds("systemctl show -p ActiveState --value boot-tree | grep -qx inactive") + machine.wait_until_succeeds("systemctl show -p ActiveState --value bootvine | grep -qx inactive") - journal = machine.succeed("journalctl -b -u boot-tree -o cat") + journal = machine.succeed("journalctl -b -u bootvine -o cat") print(journal) - watched = [line for line in journal.splitlines() if line.startswith("boot-tree: watching")] + watched = [line for line in journal.splitlines() if line.startswith("bootvine: watching")] assert any(" in initrd " in line for line in watched), "never ran in the initrd" assert any(" in stage 2 " in line for line in watched), "never reconnected after the root switch" pids = {line.split(" as pid ")[1].split()[0] for line in watched} assert len(pids) == 1, f"the initrd process did not survive the root switch: {pids}" assert "handing the console over" in journal, "never handed the console over" - machine.succeed("test \"$(systemctl show -p Result --value boot-tree)\" = success") + machine.succeed("test \"$(systemctl show -p Result --value bootvine)\" = success") console_level = machine.succeed("cut -f1 /proc/sys/kernel/printk").strip() assert console_level != "1", f"kernel console level was not restored: {console_level}" show_status = machine.succeed("systemctl show -p ShowStatus --value").strip() diff --git a/demo/units.nix b/demo/units.nix index bfd7f74..8658d83 100644 --- a/demo/units.nix +++ b/demo/units.nix @@ -1,5 +1,5 @@ { - target = "boot-tree-demo"; + target = "bootvine-demo"; initrdProbeSeconds = "6"; services = { demo-disk.seconds = "2"; diff --git a/demo/user-units.nix b/demo/user-units.nix index 90aa10d..2d6adfd 100644 --- a/demo/user-units.nix +++ b/demo/user-units.nix @@ -14,7 +14,7 @@ let name: spec: writeText "${name}.service" (toUnitFile { Unit = { - Description = "boot-tree demo: ${name}"; + Description = "bootvine demo: ${name}"; After = map (dependency: "${dependency}.service") (spec.after or [ ]); }; Service = { @@ -30,13 +30,13 @@ let targetFile = writeText "${demoUnits.target}.target" (toUnitFile { Unit = { - Description = "boot-tree demo target"; + Description = "bootvine demo target"; Wants = serviceNames; After = serviceNames; }; }); - units = linkFarm "boot-tree-demo-units" ( + units = linkFarm "bootvine-demo-units" ( lib.mapAttrsToList (name: spec: { name = "${name}.service"; path = serviceFile name spec; @@ -50,6 +50,6 @@ let ); in writeShellApplication { - name = "boot-tree-demo-units"; + name = "bootvine-demo-units"; text = ''exec ${lib.getExe nushell} ${./demo-units.nu} "$@" --units ${units} --target ${demoUnits.target}.target''; } diff --git a/examples/demo.rs b/examples/demo.rs index 20f081d..5d77540 100644 --- a/examples/demo.rs +++ b/examples/demo.rs @@ -4,7 +4,7 @@ use std::{ time::{Duration, Instant}, }; -use boot_tree::{ +use bootvine::{ model::{ActiveState, Activity, BootState, JobResult, Phase, UnitFacts}, palette::Palette, view::BootView, diff --git a/flake.nix b/flake.nix index 31599bf..99b4aa4 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "boot-tree — live dependency tree of systemd jobs on the boot console"; + description = "bootvine — live dependency tree of systemd jobs on the boot console"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; @@ -76,15 +76,15 @@ }; strictDeps = true; postInstall = '' - install -Dm644 packaging/systemd/boot-tree.service $out/lib/systemd/system/boot-tree.service - substituteInPlace $out/lib/systemd/system/boot-tree.service \ - --replace-fail /usr/bin/boot-tree $out/bin/boot-tree - install -Dm755 packaging/dracut/90boot-tree/module-setup.sh \ - $out/lib/dracut/modules.d/90boot-tree/module-setup.sh - install -Dm644 packaging/mkinitcpio/install/sd-boot-tree \ - $out/lib/initcpio/install/sd-boot-tree + install -Dm644 packaging/systemd/bootvine.service $out/lib/systemd/system/bootvine.service + substituteInPlace $out/lib/systemd/system/bootvine.service \ + --replace-fail /usr/bin/bootvine $out/bin/bootvine + install -Dm755 packaging/dracut/90bootvine/module-setup.sh \ + $out/lib/dracut/modules.d/90bootvine/module-setup.sh + install -Dm644 packaging/mkinitcpio/install/sd-bootvine \ + $out/lib/initcpio/install/sd-bootvine ''; - meta.mainProgram = "boot-tree"; + meta.mainProgram = "bootvine"; meta.platforms = lib.platforms.linux; }; demo-units = pkgs.callPackage ./demo/user-units.nix { inherit demoUnits; }; diff --git a/nixos-module.nix b/nixos-module.nix index 81c77f9..53d8d75 100644 --- a/nixos-module.nix +++ b/nixos-module.nix @@ -6,9 +6,9 @@ ... }: let - cfg = config.services.boot-tree; + cfg = config.services.bootvine; chosenColors = lib.filterAttrs (_: color: color != null) cfg.palette; - configFile = (pkgs.formats.toml { }).generate "boot-tree.toml" { palette = chosenColors; }; + configFile = (pkgs.formats.toml { }).generate "bootvine.toml" { palette = chosenColors; }; colorOption = role: default: lib.mkOption { @@ -23,7 +23,7 @@ let }; in { - options.services.boot-tree = { + options.services.bootvine = { enable = lib.mkEnableOption '' a live dependency tree of systemd jobs on the boot console. With a systemd initrd it starts there and survives the switch to the real root; @@ -34,8 +34,8 @@ in package = lib.mkOption { type = lib.types.package; default = self.packages.${pkgs.stdenv.hostPlatform.system}.default; - defaultText = lib.literalExpression "boot-tree.packages.\${system}.default"; - description = "The boot-tree package, which ships the systemd unit."; + defaultText = lib.literalExpression "bootvine.packages.\${system}.default"; + description = "The bootvine package, which ships the systemd unit."; }; palette = { @@ -52,19 +52,19 @@ in config = lib.mkIf cfg.enable { environment = { systemPackages = [ cfg.package ]; - etc."boot-tree.toml" = lib.mkIf (chosenColors != { }) { source = configFile; }; + etc."bootvine.toml" = lib.mkIf (chosenColors != { }) { source = configFile; }; }; systemd = { packages = [ cfg.package ]; - services.boot-tree.wantedBy = [ "sysinit.target" ]; + services.bootvine.wantedBy = [ "sysinit.target" ]; }; boot.initrd.systemd = lib.mkIf config.boot.initrd.systemd.enable { packages = [ cfg.package ]; storePaths = [ (lib.getExe cfg.package) ]; - services.boot-tree.wantedBy = [ "sysinit.target" ]; - contents."/etc/boot-tree.toml" = lib.mkIf (chosenColors != { }) { source = configFile; }; + services.bootvine.wantedBy = [ "sysinit.target" ]; + contents."/etc/bootvine.toml" = lib.mkIf (chosenColors != { }) { source = configFile; }; }; }; } diff --git a/packaging/dracut/90boot-tree/module-setup.sh b/packaging/dracut/90boot-tree/module-setup.sh deleted file mode 100755 index 2c7a4f1..0000000 --- a/packaging/dracut/90boot-tree/module-setup.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/bash - -check() { - require_binaries boot-tree || return 1 - return 255 -} - -depends() { - echo systemd -} - -install() { - inst_binary boot-tree - inst_simple "$systemdsystemunitdir/boot-tree.service" - if [[ -f /etc/boot-tree.toml ]]; then - inst_simple /etc/boot-tree.toml - fi - $SYSTEMCTL -q --root "$initdir" enable boot-tree.service -} diff --git a/packaging/dracut/90bootvine/module-setup.sh b/packaging/dracut/90bootvine/module-setup.sh new file mode 100755 index 0000000..fa91a27 --- /dev/null +++ b/packaging/dracut/90bootvine/module-setup.sh @@ -0,0 +1,19 @@ +#!/usr/bin/bash + +check() { + require_binaries bootvine || return 1 + return 255 +} + +depends() { + echo systemd +} + +install() { + inst_binary bootvine + inst_simple "$systemdsystemunitdir/bootvine.service" + if [[ -f /etc/bootvine.toml ]]; then + inst_simple /etc/bootvine.toml + fi + $SYSTEMCTL -q --root "$initdir" enable bootvine.service +} diff --git a/packaging/mkinitcpio/install/sd-boot-tree b/packaging/mkinitcpio/install/sd-boot-tree deleted file mode 100755 index 20b050c..0000000 --- a/packaging/mkinitcpio/install/sd-boot-tree +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/bash - -build() { - add_binary boot-tree - add_systemd_unit boot-tree.service - if [[ -f /etc/boot-tree.toml ]]; then - add_file /etc/boot-tree.toml - fi - add_symlink /usr/lib/systemd/system/sysinit.target.wants/boot-tree.service \ - /usr/lib/systemd/system/boot-tree.service -} - -help() { - cat < ExitCode { let cli = Cli::parse(); let config = match fs::read_to_string(&cli.config) { Ok(text) => toml::from_str(&text).unwrap_or_else(|error| { - eprintln!("boot-tree: ignoring {}: {error}", cli.config.display()); + eprintln!("bootvine: ignoring {}: {error}", cli.config.display()); Config::default() }), Err(error) if error.kind() == ErrorKind::NotFound => Config::default(), Err(error) => { - eprintln!("boot-tree: cannot read {}: {error}", cli.config.display()); + eprintln!("bootvine: cannot read {}: {error}", cli.config.display()); Config::default() } }; @@ -69,7 +69,7 @@ fn main() -> ExitCode { match run(&options) { Ok(()) => ExitCode::SUCCESS, Err(error) => { - eprintln!("boot-tree: {error}"); + eprintln!("bootvine: {error}"); ExitCode::FAILURE } } diff --git a/src/run.rs b/src/run.rs index e697b5a..6afcc1c 100644 --- a/src/run.rs +++ b/src/run.rs @@ -8,7 +8,7 @@ use std::{ time::{Duration, Instant}, }; -use boot_tree::{ +use bootvine::{ model::{BootState, Phase}, palette::Palette, view::BootView, @@ -115,7 +115,7 @@ fn watch( })?; if state.is_complete() { eprintln!( - "boot-tree: {} reached, handing the console over", + "bootvine: {} reached, handing the console over", state.root.as_deref().unwrap_or("boot") ); sleep(hold); diff --git a/src/systemd.rs b/src/systemd.rs index 0870893..3968aa0 100644 --- a/src/systemd.rs +++ b/src/systemd.rs @@ -1,6 +1,6 @@ use std::{iter, time::Duration}; -use boot_tree::model::{ActiveState, Activity, JobResult, UnitFacts}; +use bootvine::model::{ActiveState, Activity, JobResult, UnitFacts}; use dbus::{ Message, MessageType, Path, arg::{AppendAll, PropMap, RefArg, Variant}, diff --git a/src/view.rs b/src/view.rs index f66f955..e22ea5c 100644 --- a/src/view.rs +++ b/src/view.rs @@ -196,7 +196,7 @@ impl BootView<'_> { }); Table::new( [Row::new([ - Line::from(format!("boot-tree {}", self.host)), + Line::from(format!("bootvine {}", self.host)), Line::from(total.unwrap_or_default()).right_aligned(), ])], [Constraint::Fill(1), Constraint::Length(DURATION_WIDTH)], @@ -804,7 +804,7 @@ mod tests { fn tree_on_top_timeline_below() { let lines = render(&boot_in_progress(), 12_400 * MS, 110, 24); let screen = lines.join("\n"); - assert_eq!(lines[0], "boot-tree ryzen", "{screen}"); + assert_eq!(lines[0], "bootvine ryzen", "{screen}"); assert!(lines[2].starts_with("── stage 2 ──"), "{screen}"); assert!(lines[2].ends_with("12.4s ──"), "{screen}"); assert!(lines[3].starts_with("graphical.target"), "{screen}");