File tree Expand file tree Collapse file tree 2 files changed +64
-1
lines changed
Expand file tree Collapse file tree 2 files changed +64
-1
lines changed Original file line number Diff line number Diff line change 11{
22 lib ,
3+ pkgs ,
4+ sources ,
35 ...
46} @args :
57let
Original file line number Diff line number Diff line change 3939*/
4040{
4141 lib ,
42+ pkgs ,
43+ sources ,
44+ config ,
4245 ngiTypes ,
4346 ...
4447} :
5255 inherit ( ngiTypes )
5356 problem
5457 ;
58+
59+ # TODO: move into `lib.nix`?
60+ nixosTest =
61+ test :
62+ let
63+ # Amenities for interactive tests
64+ tools = {
65+ environment . systemPackages = with pkgs ; [
66+ vim
67+ tmux
68+ jq
69+ ] ;
70+ # Use kmscon <https://www.freedesktop.org/wiki/Software/kmscon/>
71+ # to provide a slightly nicer console.
72+ # kmscon allows zooming with [Ctrl] + [+] and [Ctrl] + [-]
73+ services . kmscon = {
74+ enable = true ;
75+ autologinUser = "root" ;
76+ fonts = [
77+ {
78+ name = "Hack" ;
79+ package = pkgs . hack-font ;
80+ }
81+ ] ;
82+ } ;
83+ } ;
84+
85+ debugging . interactive . nodes = lib . mapAttrs ( _ : _ : tools ) test . nodes ;
86+
87+ args = {
88+ imports = [
89+ debugging
90+ test
91+ ] ;
92+ # we need to extend pkgs with ngipkgs, so it can't be read-only
93+ node . pkgsReadOnly = false ;
94+ } ;
95+ in
96+ if lib . isDerivation test then
97+ lib . lazyDerivation { derivation = test ; }
98+ else if test == null then
99+ null
100+ else
101+ pkgs . testers . runNixOSTest args ;
102+
103+ callTest =
104+ module :
105+ if lib . isString module || lib . isPath module then
106+ nixosTest (
107+ import module {
108+ inherit pkgs lib sources ;
109+ inherit ( pkgs ) system ;
110+ }
111+ )
112+ else if module == null || config . problem != null then
113+ null
114+ else
115+ nixosTest module ;
55116in
56117
57118{
65126 # This is because test nodes are eagerly evaluated to create the
66127 # driver's `vmStartScripts` (see `nixos/lib/testing/driver.nix` in
67128 # NixOS).
68- type = with types ; nullOr ( either deferredModule package ) ;
129+ type = with types ; nullOr ( coercedTo ( either deferredModule package ) callTest package ) ;
69130 default = null ;
70131 description = "NixOS test module" ;
71132 } ;
You can’t perform that action at this time.
0 commit comments