From f945b569f5496f9feb9b15d63aead896f24d99bb Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 23 Jul 2024 20:07:16 +0200 Subject: [PATCH] packages/catalog: expose simulacrum checks differently --- packages/catalog/checks.nix | 41 +++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/packages/catalog/checks.nix b/packages/catalog/checks.nix index 1dab997..d8c2c72 100644 --- a/packages/catalog/checks.nix +++ b/packages/catalog/checks.nix @@ -1,21 +1,32 @@ { lib, ... }: { - perSystem = { config, ... }: { - catalog.depot = { - checks = lib.mapAttrs (name: check: { - description = "NixOS Test: ${name}"; - actions = { - build = { - description = "Build this check."; - command = "nix build -L --no-link '${builtins.unsafeDiscardStringContext check.drvPath}^*'"; - }; - runInteractive = { - description = "Run interactive driver."; - command = lib.getExe check.driverInteractive; - }; + perSystem = { config, pkgs, ... }: { + catalog = lib.mkMerge (lib.mapAttrsToList (name': check: let + simulacrum = lib.hasPrefix "simulacrum-" name'; + name = lib.removePrefix "simulacrum-" name'; + baseAttrPath = if simulacrum then + [ "cluster" "simulacrum" ] + else + [ "depot" "checks" ]; + in lib.setAttrByPath (baseAttrPath ++ [ name ]) { + description = if simulacrum then + "Simulacrum Test: ${name}" + else + "NixOS Test: ${name}"; + actions = { + build = { + description = "Build this check."; + command = "nix build -L --no-link '${builtins.unsafeDiscardStringContext check.drvPath}^*'"; }; - }) config.checks; - }; + runInteractive = { + description = "Run interactive driver."; + command = if simulacrum then + "${pkgs.bubblewrap}/bin/bwrap --unshare-all --bind / / --dev-bind /dev /dev ${lib.getExe check.driverInteractive}" + else + lib.getExe check.driverInteractive; + }; + }; + }) config.checks); }; }