From 4cad47f3fad2767458d9d5ebaabec544d508bdca Mon Sep 17 00:00:00 2001 From: lassulus Date: Thu, 20 Jul 2023 18:32:47 +0200 Subject: [PATCH] module: expose diskoTest via system.build --- module.nix | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/module.nix b/module.nix index ccece50..b6815d2 100644 --- a/module.nix +++ b/module.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, extendModules, ... }@args: let diskoLib = import ./lib { inherit lib; @@ -34,6 +34,16 @@ in type = lib.types.bool; default = false; }; + tests = { + efi = lib.mkOption { + description = '' + Whether efi is enabled for the `system.build.installTest`. + We try to automatically detect efi based on the configured bootloader. + ''; + type = lib.types.bool; + default = config.boot.loader.systemd-boot.enable || config.boot.loader.grub.efiSupport; + }; + }; }; config = lib.mkIf (cfg.devices.disk != { }) { system.build = (cfg.devices._scripts { inherit pkgs; checked = cfg.checkScripts; }) // { @@ -41,6 +51,14 @@ in # we keep this old outputs for compatibility disko = builtins.trace "the .disko output is deprecated, plase use .diskoScript instead" cfg.devices._scripts.diskoScript; diskoNoDeps = builtins.trace "the .diskoNoDeps output is deprecated, plase use .diskoScriptNoDeps instead" cfg.devices._scripts.diskoScriptNoDeps; + + installTest = diskoLib.testLib.makeDiskoTest { + inherit extendModules pkgs; + name = "${config.networking.hostName}-disko"; + disko-config = builtins.removeAttrs config ["_module"]; + testMode = "direct"; + efi = cfg.tests.efi; + }; };