haskell-te: 7c23b95740ea762e1d845e04cb336c660b6e197e
1: { bash, callPackage, coreutils, fail, helpersSrc, jq, lib, nix, perl, procps,
2: runCommand, utillinux }:
3:
4: with builtins;
5: with rec {
6: # Force nix-helpers version to use the same Nix package as us
7: withNix' =
8: with callPackage "${helpersSrc}/helpers/withNix.nix" {};
9: def;
10:
11: # Allow given env to override us, but we must override buildInputs
12: go = env: withNix' ({ inherit NIX_PATH; } // env) // {
13: buildInputs = (env.buildInputs or []) ++ commonDeps;
14: };
15:
16: # We include these for historical reasons
17: commonDeps = [
18: bash coreutils jq (nix.out or nix) perl procps utillinux
19: ];
20:
21: # Override NIX_PATH to take into account recursion using <real>
22:
23: NIX_PATH = concatStringsSep ":" [
24: "nixpkgs=${./..}"
25: "real=${toString pathReal}"
26: (getEnv "NIX_PATH")
27: ];
28:
29: # If we don't have <real> yet, use <nixpkgs>
30: pathReal = with tryEval <real>;
31: if success then value else <nixpkgs>;
32:
33: # Tests
34:
35: checkPath = runCommand "try-nix-path.nix"
36: (go { buildInputs = [ fail jq ]; })
37: ''
38: function go {
39: echo "Checking: $*" 1>&2
40: nix-instantiate --show-trace --eval --read-write-mode -E \
41: "with builtins // { x = import <nixpkgs> { config = {}; overlays = []; }; }; $1" ||
42: fail "Failed:\nNIX_PATH: $NIX_PATH\nNIX_REMOTE: $NIX_REMOTE"
43: echo "Finished: $*" 1>&2
44: }
45:
46: echo "Checking <nixpkgs> gets overridden" 1>&2
47: RESULT=$(go '<nixpkgs>')
48: F="$RESULT/nix-support/withNix.nix"
49: [[ -e "$F" ]] || fail "No such file '$F' (<nixpkgs> = '$RESULT')"
50:
51: echo "Checking <nixpkgs> isn't polluted by ~/.nixpkgs/config.nix" 1>&2
52: go 'assert !(x ? warbo-utilities); true'
53: go 'assert !(x.haskellPackages ? haskell-example); true'
54:
55: echo "Checking <nixpkgs> has our custom definitions" 1>&2
56: go 'assert x ? wrap; true'
57: for P in mlspec mlspec-helper nix-eval runtime-arbitrary
58: do
59: go "assert x.haskellPackages ? $P; true"
60: done
61:
62: echo "true" > "$out"
63: '';
64: };
65:
66: assert import checkPath;
67: go
Generated by git2html.