at 23.11-beta 2.0 kB view raw
1{ config, hostPkgs, lib, ... }: 2let 3 inherit (lib) types mkOption mdDoc; 4in 5{ 6 options = { 7 passthru = mkOption { 8 type = types.lazyAttrsOf types.raw; 9 description = mdDoc '' 10 Attributes to add to the returned derivations, 11 which are not necessarily part of the build. 12 13 This is a bit like doing `drv // { myAttr = true; }` (which would be lost by `overrideAttrs`). 14 It does not change the actual derivation, but adds the attribute nonetheless, so that 15 consumers of what would be `drv` have more information. 16 ''; 17 }; 18 19 rawTestDerivation = mkOption { 20 type = types.package; 21 description = mdDoc '' 22 Unfiltered version of `test`, for troubleshooting the test framework and `testBuildFailure` in the test framework's test suite. 23 This is not intended for general use. Use `test` instead. 24 ''; 25 internal = true; 26 }; 27 28 test = mkOption { 29 type = types.package; 30 # TODO: can the interactive driver be configured to access the network? 31 description = mdDoc '' 32 Derivation that runs the test as its "build" process. 33 34 This implies that NixOS tests run isolated from the network, making them 35 more dependable. 36 ''; 37 }; 38 }; 39 40 config = { 41 rawTestDerivation = hostPkgs.stdenv.mkDerivation { 42 name = "vm-test-run-${config.name}"; 43 44 requiredSystemFeatures = [ "kvm" "nixos-test" ]; 45 46 buildCommand = '' 47 mkdir -p $out 48 49 # effectively mute the XMLLogger 50 export LOGFILE=/dev/null 51 52 ${config.driver}/bin/nixos-test-driver -o $out 53 ''; 54 55 passthru = config.passthru; 56 57 meta = config.meta; 58 }; 59 test = lib.lazyDerivation { # lazyDerivation improves performance when only passthru items and/or meta are used. 60 derivation = config.rawTestDerivation; 61 inherit (config) passthru meta; 62 }; 63 64 # useful for inspection (debugging / exploration) 65 passthru.config = config; 66 }; 67}