on iko/ghcjs-patch-master help sign in
Remove pj.hsPkgs.${n} functions in favour of pj.${n} (#938)

Applies to: * makeConfigFiles * ghcWithHoogle * ghcWithPackages * shellFor

commit5df5be0d0889fe199325b6239f0abe9e63949aba authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateThu 26 Nov 2020, 19:20 (6 years ago) parent256bc59
5 files changed+32−34
changelog.md+8 docs/reference/library.md+14−9 overlays/haskell.nix+8−23 test/cabal-simple/default.nix+1−1 test/shell-for-setup-deps/default.nix+1−1
changelog.md+8
@@ -1,6 +1,14 @@
11This file contains a summary of changes to Haskell.nix and `nix-tools`
22that will impact users.
33
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+
412## Nov 24, 2020
513* Added `${targetPrefix}cabal` wrapper script for running cross
614 compilers in `shellFor`.
docs/reference/library.md+14−9
@@ -112,16 +112,16 @@ will be passed to it:
112112
113113# Top-level attributes
114114
115−## project
115+## project'
116116
117117Function that accepts attribute set with a `src` attribute and looks for `stack.yaml` file relative to it.
118118
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.
120120
121121**Example**:
122122
123123```nix
124−pkgs.haskell-nix.project {
124+pkgs.haskell-nix.project' {
125125 # 'cleanGit' cleans a source directory based on the files known by git
126126 src = pkgs.haskell-nix.haskellLib.cleanGit {
127127 name = "haskell-nix-project";
@@ -130,7 +130,7 @@ pkgs.haskell-nix.project {
130130}
131131```
132132
133−## stackProject
133+## stackProject'
134134
135135A function calling [callStackToNix](#callstacktonix) with all arguments.
136136
@@ -142,14 +142,13 @@ Then feeding its result into [mkStackPkgSet](#mkstackpkgset) passing also
142142| Attribute | Type | Description |
143143|-------------------|--------------------------------------------------|----------------------------------------------------------------------------|
144144| `hsPkgs` | Attrset of [Haskell Packages](#haskell-package) | Buildable packages, created from `packages` |
145−| `pkg-set` | Attrset | [`pkgSet`](#package-set) |
146145| `stack-nix` | | `projectNix` attribute of [`callStackToNix`](#callstacktonix) return value |
147146| `shellFor` | Function | [`shellFor`](#shellfor) |
148147| `ghcWithHoogle` | Function | [`ghcWithHoogle`](#ghcwithhoogle) |
149148| `ghcWithPackages` | Function | [`ghcWithPackages`](#ghcwithpackages) |
150149
151150
152−## cabalProject
151+## cabalProject'
153152
154153A function calling [callCabalProjectToNix](#callcabalprojecttonix) with all arguments.
155154
@@ -161,14 +160,18 @@ Then feeding its result into [mkCabalProjectPkgSet](#mkcabalprojectpkgset) passi
161160| Attribute | Type | Description |
162161|-------------------|--------------------------------------------------|-----------------------------------------------------------------------------|
163162| `hsPkgs` | Attrset of [Haskell Packages](#haskell-package) | Buildable packages, created from `packages` |
164−| `pkg-set` | Attrset | [`pkgSet`](#package-set) |
165163| `plan-nix` | | `projectNix` attribute of [`callCabalProjectToNix`](#callcabalprojecttonix) return value |
166164| `index-state` | | `index-state` attribute of [`callCabalProjectToNix`](#callcabalprojecttonix) return value |
167165| `shellFor` | Function | [`shellFor`](#shellfor) |
168166| `ghcWithHoogle` | Function | [`ghcWithHoogle`](#ghcwithhoogle) |
169167| `ghcWithPackages` | Function | [`ghcWithPackages`](#ghcwithpackages) |
170168
169+## project, cabalProject and stackProject
171170
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`.
172175
173176## mkStackPkgSet
174177
@@ -404,9 +407,11 @@ Sub-component types identify [components](#component) and are one of:
404407 - `tests`
405408 - `benchmarks`
406409
407−# Package-set functions
410+# Project functions
408411
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.
410415
411416## shellFor
412417
overlays/haskell.nix+8−23
@@ -531,7 +531,7 @@ final: prev: {
531531 final.lib.fix (project':
532532 let project = project' // { recurseForDerivations = false; };
533533 in rawProject // rec {
534− hsPkgs = (final.lib.mapAttrs (n: package':
534+ hsPkgs = final.lib.mapAttrs (n: package':
535535 if package' == null
536536 then null
537537 else
@@ -554,13 +554,13 @@ final: prev: {
554554 ghc = project.pkg-set.config.ghc.package;
555555 });
556556 }
557− ) rawProject.hsPkgs
558− // {
557+ ) (builtins.removeAttrs rawProject.hsPkgs
559558 # These are functions not packages
560− inherit (rawProject.hsPkgs) shellFor makeConfigFiles ghcWithHoogle ghcWithPackages;
561− });
559+ [ "shellFor" "makeConfigFiles" "ghcWithHoogle" "ghcWithPackages" ]);
562560
563561 projectCoverageReport = haskellLib.projectCoverageReport (map (pkg: pkg.coverageReport) (final.lib.attrValues (haskellLib.selectProjectPackages hsPkgs)));
562+
563+ inherit (rawProject.hsPkgs) makeConfigFiles ghcWithHoogle ghcWithPackages shellFor;
564564 });
565565
566566 cabalProject =
@@ -568,12 +568,7 @@ final: prev: {
568568 let
569569 args = { caller = "hackage-package"; } // args';
570570 p = cabalProject' args;
571− in p.hsPkgs // {
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− };
571+ in p.hsPkgs // p;
577572
578573 stackProject' =
579574 { src, ... }@args:
@@ -601,12 +596,7 @@ final: prev: {
601596 in project;
602597
603598 stackProject = args: let p = stackProject' args;
604− in p.hsPkgs // {
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− };
599+ in p.hsPkgs // p;
610600
611601 # `project'` and `project` automatically select between `cabalProject`
612602 # and `stackProject` (when possible) by looking for `stack.yaml` or
@@ -646,12 +636,7 @@ final: prev: {
646636 let
647637 args = { caller = "project"; } // args';
648638 p = project' args;
649− in p.hsPkgs // {
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; };
639+ in p.hsPkgs // p;
655640
656641 # Like `cabalProject'`, but for building the GHCJS compiler.
657642 # 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 {
2626 };
2727
2828 # 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"; }; };
3030
3131 run = stdenv.mkDerivation {
3232 name = "cabal-simple-test";
test/shell-for-setup-deps/default.nix+1−1
@@ -13,7 +13,7 @@ let
1313 }];
1414 };
1515
16− env = project.hsPkgs.shellFor {};
16+ env = project.shellFor {};
1717
1818# Making this work for cross compilers will be difficult as setup-deps are
1919# built for the build platform and the shell will be for the host platform.