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