summaryrefslogtreecommitdiff
path: root/tests/users-packages.nix
blob: 023389707bf20305e38d6b98022d448bbad40106 (plain)
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
{ config, pkgs, ... }:

let
  hello = pkgs.runCommand "hello-0.0.0" {} ''
    mkdir -p $out/bin $out/lib
    touch $out/bin/hello $out/lib/libhello.dylib
  '';
in

{
  users.knownUsers = [ "foo" ];
  users.users.foo.uid = 42000;
  users.users.foo.gid = 42000;
  users.users.foo.description = "Foo user";
  users.users.foo.isHidden = false;
  users.users.foo.home = "/Users/foo";
  users.users.foo.shell = "/run/current-system/sw/bin/bash";
  users.users.foo.packages = [ hello ];

  test = ''
    echo checking hello binary in /etc/profiles/per-user/foo/bin >&2
    test -e ${config.out}/etc/profiles/per-user/foo/bin/hello
    test "$(readlink -f ${config.out}/etc/profiles/per-user/foo/bin/hello)" = "${hello}/bin/hello"

    echo checking for unexpected paths in /etc/profiles/per-user/foo/bin >&2
    test -e ${config.out}/etc/profiles/per-user/foo/lib/libhello.dylib && return

    echo "checking /etc/profiles/per-user/foo/bin in environment" >&2
    grep 'export PATH=.*:/etc/profiles/per-user/$USER/bin' ${config.system.build.setEnvironment}
  '';
}