From a10e205e9b7bc6212fb1c969dcdf2757f4a3a9f2 Mon Sep 17 00:00:00 2001 From: Willem Vanhulle Date: Sun, 25 Oct 2026 15:07:47 +0100 Subject: [PATCH] ci: update config --- docs/configuration.md | 77 +++++++++++++++++++++++++++++--- docs/development.md | 2 + xtask/src/main.rs | 6 +++ xtask/src/sync_default_config.rs | 41 +++++++++++++++++ xtask/src/task_error.rs | 2 + 5 files changed, 121 insertions(+), 7 deletions(-) create mode 100644 xtask/src/sync_default_config.rs diff --git a/docs/configuration.md b/docs/configuration.md index a621975..7b573f6 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -39,7 +39,70 @@ some, write only those keys: `bootvine defaults` prints every key with its default as TOML, and `bootvine defaults --format nix` prints the same as a Nix attribute set to -paste into `services.bootvine.settings`. +paste into `services.bootvine.settings`: + +```toml +[colors.header] +origin = "white" +separators = "dark-gray" +total-time = "white" + +[colors.stages] +branches = "dark-gray" +finished-label = "gray" +finished-time = "green" +unit-count = "gray" +failed-count = "light-red" +current = "white" + +[colors.tree] +branches = "dark-gray" +columns = "dark-gray" +target = "cyan" +current-stage = "yellow" +reached-stage = "green" +running-unit = "white" +running-marker = "yellow" +waiting-unit = "gray" +finished-unit = "dark-gray" +finished-marker = "green" +failed-unit = "light-red" +overflow = "gray" + +[colors.timeline] +rule = "dark-gray" +title = "gray" +axis = "dark-gray" +milestone = "green" +finished = "green" +finished-label = "gray" +failed = "light-red" +queued-bar = "gray" +running = "yellow" +running-label = "white" + +[colors.footer] +rule = "dark-gray" +done = "green" +running = "yellow" +waiting = "gray" +failed = "light-red" +no-failures = "gray" + +[colors.password] +frame = "yellow" +message = "white" +hint = "dark-gray" +checking = "gray" +rejected = "light-red" +backdrop = "dark-gray" + +[timing] +keep-finished-units-for = "2s" +hide-runs-shorter-than = "1s" +keep-final-frame-for = "1s" +wait-for-display-manager = "10s" +``` ## Colours @@ -61,12 +124,12 @@ palette instead: `console.colors` on NixOS, or the `vt.default_red`, ## Timing -| Key | Default | Meaning | -| --- | --- | --- | -| `keep-finished-units-for` | `2s` | How long a finished unit stays in the tree, faded, before it leaves. | -| `hide-runs-shorter-than` | `1s` | Runs shorter than this get no timer and no timeline bar. | -| `keep-final-frame-for` | `1s` | How long the last frame stays before the console is handed back. | -| `wait-for-display-manager` | `10s` | When a display manager is starting, how long to wait for it to switch to its own terminal instead, so the console's status lines never show in between. | +| Key | Meaning | +| --- | --- | +| `keep-finished-units-for` | How long a finished unit stays in the tree, faded, before it leaves. | +| `hide-runs-shorter-than` | Runs shorter than this get no timer and no timeline bar. | +| `keep-final-frame-for` | How long the last frame stays before the console is handed back. | +| `wait-for-display-manager` | When a display manager is starting, how long to wait for it to switch to its own terminal instead, so the console's status lines never show in between. | ## Early kernel messages diff --git a/docs/development.md b/docs/development.md index ebd7777..348f1c3 100644 --- a/docs/development.md +++ b/docs/development.md @@ -85,6 +85,8 @@ exports libraries that clash with [QEMU](https://www.qemu.org) or Chromium. - `nix run .#record-screencasts` re-records the README animations from the scripted demos and copies the passphrase screenshot from the VM check. +- `cargo xtask sync-default-config` rewrites the defaults block in + [configuration](configuration.md#defaults) from `bootvine defaults`. - `cargo run -- install --destdir --initrd dracut` stages an install without touching the system; `cargo run -- uninstall --destdir ` removes it again. diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 1e440f9..90d35b4 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -1,4 +1,5 @@ mod record_screencasts; +mod sync_default_config; mod task_error; use std::{path::PathBuf, process::ExitCode}; @@ -19,6 +20,10 @@ enum Task { recordings/" )] RecordScreencasts(RecordScreencastsOptions), + #[command( + about = "Rewrite the defaults block in docs/configuration.md from `bootvine defaults`" + )] + SyncDefaultConfig, } #[derive(Args)] @@ -32,6 +37,7 @@ fn main() -> ExitCode { Task::RecordScreencasts(options) => { record_screencasts::record_screencasts(&options.passphrase_png) } + Task::SyncDefaultConfig => sync_default_config::sync_default_config(), }; match outcome { Ok(()) => ExitCode::SUCCESS, diff --git a/xtask/src/sync_default_config.rs b/xtask/src/sync_default_config.rs new file mode 100644 index 0000000..7613e52 --- /dev/null +++ b/xtask/src/sync_default_config.rs @@ -0,0 +1,41 @@ +use std::{fs, path::Path}; + +use xshell::{Shell, cmd}; + +use crate::task_error::TaskError; + +const CONFIGURATION_DOC: &str = "docs/configuration.md"; +const DEFAULTS_HEADING: &str = "## Defaults\n"; +const TOML_FENCE_OPEN: &str = "```toml\n"; +const FENCE_CLOSE: &str = "```\n"; + +pub fn sync_default_config() -> Result<(), TaskError> { + let doc_path = Path::new(CONFIGURATION_DOC); + let doc_file_error = |source| TaskError::File { + path: doc_path.to_path_buf(), + source, + }; + let doc_text = fs::read_to_string(doc_path).map_err(doc_file_error)?; + let shell = Shell::new()?; + let printed_defaults = + cmd!(shell, "cargo run --quiet --package bootvine -- defaults").read()?; + let synced_text = replace_defaults_block(&doc_text, &printed_defaults) + .ok_or(TaskError::DefaultsBlockMissing(CONFIGURATION_DOC))?; + if synced_text != doc_text { + fs::write(doc_path, synced_text).map_err(doc_file_error)?; + } + Ok(()) +} + +fn replace_defaults_block(doc_text: &str, printed_defaults: &str) -> Option { + let section_start = doc_text.find(DEFAULTS_HEADING)?; + let block_start = + section_start + doc_text[section_start..].find(TOML_FENCE_OPEN)? + TOML_FENCE_OPEN.len(); + let block_end = block_start + doc_text[block_start..].find(FENCE_CLOSE)?; + Some(format!( + "{}{}\n{}", + &doc_text[..block_start], + printed_defaults.trim_end(), + &doc_text[block_end..] + )) +} diff --git a/xtask/src/task_error.rs b/xtask/src/task_error.rs index 72b3379..88213d8 100644 --- a/xtask/src/task_error.rs +++ b/xtask/src/task_error.rs @@ -10,4 +10,6 @@ pub enum TaskError { File { path: PathBuf, source: io::Error }, #[error("no recordings directory here; run from the repository root")] NotInRepositoryRoot, + #[error("{0} has no ```toml block under its Defaults heading")] + DefaultsBlockMissing(&'static str), }