@@ -39,10 +39,13 @@ Lets say we want to build `hlint`. We might start with an `hlint`
3939file that looks like this:
4040
4141```nix
42−((import ./nixpkgs (import ./.)).haskell-nix.hackage-package {
43− name = "hlint";
44− version = "2.2.4";
45−}).components.exes.hlint
42+let inherit (import ./. {}) sources nixpkgsArgs;
43+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
44+ hlint = pkgs.haskell-nix.hackage-package {
45+ name = "hlint";
46+ version = "2.2.4";
47+ };
48+in hlint.components.exes.hlint
4649```
4750
4851Building this may result in a lot of output, but if you build
@@ -60,11 +63,14 @@ inputs. For `cabalProject` and `hackage-package` this means
6063we must specify the `index-state` of hackage we want to use:
6164
6265```nix
63−((import ./nixpkgs (import ./.)).haskell-nix.hackage-package {
64− name = "hlint";
65− version = "2.2.4";
66− index-state = "2019-12-03T00:00:00Z";
67−}).components.exes.hlint
66+let inherit (import ./. {}) sources nixpkgsArgs;
67+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
68+ hlint = pkgs.haskell-nix.hackage-package {
69+ name = "hlint";
70+ version = "2.2.4";
71+ index-state = "2019-12-03T00:00:00Z";
72+ };
73+in hlint.components.exes.hlint
6874```
6975
7076Now if we build again we get a hint telling use how to
@@ -85,12 +91,15 @@ We can add the hash as `plan-sha256` or (`stack-sha256` for
8591`stackProject`)
8692
8793```nix
88−((import ./nixpkgs (import ./.)).haskell-nix.hackage-package {
89− name = "hlint";
90− version = "2.2.4";
91− index-state = "2019-12-03T00:00:00Z";
92− plan-sha256 = "1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss";
93−}).components.exes.hlint
94+let inherit (import ./. {}) sources nixpkgsArgs;
95+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
96+ hlint = pkgs.haskell-nix.hackage-package {
97+ name = "hlint";
98+ version = "2.2.4";
99+ index-state = "2019-12-03T00:00:00Z";
100+ plan-sha256 = "1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss";
101+ };
102+in hlint.components.exes.hlint
94103```
95104
96105Just adding the hash might help reuse of the cached nix, but nix will
@@ -111,13 +120,16 @@ trace: To materialize, point `materialized` to a copy of /nix/store/0xalcphb7ifv
111120To capture the nix we can do something like:
112121
113122```nix
114−((import ./nixpkgs (import ./.)).haskell-nix.hackage-package {
115− name = "hlint";
116− version = "2.2.4";
117− index-state = "2019-12-03T00:00:00Z";
118− plan-sha256 = "1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss";
119− materialized = ./hlint.materialized;
120−}).components.exes.hlint
123+let inherit (import ./. {}) sources nixpkgsArgs;
124+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
125+ hlint = pkgs.haskell-nix.hackage-package {
126+ name = "hlint";
127+ version = "2.2.4";
128+ index-state = "2019-12-03T00:00:00Z";
129+ plan-sha256 = "1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss";
130+ materialized = ./hlint.materialized;
131+ };
132+in hlint.components.exes.hlint
121133```
122134
123135Now we can copy the nix files needed and build with:
@@ -138,14 +150,17 @@ We can change `version` and temporarily add
138150`checkMaterialization = true;`:
139151
140152```nix
141−((import ./nixpkgs (import ./.)).haskell-nix.hackage-package {
142− name = "hlint";
143− version = "2.2.3";
144− index-state = "2019-12-03T00:00:00Z";
145− plan-sha256 = "1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss";
146− materialized = ./hlint.materialized;
147− checkMaterialization = true;
148−}).components.exes.hlint
153+let inherit (import ./. {}) sources nixpkgsArgs;
154+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
155+ hlint = pkgs.haskell-nix.hackage-package {
156+ name = "hlint";
157+ version = "2.2.4";
158+ index-state = "2019-12-03T00:00:00Z";
159+ plan-sha256 = "1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss";
160+ materialized = ./hlint.materialized;
161+ checkMaterialization = true;
162+ };
163+in hlint.components.exes.hlint
149164```
150165
151166This will fail and report the details of what is wrong:
@@ -213,11 +228,14 @@ hash and materialized nix we can find out what nix files should be.
213228For instance:
214229
215230```nix
216−(import ./nixpkgs (import ./.)).haskell-nix.hackage-project {
217− name = "hlint";
218− version = "2.2.4";
219− index-state = "2019-12-03T00:00:00Z";
220−}
231+let inherit (import ./. {}) sources nixpkgsArgs;
232+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
233+ hlint = pkgs.haskell-nix.hackage-project {
234+ name = "hlint";
235+ version = "2.2.4";
236+ index-state = "2019-12-03T00:00:00Z";
237+ };
238+in hlint
221239```
222240
223241```
@@ -242,13 +260,16 @@ Yes and it gives us the same speed improvement, however:
242260For instance:
243261
244262```nix
245−((import ./nixpkgs (import ./.)).haskell-nix.hackage-package {
246− name = "hlint";
247− version = "2.2.4";
248− index-state = "2019-12-03T00:00:00Z";
249− plan-sha256 = "1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss";
250− materialized = /nix/store/qk1fvza1alkvs51vzmpjp2xsg8xklyxk-hlint-plan-to-nix-pkgs;
251−}).components.exes.hlint
263+let inherit (import ./. {}) sources nixpkgsArgs;
264+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
265+ hlint = pkgs.haskell-nix.hackage-package {
266+ name = "hlint";
267+ version = "2.2.4";
268+ index-state = "2019-12-03T00:00:00Z";
269+ plan-sha256 = "1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss";
270+ materialized = /nix/store/qk1fvza1alkvs51vzmpjp2xsg8xklyxk-hlint-plan-to-nix-pkgs;
271+ };
272+in hlint.components.exes.hlint
252273```
253274
254275Running when no building is needed is still slow in restricted evaluation mode.