haskell.nix/lib
Hamish Mackenzie 5c25ce919f
Add getComponent to project and package (#1060)
* Delays cabal configure errors until after evaluation when possible.

* Avoids rerunning long `cabal configure` if we already know it will fail.

* Provides a way to get a component from a package or project using a `cabal` like reference.

Code using the `tool` functions will automatically use `getComponent`.

For `(hackage-package {...}).components.library` is also ok.

```
# Consider changing hackage-package use:
(pkgs.haskell-nix.hackage-package {...}).components.exes.something
(pkgs.haskell-nix.hackage-package {...}).getComponent "exe:something"

# For any cabal project:
project.hsPkgs.somepackage.components.exes.something
project.getComponent "somepackage:exe:something"
# or do it in two steps
(project.getPackage "somepackage").getComponent "exe:something"
```

The reason for the new function is that we cannot provide the attribute interface without knowing that packages are in the project first.

Here is how the `cabal configure` error output is handled:

* The `plan-nix` derivation builds even if `cabal configure` fails.

* When it fails, it copies `failed-cabal-configure.nix` to the `$out/default.nix` along with a copy of the `cabal configure` output.

* When `failed-cabal-configure.nix` is imported and used in any way it writes the `cabal configure` output with `__trace` so it will always be visible.

* Instead of a `plan` the imported nix contains a `configurationError` pointing the `cabal configure` output.

* The intermediate functions `configurationError` and bubble it up to where it is needed.

* `getPackage` returns a mostly empty proxy for a real package when there is a `configurationError`

* The `getComponent` function always returns a derivation, but the version in the proxy writes the `cabal configure` output to stdout and calls `exit 1` (so that it will never build).
2021-03-04 20:10:58 +13:00
..
spdx Spdx license expressions (#859) 2021-01-14 14:33:40 +13:00
cabal-licenses.nix LicenseRef-OtherLicense is not free = false (#1006) 2021-01-20 00:27:18 +13:00
cabal-os-arch-comp.nix add iOS 2019-01-17 21:26:12 +08:00
cabal-project-parser.nix Do not use evalPackages to create sourceRepo for builds (#918) 2020-11-11 11:49:27 +00:00
call-cabal-project-to-nix.nix Add getComponent to project and package (#1060) 2021-03-04 20:10:58 +13:00
call-stack-to-nix.nix Don't reference scripts directly in materialization messages (#945) 2020-11-27 00:33:51 +13:00
check.nix Use the source sub directory when running tests (#1005) 2021-01-19 18:28:33 +13:00
clean-cabal-component.nix Fix filtering package in root of project (#1041) 2021-02-15 16:37:15 +13:00
clean-git.nix Support githash package and cross package refs (#843) 2021-01-14 12:34:06 +13:00
clean-source-haskell.nix Drop 19.09 support (#947) 2020-11-27 10:34:31 +13:00
clean-source-with.nix Spelling, typo and whitespace fixes (#833) 2020-08-31 11:08:25 +12:00
compat.nix Fix broken compat attribute 2019-02-12 12:55:10 +10:00
cover-project.nix Support githash package and cross package refs (#843) 2021-01-14 12:34:06 +13:00
cover.nix Support githash package and cross package refs (#843) 2021-01-14 12:34:06 +13:00
default.nix Add getComponent to project and package (#1060) 2021-03-04 20:10:58 +13:00
failed-cabal-configure.nix Add getComponent to project and package (#1060) 2021-03-04 20:10:58 +13:00
fetch-external.nix Provide hackage and stackage from haskell.nix 2019-02-13 14:51:10 +10:00
fetch-resolver.nix Spelling, typo and whitespace fixes (#833) 2020-08-31 11:08:25 +12:00
ghcjs-project.nix Add ghc 8.10.3 (#980) 2021-01-11 18:47:56 +13:00
hackageIndex.nix [ifd] cabalProjectToNix (#122) 2019-05-18 22:00:28 +08:00
host-map.nix Adds ghcjs and Asterius as cross compilers (#106) 2019-05-16 21:06:16 +08:00
import-and-filter-project.nix fix the way the isProject package flag is set (#1003) 2021-01-19 10:58:24 +13:00
make-source-pins.nix Fix evaluation on Hydra (#153) 2019-06-02 07:21:21 +10:00
materialize.nix Fix the way ExeDependency is handled (#1036) 2021-02-12 10:45:23 +13:00
override-with.nix Provide hackage and stackage from haskell.nix 2019-02-13 14:51:10 +10:00
pkgconf-nixpkgs-map.nix Fix for postgresql-libpg and musl (fixes #948) (#1056) 2021-02-24 22:49:31 +13:00
stack-cache-generator.nix Add "branch" information for builtins.fetchGit (#1019) 2021-02-03 13:16:02 +13:00
system-nixpkgs-map.nix add pcap -> libpcap to the system pkgs map (#1014) 2021-01-25 00:30:16 +13:00
system-pkgs.nix Updated system-nixpkgs-map.nix and a default for X11 package (fixes #984) (#988) 2021-01-08 13:10:00 +13:00