on iko/ghcjs-patch-master help sign in
Remove pj.hsPkgs.${n} functions in favour of pj.${n} (#938)
5df5be0Hamish Mackenzie
@@ -1,6 +1,14 @@
1This file contains a summary of changes to Haskell.nix and `nix-tools`
1This file contains a summary of changes to Haskell.nix and `nix-tools`
2that will impact users.
2that will impact users.
3
3
4+## Nov 25, 2020
5+* The `shellFor` `makeConfigFiles` `ghcWithHoogle` and `ghcWithPackages`
6+ functions have been removed from `project.hsPkgs`. Instead access
7+ them from `project` itself (e.g. change `p.hsPkgs.shellFor` to `p.shellFor`).
8+* The reflex-platform like `project.shells.ghc` has been removed.
9+ If needed, add something like `p // { shells.ghc = p.shellFor {} }`
10+ to `shell.nix`.
11+
4## Nov 24, 2020
12## Nov 24, 2020
5* Added `${targetPrefix}cabal` wrapper script for running cross
13* Added `${targetPrefix}cabal` wrapper script for running cross
6 compilers in `shellFor`.
14 compilers in `shellFor`.
docs/reference/library.md+14−9
@@ -112,16 +112,16 @@ will be passed to it:
112
112
113# Top-level attributes
113# Top-level attributes
114
114
115−## project
115+## project'
116
116
117Function that accepts attribute set with a `src` attribute and looks for `stack.yaml` file relative to it.
117Function that accepts attribute set with a `src` attribute and looks for `stack.yaml` file relative to it.
118
118
119−If file exists, it calls [stackProject](#stackproject) function. Otherwise it will call [cabalProject](#cabalproject) function.
119+If file exists, it calls [stackProject](#stackproject') function. Otherwise it will call [cabalProject](#cabalproject') function.
120
120
121**Example**:
121**Example**:
122
122
123```nix
123```nix
124−pkgs.haskell-nix.project {
124+pkgs.haskell-nix.project' {
125 # 'cleanGit' cleans a source directory based on the files known by git
125 # 'cleanGit' cleans a source directory based on the files known by git
126 src = pkgs.haskell-nix.haskellLib.cleanGit {
126 src = pkgs.haskell-nix.haskellLib.cleanGit {
127 name = "haskell-nix-project";
127 name = "haskell-nix-project";
@@ -130,7 +130,7 @@ pkgs.haskell-nix.project {
130}
130}
131```
131```
132
132
133−## stackProject
133+## stackProject'
134
134
135A function calling [callStackToNix](#callstacktonix) with all arguments.
135A function calling [callStackToNix](#callstacktonix) with all arguments.
136
136
@@ -142,14 +142,13 @@ Then feeding its result into [mkStackPkgSet](#mkstackpkgset) passing also
142| Attribute | Type | Description |
142| Attribute | Type | Description |
143|-------------------|--------------------------------------------------|----------------------------------------------------------------------------|
143|-------------------|--------------------------------------------------|----------------------------------------------------------------------------|
144| `hsPkgs` | Attrset of [Haskell Packages](#haskell-package) | Buildable packages, created from `packages` |
144| `hsPkgs` | Attrset of [Haskell Packages](#haskell-package) | Buildable packages, created from `packages` |
145−| `pkg-set` | Attrset | [`pkgSet`](#package-set) |
146| `stack-nix` | | `projectNix` attribute of [`callStackToNix`](#callstacktonix) return value |
145| `stack-nix` | | `projectNix` attribute of [`callStackToNix`](#callstacktonix) return value |
147| `shellFor` | Function | [`shellFor`](#shellfor) |
146| `shellFor` | Function | [`shellFor`](#shellfor) |
148| `ghcWithHoogle` | Function | [`ghcWithHoogle`](#ghcwithhoogle) |
147| `ghcWithHoogle` | Function | [`ghcWithHoogle`](#ghcwithhoogle) |
149| `ghcWithPackages` | Function | [`ghcWithPackages`](#ghcwithpackages) |
148| `ghcWithPackages` | Function | [`ghcWithPackages`](#ghcwithpackages) |
150
149
151
150
152−## cabalProject
151+## cabalProject'
153
152
154A function calling [callCabalProjectToNix](#callcabalprojecttonix) with all arguments.
153A function calling [callCabalProjectToNix](#callcabalprojecttonix) with all arguments.
155
154
@@ -161,14 +160,18 @@ Then feeding its result into [mkCabalProjectPkgSet](#mkcabalprojectpkgset) passi
161| Attribute | Type | Description |
160| Attribute | Type | Description |
162|-------------------|--------------------------------------------------|-----------------------------------------------------------------------------|
161|-------------------|--------------------------------------------------|-----------------------------------------------------------------------------|
163| `hsPkgs` | Attrset of [Haskell Packages](#haskell-package) | Buildable packages, created from `packages` |
162| `hsPkgs` | Attrset of [Haskell Packages](#haskell-package) | Buildable packages, created from `packages` |
164−| `pkg-set` | Attrset | [`pkgSet`](#package-set) |
165| `plan-nix` | | `projectNix` attribute of [`callCabalProjectToNix`](#callcabalprojecttonix) return value |
163| `plan-nix` | | `projectNix` attribute of [`callCabalProjectToNix`](#callcabalprojecttonix) return value |
166| `index-state` | | `index-state` attribute of [`callCabalProjectToNix`](#callcabalprojecttonix) return value |
164| `index-state` | | `index-state` attribute of [`callCabalProjectToNix`](#callcabalprojecttonix) return value |
167| `shellFor` | Function | [`shellFor`](#shellfor) |
165| `shellFor` | Function | [`shellFor`](#shellfor) |
168| `ghcWithHoogle` | Function | [`ghcWithHoogle`](#ghcwithhoogle) |
166| `ghcWithHoogle` | Function | [`ghcWithHoogle`](#ghcwithhoogle) |
169| `ghcWithPackages` | Function | [`ghcWithPackages`](#ghcwithpackages) |
167| `ghcWithPackages` | Function | [`ghcWithPackages`](#ghcwithpackages) |
170
168
169+## project, cabalProject and stackProject
171
170
171+These versions of the function are the same as project', cabalProject'
172+and stackProject', but `hsPkgs` attributes are also included in the
173+return value directly. That way a package can be referenced as
174+`(project {...}).foo` instead of `(project' {...}).hsPkgs.foo`.
172
175
173## mkStackPkgSet
176## mkStackPkgSet
174
177
@@ -404,9 +407,11 @@ Sub-component types identify [components](#component) and are one of:
404 - `tests`
407 - `tests`
405 - `benchmarks`
408 - `benchmarks`
406
409
407−# Package-set functions
410+# Project functions
408
411
409−These functions exist within the `hsPkgs` package set.
412+These functions are included in the `project` return values.
413+In the past they also existed within `project.hsPkgs`,
414+but have now been removed from there.
410
415
411## shellFor
416## shellFor
412
417
overlays/haskell.nix+8−23
@@ -531,7 +531,7 @@ final: prev: {
531 final.lib.fix (project':
531 final.lib.fix (project':
532 let project = project' // { recurseForDerivations = false; };
532 let project = project' // { recurseForDerivations = false; };
533 in rawProject // rec {
533 in rawProject // rec {
534− hsPkgs = (final.lib.mapAttrs (n: package':
534+ hsPkgs = final.lib.mapAttrs (n: package':
535 if package' == null
535 if package' == null
536 then null
536 then null
537 else
537 else
@@ -554,13 +554,13 @@ final: prev: {
554 ghc = project.pkg-set.config.ghc.package;
554 ghc = project.pkg-set.config.ghc.package;
555 });
555 });
556 }
556 }
557− ) rawProject.hsPkgs
557+ ) (builtins.removeAttrs rawProject.hsPkgs
558− // {
559 # These are functions not packages
558 # These are functions not packages
560− inherit (rawProject.hsPkgs) shellFor makeConfigFiles ghcWithHoogle ghcWithPackages;
559+ [ "shellFor" "makeConfigFiles" "ghcWithHoogle" "ghcWithPackages" ]);
561− });
562
560
563 projectCoverageReport = haskellLib.projectCoverageReport (map (pkg: pkg.coverageReport) (final.lib.attrValues (haskellLib.selectProjectPackages hsPkgs)));
561 projectCoverageReport = haskellLib.projectCoverageReport (map (pkg: pkg.coverageReport) (final.lib.attrValues (haskellLib.selectProjectPackages hsPkgs)));
562+
563+ inherit (rawProject.hsPkgs) makeConfigFiles ghcWithHoogle ghcWithPackages shellFor;
564 });
564 });
565
565
566 cabalProject =
566 cabalProject =
@@ -568,12 +568,7 @@ final: prev: {
568 let
568 let
569 args = { caller = "hackage-package"; } // args';
569 args = { caller = "hackage-package"; } // args';
570 p = cabalProject' args;
570 p = cabalProject' args;
571− in p.hsPkgs // {
571+ in p.hsPkgs // p;
572− inherit (p) plan-nix index-state tool tools roots projectCoverageReport;
573− # Provide `nix-shell -A shells.ghc` for users migrating from the reflex-platform.
574− # But we should encourage use of `nix-shell -A shellFor`
575− shells.ghc = p.hsPkgs.shellFor {};
576− };
577
572
578 stackProject' =
573 stackProject' =
579 { src, ... }@args:
574 { src, ... }@args:
@@ -601,12 +596,7 @@ final: prev: {
601 in project;
596 in project;
602
597
603 stackProject = args: let p = stackProject' args;
598 stackProject = args: let p = stackProject' args;
604− in p.hsPkgs // {
599+ in p.hsPkgs // p;
605− inherit (p) stack-nix tool tools roots projectCoverageReport;
606− # Provide `nix-shell -A shells.ghc` for users migrating from the reflex-platform.
607− # But we should encourage use of `nix-shell -A shellFor`
608− shells.ghc = p.hsPkgs.shellFor {};
609− };
610
600
611 # `project'` and `project` automatically select between `cabalProject`
601 # `project'` and `project` automatically select between `cabalProject`
612 # and `stackProject` (when possible) by looking for `stack.yaml` or
602 # and `stackProject` (when possible) by looking for `stack.yaml` or
@@ -646,12 +636,7 @@ final: prev: {
646 let
636 let
647 args = { caller = "project"; } // args';
637 args = { caller = "project"; } // args';
648 p = project' args;
638 p = project' args;
649− in p.hsPkgs // {
639+ in p.hsPkgs // p;
650− # Provide `nix-shell -A shells.ghc` for users migrating from the reflex-platform.
651− # But we should encourage use of `nix-shell -A shellFor`
652− shells.ghc = p.hsPkgs.shellFor {};
653− } // final.lib.optionalAttrs (p ? stack-nix) { inherit (p) stack-nix; }
654− // final.lib.optionalAttrs (p ? plan-nix ) { inherit (p) plan-nix; };
655
640
656 # Like `cabalProject'`, but for building the GHCJS compiler.
641 # Like `cabalProject'`, but for building the GHCJS compiler.
657 # This is exposed to allow GHCJS developers to work on the GHCJS
642 # This is exposed to allow GHCJS developers to work on the GHCJS
test/cabal-simple/default.nix+1−1
@@ -26,7 +26,7 @@ in recurseIntoAttrs {
26 };
26 };
27
27
28 # Used for testing externally with nix-shell (../tests.sh).
28 # Used for testing externally with nix-shell (../tests.sh).
29− test-shell = packages.shellFor { tools = { cabal = "3.2.0.0"; }; };
29+ test-shell = project.shellFor { tools = { cabal = "3.2.0.0"; }; };
30
30
31 run = stdenv.mkDerivation {
31 run = stdenv.mkDerivation {
32 name = "cabal-simple-test";
32 name = "cabal-simple-test";
test/shell-for-setup-deps/default.nix+1−1
@@ -13,7 +13,7 @@ let
13 }];
13 }];
14 };
14 };
15
15
16− env = project.hsPkgs.shellFor {};
16+ env = project.shellFor {};
17
17
18# Making this work for cross compilers will be difficult as setup-deps are
18# Making this work for cross compilers will be difficult as setup-deps are
19# built for the build platform and the shell will be for the host platform.
19# built for the build platform and the shell will be for the host platform.