Files
bootvine/vm-tests/slow-services/sample-unit-files.nix
T
Willem Vanhulle 7e95cbd8e9 feat: show why units failed, with their last journal lines
Failed jobs keep their kind: units that broke or timed out get a failure
panel entry with the reason systemd reports (exit status, signal, timeout,
start limit, status text) and their last journal lines read through
libsystemd. Units that failed only through a dependency are dimmed and left
out of the panel, and units that crash after starting count as failed.

Restructure the repository around this:
- move the library and binary into bootvine/ and the scripted demos into
  their own unpublished scripted-demos crate, with their VHS tapes
- move the crane builds and NixOS module into nix/
- group each sample VM with its check under vm-tests/, adding text-console,
  scripted-initrd, encrypted-volume and failures machines and a vm-failures
  check
- add docs/guide.md walking through the screen with every recording, keep
  one recording in the README, and re-render all recordings
2026-10-30 14:59:10 +01:00

55 lines
1.4 KiB
Nix

{
sampleUnits,
lib,
coreutils,
runCommand,
writeText,
}:
let
toUnitFile = lib.generators.toINI { listsAsDuplicateKeys = true; };
serviceFile =
name: spec:
writeText "${name}.service" (toUnitFile {
Unit = {
Description = spec.description;
After = map (dependency: "${dependency}.service") (spec.after or [ ]);
};
Service = {
Type = "oneshot";
ExecStart = [
"${coreutils}/bin/sleep ${spec.seconds}"
]
++ lib.optional (spec.fails or false) "${coreutils}/bin/false";
}
// lib.optionalAttrs (spec ? stopSeconds) {
RemainAfterExit = true;
ExecStop = "${coreutils}/bin/sleep ${spec.stopSeconds}";
};
});
serviceNames = map (name: "${name}.service") (lib.attrNames sampleUnits.services);
targetFile = writeText "${sampleUnits.target}.target" (toUnitFile {
Unit = {
Description = "bootvine demo services";
Wants = serviceNames;
After = serviceNames;
};
});
unitFiles =
lib.mapAttrsToList (name: spec: {
name = "${name}.service";
path = serviceFile name spec;
}) sampleUnits.services
++ [
{
name = "${sampleUnits.target}.target";
path = targetFile;
}
];
in
runCommand "bootvine-sample-unit-files" { } (
lib.concatMapStringsSep "\n" (unit: "install -Dm644 ${unit.path} $out/${unit.name}") unitFiles
)