1{
2 lib,
3 stdenv,
4 mkMesonDerivation,
5
6 meson,
7 ninja,
8 pkg-config,
9
10 jq,
11 git,
12 mercurial,
13 util-linux,
14
15 nix-store,
16 nix-expr,
17 nix-cli,
18
19 busybox-sandbox-shell ? null,
20
21 # Configuration Options
22
23 pname ? "nix-functional-tests",
24 version,
25
26 # For running the functional tests against a different pre-built Nix.
27 test-daemon ? null,
28}:
29
30mkMesonDerivation (
31 finalAttrs:
32 {
33 inherit pname version;
34
35 workDir = ./.;
36
37 # Hack for sake of the dev shell
38 passthru.externalNativeBuildInputs = [
39 meson
40 ninja
41 pkg-config
42
43 jq
44 git
45 mercurial
46 ]
47 ++ lib.optionals stdenv.hostPlatform.isLinux [
48 # For various sandboxing tests that needs a statically-linked shell,
49 # etc.
50 busybox-sandbox-shell
51 # For Overlay FS tests need `mount`, `umount`, and `unshare`.
52 # For `script` command (ensuring a TTY)
53 # TODO use `unixtools` to be precise over which executables instead?
54 util-linux
55 ];
56
57 nativeBuildInputs = finalAttrs.passthru.externalNativeBuildInputs ++ [
58 nix-cli
59 ];
60
61 buildInputs = [
62 nix-store
63 nix-expr
64 ];
65
66 preConfigure =
67 # TEMP hack for Meson before make is gone, where
68 # `src/nix-functional-tests` is during the transition a symlink and
69 # not the actual directory directory.
70 ''
71 cd $(readlink -e $PWD)
72 echo $PWD | grep tests/functional
73 '';
74
75 mesonCheckFlags = [
76 "--print-errorlogs"
77 ];
78
79 doCheck = true;
80
81 installPhase = ''
82 mkdir $out
83 '';
84
85 meta = {
86 platforms = lib.platforms.unix;
87 };
88
89 }
90 // lib.optionalAttrs (test-daemon != null) {
91 NIX_DAEMON_PACKAGE = test-daemon;
92 _NIX_TEST_CLIENT_VERSION = nix-cli.version;
93 }
94)