@@ -39,11 +39,11 @@ Lets say we want to build `hlint`. We might start with an `hlint`
39file that looks like this:
39file that looks like this:
42−let inherit (import ./. {}) sources nixpkgsArgs;
42+let inherit (import ./. {}) sources nixpkgsArgs;
43 pkgs = import sources.nixpkgs-default nixpkgsArgs;
43 pkgs = import sources.nixpkgs-default nixpkgsArgs;
44 hlint = pkgs.haskell-nix.hackage-package {
44 hlint = pkgs.haskell-nix.hackage-package {
45 name = "hlint";
45 name = "hlint";
46− version = "2.2.4";
46+ version = "2.2.11";
48in hlint.components.exes.hlint
48in hlint.components.exes.hlint
@@ -52,10 +52,10 @@ Building this may result in a lot of output, but if you build
52it again it should give just:
52it again it should give just:
55−$ nix-build hlint.nix
55+$ nix-build hlint.nix
56trace: Using latest index state for hlint!
56trace: Using latest index state for hlint!
57−trace: Using index-state: 2019-12-09T00:00:00Z for hlint
57+trace: Using index-state: 2020-04-15T00:00:00Z for hlint
58−/nix/store/7wwqq5v42gm6iiz2d3ngbnkyw7i4py11-hlint-2.2.4-exe-hlint
58+/nix/store/rnfz66v7k8i38c8rsmchzsyqjrmrbdpk-hlint-2.2.11-exe-hlint
61To materialize the nix files we need to take care to pin down the
61To materialize the nix files we need to take care to pin down the
@@ -63,12 +63,12 @@ inputs. For `cabalProject` and `hackage-package` this means
63we must specify the `index-state` of hackage we want to use:
63we must specify the `index-state` of hackage we want to use:
66−let inherit (import ./. {}) sources nixpkgsArgs;
66+let inherit (import ./. {}) sources nixpkgsArgs;
67− pkgs = import sources.nixpkgs-default nixpkgsArgs;
67+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
68 hlint = pkgs.haskell-nix.hackage-package {
68 hlint = pkgs.haskell-nix.hackage-package {
69 name = "hlint";
69 name = "hlint";
70− version = "2.2.4";
70+ version = "2.2.11";
71− index-state = "2019-12-03T00:00:00Z";
71+ index-state = "2020-04-15T00:00:00Z";
73in hlint.components.exes.hlint
73in hlint.components.exes.hlint
@@ -78,26 +78,26 @@ calculate a suitable sha256 hash to turn the derivation
78containing the nix files into a fixed output derivation:
78containing the nix files into a fixed output derivation:
81−$ nix-build hlint.nix
81+$ nix-build hlint.nix
82−trace: Using index-state: 2019-12-03T00:00:00Z for hlint
82+trace: Using index-state: 2020-04-15T00:00:00Z for hlint
83−trace: Get `plan-sha256` with `nix-hash --base32 --type sha256 /nix/store/qk1fvza1alkvs51vzmpjp2xsg8xklyxk-hlint-plan-to-nix-pkgs/`
83+trace: Get `plan-sha256` with `nix-hash --base32 --type sha256 /nix/store/8z6p4237rin3c6c1lmjwshmj8rdqrhw2-hlint-plan-to-nix-pkgs/`
84−/nix/store/7wwqq5v42gm6iiz2d3ngbnkyw7i4py11-hlint-2.2.4-exe-hlint
84+/nix/store/rnfz66v7k8i38c8rsmchzsyqjrmrbdpk-hlint-2.2.11-exe-hlint
86−$ nix-hash --base32 --type sha256 /nix/store/qk1fvza1alkvs51vzmpjp2xsg8xklyxk-hlint-plan-to-nix-pkgs/
86+$ nix-hash --base32 --type sha256 /nix/store/8z6p4237rin3c6c1lmjwshmj8rdqrhw2-hlint-plan-to-nix-pkgs/
87−1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss
87+02hasr27a994sml1fzf8swb716lm6lgixxr53y0gxkhw437xkck4
90We can add the hash as `plan-sha256` or (`stack-sha256` for
90We can add the hash as `plan-sha256` or (`stack-sha256` for
91`stackProject`)
91`stackProject`)
94−let inherit (import ./. {}) sources nixpkgsArgs;
94+let inherit (import ./. {}) sources nixpkgsArgs;
95− pkgs = import sources.nixpkgs-default nixpkgsArgs;
95+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
96 hlint = pkgs.haskell-nix.hackage-package {
96 hlint = pkgs.haskell-nix.hackage-package {
97 name = "hlint";
97 name = "hlint";
98− version = "2.2.4";
98+ version = "2.2.11";
99− index-state = "2019-12-03T00:00:00Z";
99+ index-state = "2020-04-15T00:00:00Z";
100− plan-sha256 = "1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss";
100+ plan-sha256 = "02hasr27a994sml1fzf8swb716lm6lgixxr53y0gxkhw437xkck4";
102in hlint.components.exes.hlint
102in hlint.components.exes.hlint
@@ -111,22 +111,22 @@ to wait while they are built or downloaded.
111Running nix build again gives us a hint on what we can do next:
111Running nix build again gives us a hint on what we can do next:
114−$ nix-build hlint.nix
114+$ nix-build hlint.nix
115−trace: Using index-state: 2019-12-03T00:00:00Z for hlint
115+trace: Using index-state: 2020-04-15T00:00:00Z for hlint
116−trace: To materialize, point `materialized` to a copy of /nix/store/0xalcphb7ifvy5fc9dpwj40fij6nn5av-hlint-plan-to-nix-pkgs
116+trace: To materialize, point `materialized` to a copy of /nix/store/kk047cqsjvbj4w8psv4l05abdcnyrqdc-hlint-plan-to-nix-pkgs
117−/nix/store/7wwqq5v42gm6iiz2d3ngbnkyw7i4py11-hlint-2.2.4-exe-hlint
117+/nix/store/rnfz66v7k8i38c8rsmchzsyqjrmrbdpk-hlint-2.2.11-exe-hlint
120To capture the nix we can do something like:
120To capture the nix we can do something like:
123−let inherit (import ./. {}) sources nixpkgsArgs;
123+let inherit (import ./. {}) sources nixpkgsArgs;
124− pkgs = import sources.nixpkgs-default nixpkgsArgs;
124+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
125 hlint = pkgs.haskell-nix.hackage-package {
125 hlint = pkgs.haskell-nix.hackage-package {
126 name = "hlint";
126 name = "hlint";
127− version = "2.2.4";
127+ version = "2.2.11";
128− index-state = "2019-12-03T00:00:00Z";
128+ index-state = "2020-04-15T00:00:00Z";
129− plan-sha256 = "1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss";
129+ plan-sha256 = "02hasr27a994sml1fzf8swb716lm6lgixxr53y0gxkhw437xkck4";
130 materialized = ./hlint.materialized;
130 materialized = ./hlint.materialized;
132in hlint.components.exes.hlint
132in hlint.components.exes.hlint
@@ -135,9 +135,9 @@ in hlint.components.exes.hlint
135Now we can copy the nix files needed and build with:
135Now we can copy the nix files needed and build with:
138−$ cp -r /nix/store/0xalcphb7ifvy5fc9dpwj40fij6nn5av-hlint-plan-to-nix-pkgs hlint.materialized
138+$ cp -r /nix/store/8z6p4237rin3c6c1lmjwshmj8rdqrhw2-hlint-plan-to-nix-pkgs hlint.materialized
139−$ nix-build hlint.nix
139+$ nix-build hlint.nix
140−/nix/store/7wwqq5v42gm6iiz2d3ngbnkyw7i4py11-hlint-2.2.4-exe-hlint
140+/nix/store/rnfz66v7k8i38c8rsmchzsyqjrmrbdpk-hlint-2.2.11-exe-hlint
143We may want to run `chmod -R +w hlint.materialized` as the files copied from the
143We may want to run `chmod -R +w hlint.materialized` as the files copied from the
@@ -145,74 +145,44 @@ store will be read only.
146## How can we check `sha256` and `materialized` are up to date?
146## How can we check `sha256` and `materialized` are up to date?
148−Let's pretend we had to go back to `hlint` version `2.2.3`.
148+Let's pretend we had to go back to `hlint` version `2.2.10`.
149−We can change `version` and temporarily add
149+We can tell haskell.nix to check the materialiazation either by:
151+* Removing the materialization files with `rm -rf hlint.materialized`
150−`checkMaterialization = true;`:
152+* Temporarily adding `checkMaterialization = true;`
154+If we choose to add the `checkMaterialization` flag you would have:
153−let inherit (import ./. {}) sources nixpkgsArgs;
157+let inherit (import ./. {}) sources nixpkgsArgs;
154− pkgs = import sources.nixpkgs-default nixpkgsArgs;
158+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
155 hlint = pkgs.haskell-nix.hackage-package {
159 hlint = pkgs.haskell-nix.hackage-package {
156 name = "hlint";
160 name = "hlint";
157− version = "2.2.4";
161+ version = "2.2.10";
158− index-state = "2019-12-03T00:00:00Z";
162+ index-state = "2020-04-15T00:00:00Z";
159− plan-sha256 = "1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss";
163+ plan-sha256 = "02hasr27a994sml1fzf8swb716lm6lgixxr53y0gxkhw437xkck4";
160 materialized = ./hlint.materialized;
164 materialized = ./hlint.materialized;
161 checkMaterialization = true;
165 checkMaterialization = true;
163in hlint.components.exes.hlint
167in hlint.components.exes.hlint
166−This will fail and report the details of what is wrong:
170+This will fail and report the details of what is wrong and how to fix it:
169−$ nix-build hlint.nix
173+$ nix-build hlint.nix
170−trace: Using index-state: 2019-12-03T00:00:00Z for hlint
174+
171−building '/nix/store/zmif4gk52ynh57pf4dikzgsk30haqi2b-hlint-plan-to-nix-pkgs.drv'...
175+...
172−Changes to hlint-plan-to-nix-pkgs not reflected in plan-sha256
176+
173−diff -ru /nix/store/0xalcphb7ifvy5fc9dpwj40fij6nn5av-hlint-plan-to-nix-pkgs/.plan.nix/hlint.nix /nix/store/h5j8k3y5lansyfss25gd7knbninzr6z4-hlint-plan-to-nix-pkgs/.plan.nix/hlint.nix
177+Calculated hash for hlint-plan-to-nix-pkgs was not 02hasr27a994sml1fzf8swb716lm6lgixxr53y0gxkhw437xkck4. New hash is :
174−--- /nix/store/0xalcphb7ifvy5fc9dpwj40fij6nn5av-hlint-plan-to-nix-pkgs/.plan.nix/hlint.nix 1970-01-01 00:00:01.000000000 +0000
178+ plan-sha256 = "0zsi3wv92qax33ic4n5dfsqd1r9qam1k75za3c5jqgdxl3hy8vph";
175−+++ /nix/store/h5j8k3y5lansyfss25gd7knbninzr6z4-hlint-plan-to-nix-pkgs/.plan.nix/hlint.nix 1970-01-01 00:00:01.000000000 +0000
179+Materialized nix used for hlint-plan-to-nix-pkgs incorrect. To fix run :
176−@@ -42,7 +42,7 @@
180+ rm -rf /Users/hamish/iohk/haskell.nix/hlint.materialized
177− flags = { threaded = true; gpl = true; ghc-lib = false; };
181+ cp -r /nix/store/ywdhbx9rzzkfc60c5vzk7cins2hnvkgx-hlint-plan-to-nix-pkgs /Users/hamish/iohk/haskell.nix/hlint.materialized
178− package = {
182+ chmod -R +w /Users/hamish/iohk/haskell.nix/hlint.materialized
179− specVersion = "1.18";
180−- identifier = { name = "hlint"; version = "2.2.4"; };
181−+ identifier = { name = "hlint"; version = "2.2.3"; };
182− license = "BSD-3-Clause";
183− copyright = "Neil Mitchell 2006-2019";
184− maintainer = "Neil Mitchell <ndmitchell@gmail.com>";
186− (hsPkgs."extra" or (buildDepError "extra"))
187− (hsPkgs."refact" or (buildDepError "refact"))
188− (hsPkgs."aeson" or (buildDepError "aeson"))
189−- (hsPkgs."filepattern" or (buildDepError "filepattern"))
190− (hsPkgs."syb" or (buildDepError "syb"))
191− (hsPkgs."mtl" or (buildDepError "mtl"))
192− ] ++ (if !flags.ghc-lib && (compiler.isGhc && (compiler.version).ge "8.8.0") && (compiler.isGhc && (compiler.version).lt "8.9.0")
193−diff -ru /nix/store/0xalcphb7ifvy5fc9dpwj40fij6nn5av-hlint-plan-to-nix-pkgs/default.nix /nix/store/h5j8k3y5lansyfss25gd7knbninzr6z4-hlint-plan-to-nix-pkgs/default.nix
194−--- /nix/store/0xalcphb7ifvy5fc9dpwj40fij6nn5av-hlint-plan-to-nix-pkgs/default.nix 1970-01-01 00:00:01.000000000 +0000
195−+++ /nix/store/h5j8k3y5lansyfss25gd7knbninzr6z4-hlint-plan-to-nix-pkgs/default.nix 1970-01-01 00:00:01.000000000 +0000
197− "tagged".revision = (((hackage."tagged")."0.8.6").revisions).default;
198− "tagged".flags.transformers = true;
199− "tagged".flags.deepseq = true;
200−- "haskell-src-exts".revision = (((hackage."haskell-src-exts")."1.22.0").revisions).default;
201−+ "haskell-src-exts".revision = (((hackage."haskell-src-exts")."1.21.1").revisions).default;
202− "unliftio-core".revision = (((hackage."unliftio-core")."0.1.2.0").revisions).default;
203− "ghc-lib-parser".revision = (((hackage."ghc-lib-parser")."8.8.1").revisions).default;
204− "containers".revision = (((hackage."containers")."0.6.0.1").revisions).default;
206− "hpc".revision = (((hackage."hpc")."0.6.0.3").revisions).default;
207− "filepath".revision = (((hackage."filepath")."1.4.2.1").revisions).default;
208− "process".revision = (((hackage."process")."1.6.5.0").revisions).default;
209−- "filepattern".revision = (((hackage."filepattern")."0.1.1").revisions).default;
210− "libyaml".revision = (((hackage."libyaml")."0.1.1.1").revisions).default;
211− "libyaml".flags.system-libyaml = false;
212− "libyaml".flags.no-unicode = false;
213−Calculated hash is 1qjmhlb4rw6mggs7y57f6zr5zjmkhkx7sn9q8pb18308n5nxgxcs expected hash was 1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss for hlint-plan-to-nix-pkgs
214−builder for '/nix/store/zmif4gk52ynh57pf4dikzgsk30haqi2b-hlint-plan-to-nix-pkgs.drv' failed with exit code 1
183+builder for '/nix/store/a5zmgfjfxahapw0q8hd2da5bg7knqvbx-hlint-plan-to-nix-pkgs.drv' failed with exit code 1
215−error: build of '/nix/store/zmif4gk52ynh57pf4dikzgsk30haqi2b-hlint-plan-to-nix-pkgs.drv' failed
184+error: build of '/nix/store/a5zmgfjfxahapw0q8hd2da5bg7knqvbx-hlint-plan-to-nix-pkgs.drv' failed
185+(use '--show-trace' to show detailed location information)
218Checking the materialization requires nix to do all the work that materialization
188Checking the materialization requires nix to do all the work that materialization
@@ -228,21 +198,21 @@ hash and materialized nix we can find out what nix files should be.
228For instance:
198For instance:
231−let inherit (import ./. {}) sources nixpkgsArgs;
201+let inherit (import ./. {}) sources nixpkgsArgs;
232− pkgs = import sources.nixpkgs-default nixpkgsArgs;
202+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
233 hlint = pkgs.haskell-nix.hackage-project {
203 hlint = pkgs.haskell-nix.hackage-project {
234 name = "hlint";
204 name = "hlint";
235− version = "2.2.4";
205+ version = "2.2.10";
236− index-state = "2019-12-03T00:00:00Z";
206+ index-state = "2020-04-15T00:00:00Z";
242$ nix-build hlint.nix -A plan-nix
212$ nix-build hlint.nix -A plan-nix
243−trace: Using index-state: 2019-12-03T00:00:00Z for hlint
213+trace: Using index-state: 2020-04-15T00:00:00Z for hlint
244−trace: Get `plan-sha256` with `nix-hash --base32 --type sha256 /nix/store/qk1fvza1alkvs51vzmpjp2xsg8xklyxk-hlint-plan-to-nix-pkgs/`
214+trace: Get `plan-sha256` with `nix-hash --base32 --type sha256 /nix/store/ywdhbx9rzzkfc60c5vzk7cins2hnvkgx-hlint-plan-to-nix-pkgs/`
245−/nix/store/qk1fvza1alkvs51vzmpjp2xsg8xklyxk-hlint-plan-to-nix-pkgs
215+/nix/store/ywdhbx9rzzkfc60c5vzk7cins2hnvkgx-hlint-plan-to-nix-pkgs
248We can have the script copy `$(nix-build hlint.nix -A plan-nix --no-out-link)`
218We can have the script copy `$(nix-build hlint.nix -A plan-nix --no-out-link)`
@@ -257,17 +227,23 @@ Yes and it gives us the same speed improvement, however:
257* Users will still wind up building or downloading the dependencies
227* Users will still wind up building or downloading the dependencies
258 needed to build the nix fileds (if they do not have them).
228 needed to build the nix fileds (if they do not have them).
260−For instance:
230+For those reasons it might be best to make a copy instead
231+of using the `/nix/store/...` path directly.
233+If you really want to use the `/nix/store/...` path directly
234+you should gaurd against the path not existing as passing in
235+a non-existing path is now an error:
263−let inherit (import ./. {}) sources nixpkgsArgs;
238+let inherit (import ./. {}) sources nixpkgsArgs;
264− pkgs = import sources.nixpkgs-default nixpkgsArgs;
239+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
240+ hlintPlan = /nix/store/kk047cqsjvbj4w8psv4l05abdcnyrqdc-hlint-plan-to-nix-pkgs;
265 hlint = pkgs.haskell-nix.hackage-package {
241 hlint = pkgs.haskell-nix.hackage-package {
266 name = "hlint";
242 name = "hlint";
267− version = "2.2.4";
243+ version = "2.2.11";
268− index-state = "2019-12-03T00:00:00Z";
244+ index-state = "2020-04-15T00:00:00Z";
269− plan-sha256 = "1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss";
245+ plan-sha256 = "02hasr27a994sml1fzf8swb716lm6lgixxr53y0gxkhw437xkck4";
270− materialized = /nix/store/qk1fvza1alkvs51vzmpjp2xsg8xklyxk-hlint-plan-to-nix-pkgs;
246+ materialized = if __pathExists hlintPlan then hlintPlan else null;
272in hlint.components.exes.hlint
248in hlint.components.exes.hlint
@@ -275,17 +251,17 @@ in hlint.components.exes.hlint
275Running when no building is needed is still slow in restricted evaluation mode.
251Running when no building is needed is still slow in restricted evaluation mode.
278−$ time nix-build --option restrict-eval true -I . --option allowed-uris "https://github.com/NixOS https://github.com/input-output-hk" hlint.nix
254+$ time nix-build --option restrict-eval true -I . --option allowed-uris "https://github.com/NixOS https://github.com/input-output-hk" hlint.nix --show-trace
279−trace: Using index-state: 2019-12-03T00:00:00Z for hlint
255+trace: Using index-state: 2020-04-15T00:00:00Z for hlint
280−/nix/store/7wwqq5v42gm6iiz2d3ngbnkyw7i4py11-hlint-2.2.4-exe-hlint
256+/nix/store/rnfz66v7k8i38c8rsmchzsyqjrmrbdpk-hlint-2.2.11-exe-hlint
282−real 0m10.066s
258+real 0m4.463s
283−user 0m8.563s
259+user 0m4.440s
284−sys 0m0.630s
260+sys 0m0.461s
285−$ time nix-build hlint.nix
261+$ time nix-build hlint.nix
286−/nix/store/7wwqq5v42gm6iiz2d3ngbnkyw7i4py11-hlint-2.2.4-exe-hlint
262+/nix/store/rnfz66v7k8i38c8rsmchzsyqjrmrbdpk-hlint-2.2.11-exe-hlint
288−real 0m4.628s
264+real 0m2.206s
289−user 0m3.889s
265+user 0m1.665s
290−sys 0m0.389s
266+sys 0m0.332s