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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
{
  lib,
  stdenv,
  symlinkJoin,

  pkgs,

  nix,
  nixpkgs,
  system,
}:

# NOTE: Every endpoint used here is very fragile as nixpkgs is not built
#       to test itself with anything other than CppNix. It will probably
#       break during some nixpkgs bump.

let
  inherit (lib) concatStringsSep optionals;

  # Deprecated features to enable while running the nixpkgs test suite
  # FIXME: All of these are fixed in Nixpkgs already, so clear the list on the next `nixpkgs` bump
  deprecatedFeatures = [
    "broken-string-indentation"
    "broken-string-escape"
    "rec-set-merges"
    "rec-set-dynamic-attrs"
    "or-as-identifier"
    "tokens-no-whitespace"
    "ancient-let"
  ];

  env.NIX_CONFIG = "extra-deprecated-features = ${concatStringsSep " " deprecatedFeatures}";
in

symlinkJoin {
  name = "nixpkgs-lib-tests";
  paths =
    map
      (
        drv:
        drv.overrideAttrs (old: {
          env = (old.env or { }) // env;
        })
      )
      (
        [
          (
            (import (nixpkgs + "/lib/tests/test-with-nix.nix") {
              inherit pkgs lib nix;
            }).overrideAttrs
            (_: {
              buildInputs = [
                (import (nixpkgs + "/lib/path/tests") {
                  inherit pkgs;
                  # NOTE: Override the nix version used here, we cannot rely on CppNix actually building
                  #       c.f. https://github.com/NixOS/nixpkgs/blob/master/lib/path/tests/default.nix#L18
                  nixVersions.stable = nix;
                })
              ];
            })
          )
        ]
        ++ optionals stdenv.isLinux [
          ((pkgs.callPackage (nixpkgs + "/ci/eval") { inherit nix; } { }).attrpathsSuperset {
            evalSystem = system;
          })
        ]
      );
}