forked from input-output-hk/haskell.nix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
95 lines (90 loc) · 3.16 KB
/
default.nix
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
{ system ? builtins.currentSystem
, sourcesOverride ? { }
, checkMaterialization ? false
, ...
}:
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
# NOTE: This has to be whitelisted in restricted evaluation mode
flake-compat =
with lock.nodes.flake-compat.locked;
builtins.fetchTarball {
url = "https://github.com/input-output-hk/flake-compat/archive/${rev}.tar.gz";
sha256 = narHash;
};
# With flake-compat you will end up fetching the flake inputs with
# builtins.fetchTarball. This is simply because you don't have access to any
# nixpkgs before fetching the inputs.
#
# This won't work in restricted evaluation mode.
#
# Under the mild assumtion that https://github.com/NixOS is whitelisted, we
# can manually fetch nixpkgs and let flake-compat fetch the rest of the
# inputs with the nixpkgs just fetched.
#
# Manually fetch nixpkgs
nixpkgs =
with lock.nodes.nixpkgs.locked;
builtins.fetchTarball {
url = "https://github.com/NixOS/nixpkgs/archive/${rev}.tar.gz";
sha256 = narHash;
};
#
# Instantiate the flake fetching the other inputs with the nixpkgs already
# fetched
self = (import flake-compat {
pkgs = import nixpkgs { };
# We bypass flake-compat's rootSrc cleaning by evading its detection of this as a git
# repo.
# This is done for 3 reasons:
# * To workaround https://github.com/edolstra/flake-compat/issues/25
# * Make `updateMaterilized` scripts work (if filtering is done by `flake-compat`
# the `updateMaterilized` scripts will try to update the copy in the store).
# * Allow more granular filtering done by the tests (the use of `cleanGit` and `cleanSourceWith`
# in `test/default.nix`). If `flake-compat` copies the whole git repo, any change to the
# repo causes a change of input for all tests.
src = { outPath = ./.; };
override-inputs = sourcesOverride;
}).defaultNix;
inherit (self.inputs.nixpkgs) lib;
# coming from internal.compat
overlays = [ self.overlay ]
++ lib.optional checkMaterialization
(_final: prev: {
haskell-nix = prev.haskell-nix // {
checkMaterialization = true;
};
});
nixpkgsArgs = {
inherit overlays;
inherit (self) config;
};
pkgs = import self.inputs.nixpkgs (nixpkgsArgs // {
localSystem = { inherit system; };
});
in
self // {
inherit nixpkgsArgs pkgs;
inherit (nixpkgsArgs) config overlays;
sources = self.inputs;
allOverlays = self.overlays;
pkgs-2105 = import self.inputs.nixpkgs-2105 (nixpkgsArgs // {
localSystem = { inherit system; };
});
pkgs-2111 = import self.inputs.nixpkgs-2111 (nixpkgsArgs // {
localSystem = { inherit system; };
});
pkgs-2205 = import self.inputs.nixpkgs-2205 (nixpkgsArgs // {
localSystem = { inherit system; };
});
pkgs-2211 = import self.inputs.nixpkgs-2211 (nixpkgsArgs // {
localSystem = { inherit system; };
});
pkgs-2305 = import self.inputs.nixpkgs-2305 (nixpkgsArgs // {
localSystem = { inherit system; };
});
pkgs-unstable = import self.inputs.nixpkgs-unstable (nixpkgsArgs // {
localSystem = { inherit system; };
});
hix = import ./hix/default.nix { inherit pkgs; };
}