refactor: reorganise flake, tests and repo tasks

This commit is contained in:
Willem Vanhulle committed 2026-10-21 12:12:49 +02:00
1 parent b93147c7a6
commit 794ca5a086
34 files changed
+670 -220

No files matched your search

+25
View File
@@ -0,0 +1,25 @@
{ lib, bootvineModule }:
let
sampleUnits = import ./sample-units.nix;
machine = {
imports = [
bootvineModule
./machine.nix
];
_module.args = { inherit sampleUnits; };
};
in
{
inherit sampleUnits machine;
nixosSystemFor =
system:
lib.nixosSystem {
inherit system;
modules = [
machine
./interactive-vm.nix
];
};
}
+20
View File
@@ -0,0 +1,20 @@
{
boot.loader.grub.enable = false;
services.getty.autologinUser = "root";
fileSystems."/" = {
device = "/dev/disk/by-label/nixos";
fsType = "ext4";
};
virtualisation.vmVariant.virtualisation = {
memorySize = 2048;
cores = 2;
graphics = true;
diskImage = "\${XDG_CACHE_HOME:-$HOME/.cache}/bootvine-sample-machine.qcow2";
qemu.options = [
"-vga none"
"-device virtio-vga,xres=1920,yres=1080"
];
};
}
+92
View File
@@ -0,0 +1,92 @@
{
sampleUnits,
lib,
pkgs,
...
}:
let
sampleService = spec: {
inherit (spec) description;
after = map (dependency: "${dependency}.service") (spec.after or [ ]);
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = [
"${pkgs.coreutils}/bin/sleep ${spec.seconds}"
]
++ lib.optional (spec.fails or false) "${pkgs.coreutils}/bin/false";
}
// lib.optionalAttrs (spec ? stopSeconds) {
RemainAfterExit = true;
ExecStop = "${pkgs.coreutils}/bin/sleep ${spec.stopSeconds}";
};
};
in
{
networking.hostName = "bootvine-demo";
system.stateVersion = "26.05";
boot.consoleLogLevel = lib.mkForce 3;
boot.initrd.systemd = {
enable = true;
services.demo-initrd-probe = {
description = "Slow hardware probe";
wantedBy = [ "initrd.target" ];
before = [ "initrd.target" ];
unitConfig.DefaultDependencies = false;
serviceConfig = {
Type = "oneshot";
ExecStart = "/bin/sleep ${sampleUnits.initrdProbeSeconds}";
};
};
};
services.bootvine = {
enable = true;
settings.colors = {
tree.current-stage = "light-yellow";
tree.running-marker = "light-yellow";
timeline.running = "light-yellow";
footer.running = "light-yellow";
password.frame = "light-yellow";
};
};
console = {
colors = [
"1d2021"
"fb4934"
"b8bb26"
"fabd2f"
"83a598"
"d3869b"
"8ec07c"
"d5c4a1"
"665c54"
"fb4934"
"b8bb26"
"fabd2f"
"83a598"
"d3869b"
"8ec07c"
"fbf1c7"
];
earlySetup = true;
font = "${pkgs.terminus_font}/share/consolefonts/ter-v20n.psf.gz";
};
systemd.services = lib.mapAttrs (_: sampleService) sampleUnits.services // {
greetd.after = [ "multi-user.target" ];
};
services.greetd = {
enable = true;
settings.default_session.command = "${pkgs.greetd}/bin/agreety --cmd ${pkgs.bashInteractive}/bin/bash";
};
users.users.demo = {
isNormalUser = true;
password = "demo";
};
}
@@ -0,0 +1,54 @@
{
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
)
+52
View File
@@ -0,0 +1,52 @@
{
target = "bootvine-demo";
initrdProbeSeconds = "6";
services = {
demo-disk = {
description = "Scratch disk preparation";
seconds = "2";
stopSeconds = "2";
};
demo-db = {
description = "Demo database";
seconds = "3";
stopSeconds = "3";
after = [ "demo-disk" ];
};
demo-cache = {
description = "In-memory cache";
seconds = "1.5";
stopSeconds = "1";
};
demo-web = {
description = "Web frontend";
seconds = "2";
stopSeconds = "2";
after = [
"demo-db"
"demo-cache"
];
};
demo-fetch = {
description = "Remote content sync";
seconds = "4";
};
demo-flaky = {
description = "Flaky health check";
seconds = "1";
fails = true;
};
demo-slow = {
description = "Slow warm-up job";
seconds = "8";
};
demo-report = {
description = "Startup report";
seconds = "1";
after = [
"demo-web"
"demo-fetch"
];
};
};
}