about summary refs log tree commit diff
path: root/nixos/tests/env.nix
blob: dec17b6b565a0fa1ae6bd14058b1f3304bb31141 (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
34
35
36
import ./make-test-python.nix ({ pkgs, ...} : {
  name = "environment";
  meta = with pkgs.lib.maintainers; {
    maintainers = [ nequissimus ];
  };

  nodes.machine = { pkgs, ... }:
    {
      boot.kernelPackages = pkgs.linuxPackages;
      environment.etc.plainFile.text = ''
        Hello World
      '';
      environment.etc."folder/with/file".text = ''
        Foo Bar!
      '';

      environment.sessionVariables = {
        TERMINFO_DIRS = "/run/current-system/sw/share/terminfo";
        NIXCON = "awesome";
      };
    };

  testScript = ''
    machine.succeed('[ -L "/etc/plainFile" ]')
    assert "Hello World" in machine.succeed('cat "/etc/plainFile"')
    machine.succeed('[ -d "/etc/folder" ]')
    machine.succeed('[ -d "/etc/folder/with" ]')
    machine.succeed('[ -L "/etc/folder/with/file" ]')
    assert "Hello World" in machine.succeed('cat "/etc/plainFile"')

    assert "/run/current-system/sw/share/terminfo" in machine.succeed(
        "echo ''${TERMINFO_DIRS}"
    )
    assert "awesome" in machine.succeed("echo ''${NIXCON}")
  '';
})