on iko/ghcjs-patch-master help sign in
Expose our nixpkgs pins by restructuring default.nix (#514)
eb15db0Michael Peyton Jones
@@ -20,13 +20,26 @@ For the documentation, see https://input-output-hk.github.io/haskell.nix/.
20For =cabal.project= project add a =default.nix=:
20For =cabal.project= project add a =default.nix=:
21
21
22#+begin_src sh
22#+begin_src sh
23+let
24+ # Fetch the latest haskell.nix and import its default.nix
23−{ pkgs ? import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz))
25+ haskellNix = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {};
26+ # haskell.nix provides access to the nixpkgs pins which are used by our CI, hence
27+ # you will be more likely to get cache hits when using these.
28+ # But you can also just use your own, e.g. '<nixpkgs>'
29+ nixpkgsSrc = haskellNix.sources.nixpkgs-1909;
30+ # haskell.nix provides some arguments to be passed to nixpkgs, including some patches
31+ # and also the haskell.nix functionality itself as an overlay.
32+ nixpkgsArgs = haskellNix.nixpkgsArgs;
33+in
34+{ pkgs ? import nixpkgsSrc nixpkgsArgs
24, haskellCompiler ? "ghc865"
35, haskellCompiler ? "ghc865"
25}:
36}:
37+# 'cabalProject' generates a package set based on a cabal.project (and the corresponding .cabal files)
26− pkgs.haskell-nix.cabalProject {
38+pkgs.haskell-nix.cabalProject {
39+ # 'cleanGit' cleans a source directory based on the files known by git
27− src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
40+ src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
28− ghc = pkgs.buildPackages.pkgs.haskell-nix.compiler.${haskellCompiler};
41+ ghc = pkgs.buildPackages.pkgs.haskell-nix.compiler.${haskellCompiler};
29− }
42+}
30#+end_src
43#+end_src
31
44
32Note that you'll need to add a comment specifying the expected sha256
45Note that you'll need to add a comment specifying the expected sha256
@@ -45,11 +58,16 @@ source-repository-package
45For a =stack.yaml= project add a =default.nix=:
58For a =stack.yaml= project add a =default.nix=:
46
59
47#+begin_src sh
60#+begin_src sh
61+let
48−{ pkgs ? import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz))
62+ haskellNix = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {};
63+ nixpkgsSrc = haskellNix.sources.nixpkgs-1909;
64+ nixpkgsArgs = haskellNix.nixpkgsArgs;
65+in
66+{ pkgs ? import nixpkgsSrc nixpkgsArgs
49}:
67}:
50− pkgs.haskell-nix.stackProject {
68+pkgs.haskell-nix.stackProject {
51− src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
69+ src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
52− }
70+}
53#+end_src
71#+end_src
54
72
55To build the library component of a package in the project run:
73To build the library component of a package in the project run:
build.nix+7−5
@@ -2,10 +2,12 @@
2#
2#
3# It is separate from default.nix because that file is the public API
3# It is separate from default.nix because that file is the public API
4# of Haskell.nix, which shouldn't have tests, etc.
4# of Haskell.nix, which shouldn't have tests, etc.
5−
5+let
6−{ nixpkgs ? (import ./nixpkgs/default.nix)
6+ haskellNix = (import ./default.nix {});
7−, nixpkgsArgs ? (import ./default.nix)
7+in
8+{ nixpkgs ? haskellNix.sources.nixpkgs-default
9+, nixpkgsArgs ? haskellNix.nixpkgsArgs
8−, pkgs ? (nixpkgs nixpkgsArgs)
10+, pkgs ? import nixpkgs nixpkgsArgs
9, ifdLevel ? 1000
11, ifdLevel ? 1000
10}:
12}:
11
13
@@ -27,7 +29,7 @@ in rec {
27 # nixpkgs 19.09 changes "Option has no description" from an
29 # nixpkgs 19.09 changes "Option has no description" from an
28 # error into a warning. That is quite helpful when hardly any
30 # error into a warning. That is quite helpful when hardly any
29 # of our options are documented, thanks @oxij.
31 # of our options are documented, thanks @oxij.
30− pkgs = import ./nixpkgs { nixpkgs-pin = "release-19.09"; };
32+ pkgs = import (import ./nixpkgs/default.nix).nixpkgs-1909 {};
31 };
33 };
32 };
34 };
33 # Because this is going to be used to test caching on hydra, it must not
35 # Because this is going to be used to test caching on hydra, it must not
builder/default.nix+1−1
@@ -40,7 +40,7 @@ let
40
40
41 hoogleLocal = let
41 hoogleLocal = let
42 # Use the latest default nixpkgs hoogle.nix, as the 19.03 one does not work with cross compilers
42 # Use the latest default nixpkgs hoogle.nix, as the 19.03 one does not work with cross compilers
43− nixpkgsHoogleLocal = import ((import ../nixpkgs {}).path + /pkgs/development/haskell-modules/hoogle.nix);
43+ nixpkgsHoogleLocal = import ((import (import ../nixpkgs).nixpkgs-default {}).path + /pkgs/development/haskell-modules/hoogle.nix);
44 in { packages ? [], hoogle ? pkgs.buildPackages.haskell-nix.haskellPackages.hoogle.components.exes.hoogle }:
44 in { packages ? [], hoogle ? pkgs.buildPackages.haskell-nix.haskellPackages.hoogle.components.exes.hoogle }:
45 haskellLib.weakCallPackage pkgs nixpkgsHoogleLocal {
45 haskellLib.weakCallPackage pkgs nixpkgsHoogleLocal {
46 # For musl we can use haddock from the buildGHC
46 # For musl we can use haddock from the buildGHC
ci-lib.nix+1−1
@@ -1,6 +1,6 @@
1let
1let
2 # Generic nixpkgs, use *only* for lib functions that are stable across versions
2 # Generic nixpkgs, use *only* for lib functions that are stable across versions
3− pkgs = import ./nixpkgs/default.nix {};
3+ pkgs = import (import ./nixpkgs/default.nix).nixpkgs-default {};
4 lib = pkgs.lib;
4 lib = pkgs.lib;
5in rec {
5in rec {
6 inherit (import ./dimension.nix) dimension;
6 inherit (import ./dimension.nix) dimension;
ci.nix+8−7
@@ -6,9 +6,10 @@
6, restrictEval ? false }:
6, restrictEval ? false }:
7let
7let
8 inherit (import ./ci-lib.nix) dimension platformFilterGeneric filterAttrsOnlyRecursive;
8 inherit (import ./ci-lib.nix) dimension platformFilterGeneric filterAttrsOnlyRecursive;
9+ inherit (import ./default.nix {}) sources nixpkgsArgs;
9 nixpkgsVersions = {
10 nixpkgsVersions = {
10− "R1903" = "release-19.03";
11+ "R1903" = "nixpkgs-1903";
11− "R1909" = "release-19.09";
12+ "R1909" = "nixpkgs-1909";
12 };
13 };
13 systems = nixpkgs: nixpkgs.lib.filterAttrs (_: v: builtins.elem v supportedSystems) {
14 systems = nixpkgs: nixpkgs.lib.filterAttrs (_: v: builtins.elem v supportedSystems) {
14 # I wanted to take these from 'lib.systems.examples', but apparently there isn't one for linux!
15 # I wanted to take these from 'lib.systems.examples', but apparently there isn't one for linux!
@@ -27,13 +28,13 @@ let
27 # aarch64 cross only works on linux
28 # aarch64 cross only works on linux
28 inherit (lib.systems.examples) musl64 aarch64-multiplatform;
29 inherit (lib.systems.examples) musl64 aarch64-multiplatform;
29 };
30 };
30− haskellNixArgs = import ./.;
31in
31in
32dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: nixpkgs-pin:
32dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: nixpkgs-pin:
33+ let pinnedNixpkgsSrc = sources.${nixpkgs-pin};
33− # We need this for generic nixpkgs stuff at the right version
34+ # We need this for generic nixpkgs stuff at the right version
34− let genericPkgs = import ./nixpkgs { inherit nixpkgs-pin; };
35+ genericPkgs = import pinnedNixpkgsSrc {};
35 in dimension "System" (systems genericPkgs) (systemName: system:
36 in dimension "System" (systems genericPkgs) (systemName: system:
36− let pkgs = import ./nixpkgs (haskellNixArgs // { inherit nixpkgs-pin system; });
37+ let pkgs = import pinnedNixpkgsSrc (nixpkgsArgs // { inherit system; });
37 build = import ./build.nix { inherit pkgs ifdLevel; };
38 build = import ./build.nix { inherit pkgs ifdLevel; };
38 platformFilter = platformFilterGeneric pkgs system;
39 platformFilter = platformFilterGeneric pkgs system;
39 in filterAttrsOnlyRecursive (_: v: platformFilter v) {
40 in filterAttrsOnlyRecursive (_: v: platformFilter v) {
@@ -49,7 +50,7 @@ dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: nixpkgs-pin:
49 //
50 //
50 dimension "Cross system" (crossSystems nixpkgsName genericPkgs system) (crossSystemName: crossSystem:
51 dimension "Cross system" (crossSystems nixpkgsName genericPkgs system) (crossSystemName: crossSystem:
51 # Cross builds
52 # Cross builds
52− let pkgs = import ./nixpkgs (haskellNixArgs // { inherit nixpkgs-pin system crossSystem; });
53+ let pkgs = import pinnedNixpkgsSrc (nixpkgsArgs // { inherit system crossSystem; });
53 build = import ./build.nix { inherit pkgs ifdLevel; };
54 build = import ./build.nix { inherit pkgs ifdLevel; };
54 in pkgs.recurseIntoAttrs {
55 in pkgs.recurseIntoAttrs {
55 hello = (pkgs.haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2"; }).components.exes.hello;
56 hello = (pkgs.haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2"; }).components.exes.hello;
default.nix+24−5
@@ -1,5 +1,24 @@
1−# This default.nix is designed to be passed directly nixpkgs with something like:
1+let haskellNix = rec {
2−# import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz))
2+ sources = {
3−{ config = import ./config.nix;
3+ inherit (import ./nixpkgs/default.nix) nixpkgs-1903 nixpkgs-1909 nixpkgs-default;
4− overlays = import ./overlays;
4+ };
5+
6+ config = import ./config.nix;
7+ overlays = import ./overlays;
8+ nixpkgsArgs = { inherit overlays config; };
9+ };
10+
11+ haskellNixV1 = haskellNix.nixpkgsArgs;
12+ haskellNixV2 = haskellNix;
13+
14+ v1DeprecationMessage = "Version 1 is deprecated: use version 2 (nixpkgs arguments are available as the `nixpkgsArgs` attribute of version 2)";
15+# If no arguments, then you get V1
16+# I'd like to make importing directly issue a warning, but I couldn't figure out a way to make it happen
17+in haskellNixV1 // {
18+ __functor = _: { version ? 2 }:
19+ if version == 1
20+ then builtins.trace v1DeprecationMessage haskellNixV1
21+ else if version == 2
22+ then haskellNixV2
23+ else builtins.throw ("haskell.nix: unknown version: " + (builtins.toString version));
5−}
24+}
docs/user-guide.md+9−9
@@ -7,7 +7,7 @@
7To build a package, say [lens][], from a stackage snapshot, say [lts-13.28][],
7To build a package, say [lens][], from a stackage snapshot, say [lts-13.28][],
8you could run
8you could run
9```bash
9```bash
10−nix build '(with import <nixpkgs> (import ./.); haskell-nix.snapshots."lts-13.28").lens.components.library'
10+nix build '(with import <nixpkgs> (import ./. {}).nixpkgsArgs; haskell-nix.snapshots."lts-13.28").lens.components.library'
11```
11```
12which would build the [lens][] library component from the lens package as fixed
12which would build the [lens][] library component from the lens package as fixed
13by the [lts-13.28][] stackage snapshot.
13by the [lts-13.28][] stackage snapshot.
@@ -15,14 +15,14 @@ by the [lts-13.28][] stackage snapshot.
15To build any package from hackage, say [lens][], in version, say 4.17.1, you
15To build any package from hackage, say [lens][], in version, say 4.17.1, you
16could run
16could run
17```bash
17```bash
18−nix build '(with import <nixpkgs> (import ./.); (haskell-nix.hackage-package { name = "lens"; version = "4.17.1"; })).components.library'
18+nix build '(with import <nixpkgs> (import ./. {}).nixpkgsArgs; (haskell-nix.hackage-package { name = "lens"; version = "4.17.1"; })).components.library'
19```
19```
20which would build the [lens][] library component from the [lens-4.17.1][] package
20which would build the [lens][] library component from the [lens-4.17.1][] package
21from hackage. The dependencies would be solved against the most recent
21from hackage. The dependencies would be solved against the most recent
22[hackage-index-state][] that comes via the [hackage.nix][] pin with your
22[hackage-index-state][] that comes via the [hackage.nix][] pin with your
23[haskell.nix][] checkout. A specific one can be specified as well:
23[haskell.nix][] checkout. A specific one can be specified as well:
24```bash
24```bash
25−nix build '(with import <nixpkgs> (import ./.); (haskell-nix.hackage-package { name = "lens"; version = "4.17.1"; index-state = "2019-07-14T00:00:00Z"; })).components.library'
25+nix build '(with import <nixpkgs> (import ./. {}).nixpkgsArgs; (haskell-nix.hackage-package { name = "lens"; version = "4.17.1"; index-state = "2019-07-14T00:00:00Z"; })).components.library'
26```
26```
27which would use the hackage index as of `2019-07-14T00:00:00Z` to produce a build plan
27which would use the hackage index as of `2019-07-14T00:00:00Z` to produce a build plan
28for the [lens-4.17.1][] package.
28for the [lens-4.17.1][] package.
@@ -49,7 +49,7 @@ produce derivations that we can `nix build`.
49To build the latest `nix-tools` and store the result at `./nt`, run:
49To build the latest `nix-tools` and store the result at `./nt`, run:
50
50
51```bash
51```bash
52−nix build '(with import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz)); haskell-nix.nix-tools)' --out-link nt
52+nix build '(with import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {}).nixpkgsArgs; haskell-nix.nix-tools)' --out-link nt
53```
53```
54
54
55If you would like to then install `nix-tools` into your profile, run:
55If you would like to then install `nix-tools` into your profile, run:
@@ -85,7 +85,7 @@ The easiest way to get a hold of [Haskell.nix][] is with
85[`fetchTarball`](https://nixos.org/nix/manual/#ssec-builtins).
85[`fetchTarball`](https://nixos.org/nix/manual/#ssec-builtins).
86
86
87```nix
87```nix
88−import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz))
88+import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {}).nixpkgsArgs
89```
89```
90
90
91### Using your cabal.project file
91### Using your cabal.project file
@@ -93,7 +93,7 @@ import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-
93If your project has a `cabal.project` you can add a `default.nix` like this:
93If your project has a `cabal.project` you can add a `default.nix` like this:
94
94
95```nix
95```nix
96−{ pkgs ? import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz))
96+{ pkgs ? import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {}).nixpkgsArgs
97, haskellCompiler ? "ghc865"
97, haskellCompiler ? "ghc865"
98}:
98}:
99 pkgs.haskell-nix.cabalProject {
99 pkgs.haskell-nix.cabalProject {
@@ -173,7 +173,7 @@ or one of the constraints in your local `.cabal` files).
173If your project has a `stack.yaml` you can add a `default.nix` like this:
173If your project has a `stack.yaml` you can add a `default.nix` like this:
174
174
175```nix
175```nix
176−{ pkgs ? import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz))
176+{ pkgs ? import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {}).nixpkgsArgs
177}:
177}:
178 pkgs.haskell-nix.stackProject {
178 pkgs.haskell-nix.stackProject {
179 src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
179 src = pkgs.haskell-nix.haskellLib.cleanGit { src = ./.; };
@@ -269,7 +269,7 @@ these Git repositories correspond to the actual Hackage and Stackage.
269 stackageSourceJSON = ./stackage-src.json;
269 stackageSourceJSON = ./stackage-src.json;
270 };
270 };
271 })]; })
271 })]; })
272−, haskellNixArgs ? import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz)
272+, haskellNixArgs ? (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {}).nixpkgsArgs
273}:
273}:
274 pkgs
274 pkgs
275```
275```
@@ -283,7 +283,7 @@ attrsets and try examples.
283# example.nix
283# example.nix
284{ nixpkgs ? <nixpkgs> }:
284{ nixpkgs ? <nixpkgs> }:
285rec {
285rec {
286− haskell = import nixpkgs (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz));
286+ haskell = import nixpkgs (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {}).nixpkgsArgs;
287 pkgNames = haskell.pkgs.lib.attrNames haskell.haskell-nix.snapshots."lts-13.18";
287 pkgNames = haskell.pkgs.lib.attrNames haskell.haskell-nix.snapshots."lts-13.18";
288}
288}
289```
289```
docs/user-guide/cabal-projects.md+2−2
@@ -81,8 +81,8 @@ instantiate a package set.
81# default.nix
81# default.nix
82let
82let
83 # Import the Haskell.nix library,
83 # Import the Haskell.nix library,
84− src = builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz;
84+ haskellNix = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {};
85− nixpkgs = import (src + "/nixpkgs") (import src);
85+ nixpkgs = haskellNix.sources.nixpgs-1909 haskellNix.nixpkgsArgs;
86 haskell = nixpkgs.haskell-nix;
86 haskell = nixpkgs.haskell-nix;
87
87
88 # Instantiate a package set using the generated file.
88 # Instantiate a package set using the generated file.
docs/user-guide/development.md+4−4
@@ -108,8 +108,8 @@ selects packages from the larger package set.
108```nix
108```nix
109# shell.nix
109# shell.nix
110let
110let
111− src = builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz;
111+ haskellNix = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {};
112− nixpkgs = import (src + "/nixpkgs") (import src);
112+ nixpkgs = haskellNix.sources.nixpkgs-1909 haskellNix.nixpkgsArgs;
113 haskell = nixpkgs.haskell-nix;
113 haskell = nixpkgs.haskell-nix;
114in
114in
115 haskell.haskellPackages.ghcWithPackages (ps: with ps;
115 haskell.haskellPackages.ghcWithPackages (ps: with ps;
@@ -127,8 +127,8 @@ project.
127
127
128```nix
128```nix
129let
129let
130− src = builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz;
130+ haskellNix = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {};
131− nixpkgs = import (src + "/nixpkgs") (import src);
131+ nixpkgs = haskellNix.sources.nixpkgs-1909 haskellNix.nixpkgsArgs;
132 haskell = nixpkgs.haskell-nix;
132 haskell = nixpkgs.haskell-nix;
133in
133in
134 haskell.snapshots."lts-13.18".alex.components.exes.alex
134 haskell.snapshots."lts-13.18".alex.components.exes.alex
docs/user-guide/materialization.md+63−42
@@ -39,10 +39,13 @@ Lets say we want to build `hlint`. We might start with an `hlint`
39file that looks like this:
39file that looks like this:
40
40
41```nix
41```nix
42+let inherit (import ./. {}) sources nixpkgsArgs;
43+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
42−((import ./nixpkgs (import ./.)).haskell-nix.hackage-package {
44+ hlint = pkgs.haskell-nix.hackage-package {
43− name = "hlint";
45+ name = "hlint";
44− version = "2.2.4";
46+ version = "2.2.4";
47+ };
45−}).components.exes.hlint
48+in hlint.components.exes.hlint
46```
49```
47
50
48Building this may result in a lot of output, but if you build
51Building this may result in a lot of output, but if you build
@@ -60,11 +63,14 @@ inputs. For `cabalProject` and `hackage-package` this means
60we must specify the `index-state` of hackage we want to use:
63we must specify the `index-state` of hackage we want to use:
61
64
62```nix
65```nix
66+let inherit (import ./. {}) sources nixpkgsArgs;
67+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
63−((import ./nixpkgs (import ./.)).haskell-nix.hackage-package {
68+ hlint = pkgs.haskell-nix.hackage-package {
64− name = "hlint";
69+ name = "hlint";
65− version = "2.2.4";
70+ version = "2.2.4";
66− index-state = "2019-12-03T00:00:00Z";
71+ index-state = "2019-12-03T00:00:00Z";
72+ };
67−}).components.exes.hlint
73+in hlint.components.exes.hlint
68```
74```
69
75
70Now if we build again we get a hint telling use how to
76Now 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
85`stackProject`)
91`stackProject`)
86
92
87```nix
93```nix
94+let inherit (import ./. {}) sources nixpkgsArgs;
95+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
88−((import ./nixpkgs (import ./.)).haskell-nix.hackage-package {
96+ hlint = pkgs.haskell-nix.hackage-package {
89− name = "hlint";
97+ name = "hlint";
90− version = "2.2.4";
98+ version = "2.2.4";
91− index-state = "2019-12-03T00:00:00Z";
99+ index-state = "2019-12-03T00:00:00Z";
92− plan-sha256 = "1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss";
100+ plan-sha256 = "1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss";
101+ };
93−}).components.exes.hlint
102+in hlint.components.exes.hlint
94```
103```
95
104
96Just adding the hash might help reuse of the cached nix, but nix will
105Just 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
111To capture the nix we can do something like:
120To capture the nix we can do something like:
112
121
113```nix
122```nix
123+let inherit (import ./. {}) sources nixpkgsArgs;
124+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
114−((import ./nixpkgs (import ./.)).haskell-nix.hackage-package {
125+ hlint = pkgs.haskell-nix.hackage-package {
115− name = "hlint";
126+ name = "hlint";
116− version = "2.2.4";
127+ version = "2.2.4";
117− index-state = "2019-12-03T00:00:00Z";
128+ index-state = "2019-12-03T00:00:00Z";
118− plan-sha256 = "1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss";
129+ plan-sha256 = "1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss";
119− materialized = ./hlint.materialized;
130+ materialized = ./hlint.materialized;
131+ };
120−}).components.exes.hlint
132+in hlint.components.exes.hlint
121```
133```
122
134
123Now we can copy the nix files needed and build with:
135Now we can copy the nix files needed and build with:
@@ -138,14 +150,17 @@ We can change `version` and temporarily add
138`checkMaterialization = true;`:
150`checkMaterialization = true;`:
139
151
140```nix
152```nix
153+let inherit (import ./. {}) sources nixpkgsArgs;
154+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
141−((import ./nixpkgs (import ./.)).haskell-nix.hackage-package {
155+ hlint = pkgs.haskell-nix.hackage-package {
142− name = "hlint";
156+ name = "hlint";
143− version = "2.2.3";
157+ version = "2.2.4";
144− index-state = "2019-12-03T00:00:00Z";
158+ index-state = "2019-12-03T00:00:00Z";
145− plan-sha256 = "1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss";
159+ plan-sha256 = "1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss";
146− materialized = ./hlint.materialized;
160+ materialized = ./hlint.materialized;
147− checkMaterialization = true;
161+ checkMaterialization = true;
162+ };
148−}).components.exes.hlint
163+in hlint.components.exes.hlint
149```
164```
150
165
151This will fail and report the details of what is wrong:
166This 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.
213For instance:
228For instance:
214
229
215```nix
230```nix
231+let inherit (import ./. {}) sources nixpkgsArgs;
232+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
216−(import ./nixpkgs (import ./.)).haskell-nix.hackage-project {
233+ hlint = pkgs.haskell-nix.hackage-project {
217− name = "hlint";
234+ name = "hlint";
218− version = "2.2.4";
235+ version = "2.2.4";
219− index-state = "2019-12-03T00:00:00Z";
236+ index-state = "2019-12-03T00:00:00Z";
220−}
237+ };
238+in hlint
221```
239```
222
240
223```
241```
@@ -242,13 +260,16 @@ Yes and it gives us the same speed improvement, however:
242For instance:
260For instance:
243
261
244```nix
262```nix
263+let inherit (import ./. {}) sources nixpkgsArgs;
264+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
245−((import ./nixpkgs (import ./.)).haskell-nix.hackage-package {
265+ hlint = pkgs.haskell-nix.hackage-package {
246− name = "hlint";
266+ name = "hlint";
247− version = "2.2.4";
267+ version = "2.2.4";
248− index-state = "2019-12-03T00:00:00Z";
268+ index-state = "2019-12-03T00:00:00Z";
249− plan-sha256 = "1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss";
269+ plan-sha256 = "1a4rhv3h2daz6dzwzfl3w7l1v556n7aqfiagw6m0rvqq230iabss";
250− materialized = /nix/store/qk1fvza1alkvs51vzmpjp2xsg8xklyxk-hlint-plan-to-nix-pkgs;
270+ materialized = /nix/store/qk1fvza1alkvs51vzmpjp2xsg8xklyxk-hlint-plan-to-nix-pkgs;
271+ };
251−}).components.exes.hlint
272+in hlint.components.exes.hlint
252```
273```
253
274
254Running when no building is needed is still slow in restricted evaluation mode.
275Running when no building is needed is still slow in restricted evaluation mode.
docs/user-guide/projects.md+1−1
@@ -22,7 +22,7 @@ expression (see the links bellow). The following file then produces a package se
22# default.nix
22# default.nix
23let
23let
24 # Import the Haskell.nix library,
24 # Import the Haskell.nix library,
25− pkgs = import <nixpkgs> (import builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz);
25+ pkgs = import <nixpkgs> (import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {}).nixpkgsArgs;
26
26
27 # Import the file you will create in the stack-to-nix or cabal-to-nix step.
27 # Import the file you will create in the stack-to-nix or cabal-to-nix step.
28 my-pkgs = import ./pkgs.nix;
28 my-pkgs = import ./pkgs.nix;
docs/user-guide/stack-projects.md+2−2
@@ -43,8 +43,8 @@ instantiate a package set.
43# default.nix
43# default.nix
44let
44let
45 # Import the Haskell.nix library,
45 # Import the Haskell.nix library,
46− src = builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz;
46+ haskellNix = import (builtins.fetchTarball https://github.com/input-output-hk/haskell.nix/archive/master.tar.gz) {};
47− nixpkgs = import (src + "/nixpkgs") (import src);
47+ nixpkgs = haskellNix.sources.nixpgs-1909 haskellNix.nixpkgsArgs;
48 haskell = nixpkgs.haskell-nix;
48 haskell = nixpkgs.haskell-nix;
49
49
50 # Instantiate a package set using the generated file.
50 # Instantiate a package set using the generated file.
examples/cardano-sl-mingw32.nix+3−3
@@ -1,3 +1,3 @@
1+let inherit (import ../. {}) sources nixpkgsArgs;
1−with import ../nixpkgs ((import ../.) // { crossSystem.config = "x86_64-pc-mingw32"; });
2+ pkgs = import sources.nixpkgs-default (nixpkgsArgs // { crossSystem.config = "x86_64-pc-mingw32"; });
2−(haskell-nix.stackProject (import ./cardano-sl-args.nix))
3+in (pkgs.haskell-nix.stackProject (import ./cardano-sl-args.nix)).cardano-sl.components.all
3− .cardano-sl.components.all
examples/cardano-sl.nix+3−3
@@ -1,3 +1,3 @@
1−with import ../nixpkgs (import ../.);
1+let inherit (import ../. {}) sources nixpkgsArgs;
2+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
2−(haskell-nix.stackProject (import ./cardano-sl-args.nix))
3+in (pkgs.haskell-nix.stackProject (import ./cardano-sl-args.nix)).cardano-sl.components.all
3− .cardano-sl.components.all
examples/cardano-wallet-ghcjs.nix+4−3
@@ -1,5 +1,6 @@
1+let inherit (import ../. {}) sources nixpkgsArgs;
1−with import ../. { nixpkgs = ../nixpkgs; nixpkgsArgs = { crossSystem = { config = "js-unknown-ghcjs"; }; }; };
2+ pkgs = import sources.nixpkgs-default (nixpkgsArgs // { crossSystem.config = "js-unknown-ghcjs"; });
2−let Cabal = buildPackages.haskell-nix.hackage-package {
3+ Cabal = pkgs.buildPackages.haskell-nix.hackage-package {
3 name = "Cabal"; version = "2.4.1.0";
4 name = "Cabal"; version = "2.4.1.0";
4 modules = [
5 modules = [
5 { packages.Cabal.patches = [ ./Cabal-install-folder.diff ]; }
6 { packages.Cabal.patches = [ ./Cabal-install-folder.diff ]; }
@@ -11,7 +12,7 @@ let Cabal = buildPackages.haskell-nix.hackage-package {
11# ({config, ... }:{ packages.hello.package.setup-depends = [ Cabal ]; })
12# ({config, ... }:{ packages.hello.package.setup-depends = [ Cabal ]; })
12# ];}).cardano-wallet.components.all
13# ];}).cardano-wallet.components.all
13(let stack-pkgs = import ../cardano-wallet/flags-test/pkgs.nix;
14(let stack-pkgs = import ../cardano-wallet/flags-test/pkgs.nix;
14− in let pkg-set = haskell-nix.mkStackPkgSet
15+ in let pkg-set = pkgs.haskell-nix.mkStackPkgSet
15 { inherit stack-pkgs;
16 { inherit stack-pkgs;
16 pkg-def-extras = [(hackage: {
17 pkg-def-extras = [(hackage: {
17 packages = {
18 packages = {
examples/cardano-wallet-mingw32.nix+3−3
@@ -1,3 +1,3 @@
1+let inherit (import ../. {}) sources nixpkgsArgs;
1−with import ../nixpkgs ((import ../.) // { crossSystem.config = "x86_64-pc-mingw32"; });
2+ pkgs = import sources.nixpkgs-default (nixpkgsArgs // { crossSystem.config = "x86_64-pc-mingw32"; });
2−(haskell-nix.stackProject (import ./cardano-wallet-args.nix))
3+in (pkgs.haskell-nix.stackProject (import ./cardano-wallet-args.nix)).cardano-wallet.components.all
3− .cardano-wallet.components.all
examples/cardano-wallet-rpi.nix+4−3
@@ -1,5 +1,6 @@
1+let inherit (import ../. {}) sources nixpkgsArgs;
1−with import ../. { nixpkgs = ../nixpkgs; nixpkgsArgs = { crossSystem = { config = "armv6l-unknown-linux-gnueabihf"; }; }; };
2+ pkgs = import sources.nixpkgs-default (nixpkgsArgs // { crossSystem.config = "armv6l-unknown-linux-gnueabihf"; });
2−let Cabal = buildPackages.haskell-nix.hackage-package {
3+ Cabal = pkgs.buildPackages.haskell-nix.hackage-package {
3 name = "Cabal"; version = "2.4.1.0";
4 name = "Cabal"; version = "2.4.1.0";
4 modules = [
5 modules = [
5 { packages.Cabal.patches = [ ./Cabal-install-folder.diff ]; }
6 { packages.Cabal.patches = [ ./Cabal-install-folder.diff ]; }
@@ -11,7 +12,7 @@ let Cabal = buildPackages.haskell-nix.hackage-package {
11# ({config, ... }:{ packages.hello.package.setup-depends = [ Cabal ]; })
12# ({config, ... }:{ packages.hello.package.setup-depends = [ Cabal ]; })
12# ];}).cardano-wallet.components.all
13# ];}).cardano-wallet.components.all
13(let stack-pkgs = import ../cardano-wallet/flags-test/pkgs.nix;
14(let stack-pkgs = import ../cardano-wallet/flags-test/pkgs.nix;
14− in let pkg-set = haskell-nix.mkStackPkgSet
15+ in let pkg-set = pkgs.haskell-nix.mkStackPkgSet
15 { inherit stack-pkgs;
16 { inherit stack-pkgs;
16 pkg-def-extras = [(hackage: {
17 pkg-def-extras = [(hackage: {
17 packages = {
18 packages = {
examples/cardano-wallet.nix+3−3
@@ -1,3 +1,3 @@
1−with import ../nixpkgs (import ../.);
1+let inherit (import ../. {}) sources nixpkgsArgs;
2+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
2−(haskell-nix.stackProject (import ./cardano-wallet-args.nix))
3+in (pkgs.haskell-nix.stackProject (import ./cardano-wallet-args.nix)).cardano-wallet.components.all
3− .cardano-wallet.components.all
examples/plutus-mingw32.nix+3−3
@@ -1,3 +1,3 @@
1+let inherit (import ../. {}) sources nixpkgsArgs;
1−with import ../nixpkgs ((import ../.) // { crossSystem.config = "x86_64-pc-mingw32"; });
2+ pkgs = import sources.nixpkgs-default (nixpkgsArgs // { crossSystem.config = "x86_64-pc-mingw32"; });
2−(haskell-nix.stackProject (import ./plutus-args.nix))
3+in (pkgs.haskell-nix.stackProject (import ./plutus-args.nix)).language-plutus-core.components.all
3− .language-plutus-core.components.all
examples/plutus.nix+3−3
@@ -1,3 +1,3 @@
1−with import ../nixpkgs (import ../.);
1+let inherit (import ../. {}) sources nixpkgsArgs;
2+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
2−(haskell-nix.stackProject (import ./plutus-args.nix))
3+in (pkgs.haskell-nix.stackProject (import ./plutus-args.nix)).language-plutus-core.components.all
3− .language-plutus-core.components.all
nix-tools/regenerate.nix+5−2
@@ -6,8 +6,11 @@
6# 3. run `./result/bin/update-nix-tools` and follow the instructions.
6# 3. run `./result/bin/update-nix-tools` and follow the instructions.
7# 4. git commit -a -m "bump nix-tools"
7# 4. git commit -a -m "bump nix-tools"
8#
8#
9+let
10+ inherit (import ../default.nix {}) sources nixpkgsArgs;
11+in
9{ specJSON ? ./nix-tools-src.json }:
12{ specJSON ? ./nix-tools-src.json }:
10−with import ../nixpkgs (import ../.);
13+with import sources.nixpkgs-default nixpkgsArgs;
11let
14let
12 src = haskell-nix.cleanSourceHaskell {
15 src = haskell-nix.cleanSourceHaskell {
13 src = haskell-nix.fetchExternal {
16 src = haskell-nix.fetchExternal {
@@ -65,4 +68,4 @@ writeShellScriptBin "update-nix-tools" ''
65 echo "*** cp -fr "$TMP/" ."
68 echo "*** cp -fr "$TMP/" ."
66 echo "***"
69 echo "***"
67 echo "******"
70 echo "******"
68−''
71+''
nixpkgs/default.nix+6−2
@@ -1,5 +1,4 @@
1# see ../docs/dev/nixpkgs-pin.md
1# see ../docs/dev/nixpkgs-pin.md
2−{ nixpkgs-pin ? "github", ... }@args:
3let
2let
4 fetch = jsonFile:
3 fetch = jsonFile:
5 with builtins;
4 with builtins;
@@ -9,4 +8,9 @@ let
9 inherit (spec) sha256;
8 inherit (spec) sha256;
10 url = "${spec.url}/archive/${spec.rev}.tar.gz";
9 url = "${spec.url}/archive/${spec.rev}.tar.gz";
11 };
10 };
12−in import (fetch (./. + "/${nixpkgs-pin}.json")) (builtins.removeAttrs args [ "nixpkgs-pin" ])
11+in
12+{
13+ nixpkgs-1909 = fetch (./. + "/release-19.09.json");
14+ nixpkgs-1903 = fetch (./. + "/release-19.03.json");
15+ nixpkgs-default = fetch (./. + "/github.json");
16+}
release.nix+1−1
@@ -5,7 +5,7 @@
5
5
6let
6let
7 inherit (import ./ci-lib.nix) stripAttrsForHydra filterDerivations;
7 inherit (import ./ci-lib.nix) stripAttrsForHydra filterDerivations;
8− genericPkgs = import ./nixpkgs {};
8+ genericPkgs = import (import ./nixpkgs/default.nix).nixpkgs-default {};
9 lib = genericPkgs.lib;
9 lib = genericPkgs.lib;
10 ci = import ./ci.nix { inherit supportedSystems ifdLevel; restrictEval = true; };
10 ci = import ./ci.nix { inherit supportedSystems ifdLevel; restrictEval = true; };
11 allJobs = stripAttrsForHydra (filterDerivations ci);
11 allJobs = stripAttrsForHydra (filterDerivations ci);
shell.nix+2−1
@@ -1,5 +1,6 @@
1let
1let
2+ inherit (import ./default.nix {}) sources nixpkgsArgs;
2− pkgs = import ./nixpkgs/default.nix (import ./default.nix);
3+ pkgs = import sources.nixpkgs-default nixpkgsArgs;
3in pkgs.stdenv.mkDerivation rec {
4in pkgs.stdenv.mkDerivation rec {
4 name = "env";
5 name = "env";
5 env = pkgs.buildEnv { name = name; paths = buildInputs; };
6 env = pkgs.buildEnv { name = name; paths = buildInputs; };
test-ghcjs.nixdeleted−12
@@ -1,12 +0,0 @@
1−with import ./. { nixpkgs = ../nixpkgs; nixpkgsArgs = { crossSystem = { config = "js-unknown-ghcjs"; }; }; };
2−let Cabal = buildPackages.haskell-nix.hackage-package {
3− name = "Cabal"; version = "2.4.1.0";
4− modules = [
5− { packages.Cabal.patches = [ ./Cabal-install-folder.diff ]; }
6− ];
7−}; in
8−(haskell-nix.hackage-package {
9− name = "hello"; version = "1.0.0.2";
10− modules = [
11− ({config, ... }:{ packages.hello.package.setup-depends = [ Cabal ]; })
12− ];}).components.exes.hello
test-mingw32.nixdeleted−12
@@ -1,12 +0,0 @@
1−with import ./. { nixpkgs = ../nixpkgs; nixpkgsArgs = { crossSystem = { config = "x86_64-pc-mingw32"; }; }; };
2−let Cabal = buildPackages.haskell-nix.hackage-package {
3− name = "Cabal"; version = "2.4.1.0";
4− modules = [
5− { packages.Cabal.patches = [ ./Cabal-install-folder.diff ]; }
6− ];
7−}; in
8−(haskell-nix.hackage-package {
9− name = "hello"; version = "1.0.0.2";
10− modules = [
11− ({config, ... }:{ packages.hello.package.setup-depends = [ Cabal ]; })
12− ];}).components.exes.hello
test-rpi.nixdeleted−12
@@ -1,12 +0,0 @@
1−with import ./. { nixpkgs = ../nixpkgs; nixpkgsArgs = { crossSystem = { config = "armv6l-unknown-linux-gnueabihf"; }; }; };
2−let Cabal = buildPackages.haskell-nix.hackage-package {
3− name = "Cabal"; version = "2.4.1.0";
4− modules = [
5− { packages.Cabal.patches = [ ./Cabal-install-folder.diff ]; }
6− ];
7−}; in
8−(haskell-nix.hackage-package {
9− name = "hello"; version = "1.0.0.2";
10− modules = [
11− ({config, ... }:{ packages.hello.package.setup-depends = [ Cabal ]; })
12− ];}).components.exes.hello
test.nixdeleted−12
@@ -1,12 +0,0 @@
1−with import ./. { nixpkgs = ../nixpkgs; nixpkgsArgs = { }; };
2−let Cabal = buildPackages.haskell-nix.hackage-package {
3− name = "Cabal"; version = "2.4.1.0";
4− modules = [
5− { packages.Cabal.patches = [ ./Cabal-install-folder.diff ]; }
6− ];
7−}; in
8−(haskell-nix.hackage-package {
9− name = "hello"; version = "1.0.0.2";
10− modules = [
11− ({config, ... }:{ packages.hello.package.setup-depends = [ Cabal ]; })
12− ];}).components.exes.hello
test/default.nix+6−3
@@ -1,6 +1,9 @@
1+let
2+ haskellNix = (import ../default.nix {});
3+in
1−{ pkgs ? import nixpkgs ((import ../.) // nixpkgsArgs)
4+{ pkgs ? import nixpkgs nixpkgsArgs
2−, nixpkgs ? ../nixpkgs
5+, nixpkgs ? haskellNix.sources.nixpkgs-default
3−, nixpkgsArgs ? { }
6+, nixpkgsArgs ? haskellNix.nixpkgsArgs
4, ifdLevel ? 1000
7, ifdLevel ? 1000
5}:
8}:
6
9
test/fully-static/cross.nix+2−2
@@ -1,10 +1,10 @@
1{ pkgs ? import nixpkgs { }
1{ pkgs ? import nixpkgs { }
2−, nixpkgs ? ../../nixpkgs
2+, nixpkgs ? import (../../nixpkgs).nixpkgs-default
3}:
3}:
4
4
5let
5let
6 pkgs' = pkgs.pkgsCross.musl64;
6 pkgs' = pkgs.pkgsCross.musl64;
7− haskellMusl64 = pkgs.callPackage ../../. { pkgs = pkgs'; };
7+ haskellMusl64 = pkgs.callPackage ../.. { pkgs = pkgs'; };
8
8
9 test = haskellMusl64.callPackage ./default.nix {
9 test = haskellMusl64.callPackage ./default.nix {
10 inherit (pkgs') buildPackages;
10 inherit (pkgs') buildPackages;
test/regen.nix+6−3
@@ -1,7 +1,10 @@
1# A script for regenerating nix for tests
1# A script for regenerating nix for tests
2+let
3+ haskellNix = (import ../default.nix {});
4+in
2−{ pkgs ? import nixpkgs ((import ../.) // nixpkgsArgs)
5+{ pkgs ? import nixpkgs nixpkgsArgs
3−, nixpkgs ? ../nixpkgs
6+, nixpkgs ? haskellNix.sources.nixpkgs-default
4−, nixpkgsArgs ? { }
7+, nixpkgsArgs ? haskellNix.nixpkgsArgs
5}:
8}:
6
9
7with pkgs;
10with pkgs;