···39394040## Calling a test {#sec-calling-nixos-tests}
41414242-Tests are invoked a bit differently depending on whether the test lives in NixOS or in another project.
4242+Tests are invoked differently depending on whether the test is part of NixOS or lives in a different project.
43434444### Testing within NixOS {#sec-call-nixos-test-in-nixos}
4545-4646-Test modules can be instantiated into derivations in multiple ways.
47454846Tests that are part of NixOS are added to [`nixos/tests/all-tests.nix`](https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/all-tests.nix).
4947···5452Overrides can be added by defining an anonymous module in `all-tests.nix`.
55535654```nix
5757- hostname = runTest { imports = [ ./hostname.nix ]; defaults.networking.firewall.enable = false; };
5555+ hostname = runTest {
5656+ imports = [ ./hostname.nix ];
5757+ defaults.networking.firewall.enable = false;
5858+ };
5859```
59606060-You can run a test with attribute name `mytest` in `nixos/tests/all-tests.nix` by invoking:
6161+You can run a test with attribute name `hostname` in `nixos/tests/all-tests.nix` by invoking:
61626263```shell
6364cd /my/git/clone/of/nixpkgs
6464-nix-build -A nixosTests.mytest
6565+nix-build -A nixosTests.hostname
6566```
66676768### Testing outside the NixOS project {#sec-call-nixos-test-outside-nixos}
68696969-Outside the `nixpkgs` repository, you can instantiate the test by first acquiring the NixOS library,
7070+Outside the `nixpkgs` repository, you can instantiate the test by first importing the NixOS library,
70717172```nix
7273# regular nix
···4949 <section xml:id="sec-calling-nixos-tests">
5050 <title>Calling a test</title>
5151 <para>
5252- Tests are invoked a bit differently depending on whether the test
5353- lives in NixOS or in another project.
5252+ Tests are invoked differently depending on whether the test is
5353+ part of NixOS or lives in a different project.
5454 </para>
5555 <section xml:id="sec-call-nixos-test-in-nixos">
5656 <title>Testing within NixOS</title>
5757- <para>
5858- Test modules can be instantiated into derivations in multiple
5959- ways.
6060- </para>
6157 <para>
6258 Tests that are part of NixOS are added to
6359 <link xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/all-tests.nix"><literal>nixos/tests/all-tests.nix</literal></link>.
···7066 <literal>all-tests.nix</literal>.
7167 </para>
7268 <programlisting language="bash">
7373- hostname = runTest { imports = [ ./hostname.nix ]; defaults.networking.firewall.enable = false; };
6969+ hostname = runTest {
7070+ imports = [ ./hostname.nix ];
7171+ defaults.networking.firewall.enable = false;
7272+ };
7473</programlisting>
7574 <para>
7676- You can run a test with attribute name <literal>mytest</literal>
7777- in <literal>nixos/tests/all-tests.nix</literal> by invoking:
7575+ You can run a test with attribute name
7676+ <literal>hostname</literal> in
7777+ <literal>nixos/tests/all-tests.nix</literal> by invoking:
7878 </para>
7979 <programlisting>
8080cd /my/git/clone/of/nixpkgs
8181-nix-build -A nixosTests.mytest
8181+nix-build -A nixosTests.hostname
8282</programlisting>
8383 </section>
8484 <section xml:id="sec-call-nixos-test-outside-nixos">
8585 <title>Testing outside the NixOS project</title>
8686 <para>
8787 Outside the <literal>nixpkgs</literal> repository, you can
8888- instantiate the test by first acquiring the NixOS library,
8888+ instantiate the test by first importing the NixOS library,
8989 </para>
9090 <programlisting language="bash">
9191# regular nix