-
Notifications
You must be signed in to change notification settings - Fork 247
Add getComponent
to project and package
#1060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* 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 from: (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).
bors try |
tryBuild failed: |
bors try |
tryTimed out. |
bors try |
tryTimed out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I'm just a bit concerned about the disabling of all the targets (musl, ...)
# Conflicts: # lib/call-cabal-project-to-nix.nix
Ooops, that was not supposed to be in here. Fixed |
bors try |
tryBuild succeeded: |
* 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).
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 usegetComponent
.For
(hackage-package {...}).components.library
is also ok.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 ifcabal configure
fails.When it fails, it copies
failed-cabal-configure.nix
to the$out/default.nix
along with a copy of thecabal configure
output.When
failed-cabal-configure.nix
is imported and used in any way it writes thecabal configure
output with__trace
so it will always be visible.Instead of a
plan
the imported nix contains aconfigurationError
pointing thecabal 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 aconfigurationError
The
getComponent
function always returns a derivation, but the version in the proxy writes thecabal configure
output to stdout and callsexit 1
(so that it will never build).