Skip to content
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

Shell.nix, almost #645

Closed
wants to merge 4 commits into from
Closed

Shell.nix, almost #645

wants to merge 4 commits into from

Conversation

deepfire
Copy link
Contributor

This almost brings back nix-shell that can build/run demo-playground.

The only blocker is the need to remove the source package definitions in the Cabal project file, which is caused by this Cabal issue: haskell/cabal#6049 (comment)

@deepfire deepfire requested review from nc6 and coot June 17, 2019 10:28
This was referenced Jun 17, 2019
Copy link
Contributor

@nc6 nc6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to work for me (whereas the previous iteration did):

[nc@lorien:~/topos/iohk/ouroboros-network]$ nix-shell --run "cabal new-build ouroboros-consensus"
Warning: No remote package servers have been specified. Usually you would have
one specified in the config file.
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: cardano-crypto-wrapper-1.3.0 (user goal)
[__1] trying: base64-bytestring-type-1.0.1/installed-Hpj... (dependency of
cardano-crypto-wrapper)
[__2] next goal: serialise (dependency of base64-bytestring-type)
[__2] rejecting: serialise-0.2.1.0/installed-LOU... (package is broken)
[__2] fail (backjumping, conflict set: base64-bytestring-type, serialise)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: base64-bytestring-type,
cardano-crypto-wrapper, serialise

@deepfire
Copy link
Contributor Author

deepfire commented Jun 17, 2019

@nc6, two options for what could have gone wrong:

  1. GHC environment file -- remedy being rm .ghc.environment.*
  2. source-repository-package in cabal.project (problematic as mentioned) -- remedy being commenting out these sections, so that grep '^source-repository-package' cabal.project | wc -l is 0

(EDIT: to clarify, I couldn't reproduce locally.)

@deepfire deepfire mentioned this pull request Jun 17, 2019
7 tasks
@deepfire deepfire changed the title Dfr/shell nix almost Shell.nix, almost Jun 17, 2019
shell.nix Outdated
default = import ./default.nix {};
in
default.nix-tools._raw.shellFor {
packages = p: map (x: p."${x}") [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not this?

Suggested change
packages = p: map (x: p."${x}") [
packages = ps: with ps; [ io-sim io-sim-classes ... ];
inherit withHoogle;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, thanks!

];
withHoogle = withHoogle;
buildInputs = with default.nix-tools._raw; [
cabal-install.components.exes.cabal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to assume that the user already has the latest cabal in their profile, so we don't need to add it to the project's dependencies.

Copy link
Contributor Author

@deepfire deepfire Jun 18, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really? The cabal in question might be incongruent in some fashion with the GHC in use -- or even completely absent.

If we choose not to specify it here, it would be one of those extra things for someone to care (as in debug, research etc.) about.

@rvl
Copy link
Contributor

rvl commented Jun 18, 2019

This project's Haskell.nix package set is generated from stack.yaml. If the cabal.project adds slightly different version constraints, then the nix-shell is unlikely to work for cabal.

I got the same error as @nc6. If I removed the constraints and source-repository-package sections from `cabal.project then it worked.

@deepfire
Copy link
Contributor Author

This project's Haskell.nix package set is generated from stack.yaml. If the cabal.project adds slightly different version constraints, then the nix-shell is unlikely to work for cabal.

I got the same error as @nc6. If I removed the constraints and source-repository-package sections from `cabal.project then it worked.>

@rvl, indeed. I've mentioned that in the PR description -- there is an upstream issue regarding this problem.

Do you have a suggestion of a workaround in the meantime?

@rvl
Copy link
Contributor

rvl commented Jun 18, 2019

I don't think this is an upstream issue with Cabal.

The Haskell.nix shellFor function forces Cabal, ghc and ghc-pkg into using its own package db and nothing else. So the Cabal solver doesn't have any options other than to use what it's been given.

But if cabal.project and the shellFor environment are inconsistent (i.e. contradictory), then it's going to break.

So you need to make sure that cabal.project and stack.yaml are consistent, because the shell is generated from stack.yaml. You could change from stack-to-nix to plan-to-nix, but that there's a bug that needs to be fixed first: input-output-hk/haskell.nix#182.

@deepfire
Copy link
Contributor Author

The Haskell.nix shellFor function forces Cabal, ghc and ghc-pkg into using its own package db and nothing else.

What you just described is specifically the Cabal behavior I asked the upstream for -- and according to them, it's not currently possible -- if you have a cabal.project that contains source-repository-package references, they are going to be used by cabal-install.

@deepfire deepfire force-pushed the dfr/shell-nix-almost branch 2 times, most recently from 80d03eb to 81e61c6 Compare July 5, 2019 18:46
@deepfire
Copy link
Contributor Author

deepfire commented Jul 8, 2019

Closed in favor of #723 -- same, but updated.

@deepfire deepfire closed this Jul 8, 2019
@deepfire deepfire deleted the dfr/shell-nix-almost branch July 18, 2019 22:24
infinisil added a commit to input-output-hk/ECIP-Checkpointing that referenced this pull request Dec 15, 2020
For source-repository-package's, cabal tries to build them on its own, even
when all dependencies are already provided by Nix. Relevant issues:
- haskell/cabal#6049
- IntersectMBO/ouroboros-network#645
- haskell/cabal#5586 (comment)

This seems to be a problem even with a cabal that includes
haskell/cabal#6917 (see
input-output-hk/haskell.nix#720 (comment)
for how to test a cabal-install 3.4)

The only known workaround is to remove the source-repository-package
sections from cabal.project, but this should only be done for cabal when
used from a nix-shell, not from cabal without a nix-shell, and not outside
the nix-shell.

To make this work smoothly, the script `scripts/nix-setup` can be used,
which splits the source-repository-package sections into cabal.project.srcs,
which is then again included from here (to make the Nix setup still work).
Running the script again undoes it.
infinisil added a commit to input-output-hk/ECIP-Checkpointing that referenced this pull request Dec 16, 2020
For source-repository-package's, cabal tries to build them on its own, even
when all dependencies are already provided by Nix. Relevant issues:
- haskell/cabal#6049
- IntersectMBO/ouroboros-network#645
- haskell/cabal#5586 (comment)

This seems to be a problem even with a cabal that includes
haskell/cabal#6917 (see
input-output-hk/haskell.nix#720 (comment)
for how to test a cabal-install 3.4)

The only known workaround is to remove the source-repository-package
sections from cabal.project, but this should only be done for cabal when
used from a nix-shell, not from cabal without a nix-shell, and not outside
the nix-shell.

To make this work smoothly, the script `scripts/nix-setup` can be used,
which splits the source-repository-package sections into cabal.project.srcs,
which is then again included from here (to make the Nix setup still work).
Running the script again undoes it.
infinisil added a commit to input-output-hk/ECIP-Checkpointing that referenced this pull request Dec 16, 2020
For source-repository-package's, cabal tries to build them on its own, even
when all dependencies are already provided by Nix. Relevant issues:
- haskell/cabal#6049
- IntersectMBO/ouroboros-network#645
- haskell/cabal#5586 (comment)

This seems to be a problem even with a cabal that includes
haskell/cabal#6917 (see
input-output-hk/haskell.nix#720 (comment)
for how to test a cabal-install 3.4)

The only known workaround is to remove the source-repository-package
sections from cabal.project, but this should only be done for cabal when
used from a nix-shell, not from cabal without a nix-shell, and not outside
the nix-shell.

To make this work smoothly, the script `scripts/nix-setup` can be used,
which splits the source-repository-package sections into cabal.project.srcs,
which is then again included from here (to make the Nix setup still work).
Running the script again undoes it.
infinisil added a commit to input-output-hk/ECIP-Checkpointing that referenced this pull request Dec 16, 2020
For source-repository-package's, cabal tries to build them on its own, even
when all dependencies are already provided by Nix. Relevant issues:
- haskell/cabal#6049
- IntersectMBO/ouroboros-network#645
- haskell/cabal#5586 (comment)

This seems to be a problem even with a cabal that includes
haskell/cabal#6917 (see
input-output-hk/haskell.nix#720 (comment)
for how to test a cabal-install 3.4)

The only known workaround is to remove the source-repository-package
sections from cabal.project, but this should only be done for cabal when
used from a nix-shell, not from cabal without a nix-shell, and not outside
the nix-shell.

To make this work smoothly, the script `scripts/nix-setup` can be used,
which splits the source-repository-package sections into cabal.project.srcs,
which is then again included from here (to make the Nix setup still work).
Running the script again undoes it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants