summary refs log tree commit diff
path: root/pkgs/test/nixos-functions/default.nix
blob: c8f7122006f70864fede29d03f953cb0c998ae63 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*

This file is a test that makes sure that the `pkgs.nixos` and
`pkgs.nixosTest` functions work. It's far from a perfect test suite,
but better than not checking them at all on hydra.

To run this test:

    nixpkgs$ nix-build -A tests.nixos-functions

 */
{ pkgs, lib, stdenv, ... }:

lib.optionalAttrs stdenv.hostPlatform.isLinux (
  pkgs.recurseIntoAttrs {

    nixos-test = (pkgs.nixos {
      boot.loader.grub.enable = false;
      fileSystems."/".device = "/dev/null";
    }).toplevel;

    nixosTest-test = pkgs.nixosTest ({ lib, pkgs, ... }: {
      name = "nixosTest-test";
      machine = { pkgs, ... }: {
        environment.systemPackages = [ pkgs.hello ];
      };
      testScript = ''
        $machine->succeed("hello");
      '';
    });

  }
)