nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 haskellPackages,
4}:
5
6let
7 withEnv =
8 env:
9 haskellPackages.mkDerivation {
10 pname = "puppy";
11 version = "1.0.0";
12 src = null;
13 license = null;
14
15 inherit env;
16 };
17
18 failures = lib.runTests {
19 testCanSetEnv = {
20 expr =
21 (withEnv {
22 PUPPY = "DOGGY";
23 }).drvAttrs.PUPPY;
24 expected = "DOGGY";
25 };
26
27 testCanSetEnvMultiple = {
28 expr =
29 let
30 env =
31 (withEnv {
32 PUPPY = "DOGGY";
33 SILLY = "GOOFY";
34 }).drvAttrs;
35 in
36 {
37 inherit (env) PUPPY SILLY;
38 };
39 expected = {
40 PUPPY = "DOGGY";
41 SILLY = "GOOFY";
42 };
43 };
44
45 testCanSetEnvPassthru = {
46 expr =
47 (withEnv {
48 PUPPY = "DOGGY";
49 }).passthru.env.PUPPY;
50 expected = "DOGGY";
51 };
52 };
53in
54# TODO: Use `lib.debug.throwTestFailures`: https://github.com/NixOS/nixpkgs/pull/416207
55lib.optional (failures != [ ]) (throw "${lib.generators.toPretty { } failures}")