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

External hackages #535

Merged
merged 7 commits into from
May 2, 2020
Merged

Conversation

maksbotan
Copy link
Contributor

Two changes:

Add support for external Hackage repositories

Currently haskell.nix is not able to build Cabal projects that depend on
packages from private Hackage repositories, as it make only main Hackage
available to cabal. This is unfortunate.

This commit adds this functionality, by allowing the user to pass
`extra-hackages` and `extra-hackage-tarballs` to `mkPkgSet` and
`callCabalToNix` respectively, to add as much extra repositories as
needed.

This repositories are first made available to Cabal when calling
`v2-configure`, resulting in correct plans. Later they are combined with
global Hackage when building dependencies of the local packages.

Use cabal.project.freeze if available

Currently callCabalProjectToNix does not copy `cabal.project.freeze`
from source directory, leading to different build plans when building
components with nix and when building project with `cabal new-build`
inside `nix-shell`.

This behavior is undesired, so this commits fixes it.

This branch also includes serokell/kirelagin/darwin-so because I needed fixes from #534 .

Support for external hackages requires this PR: input-output-hk/nix-tools#84

@balsoft
Copy link
Contributor

balsoft commented Apr 7, 2020

The first two commits belong in a separate PR. They have nothing to do with hackage repositories.

@maksbotan
Copy link
Contributor Author

Do you think I should point this PR to a branch without those commits?

@balsoft
Copy link
Contributor

balsoft commented Apr 7, 2020 via email

@maksbotan maksbotan force-pushed the external-hackages branch from 07acc06 to a1a1cdf Compare April 7, 2020 18:57
@maksbotan
Copy link
Contributor Author

Done!

@balsoft
Copy link
Contributor

balsoft commented Apr 8, 2020

Otherwise, LGTM (if it works, I haven't tested it yet)

@michaelpj
Copy link
Collaborator

This seems like a slightly unusual usecase, so I think this could really do with a test to make sure it keeps working!

@maksbotan
Copy link
Contributor Author

How do I make a test in this repo?

@balsoft
Copy link
Contributor

balsoft commented Apr 8, 2020

@angerman
Copy link
Collaborator

angerman commented Apr 9, 2020

Pending a test, this LGTM.

@maksbotan
Copy link
Contributor Author

@angerman thanks, I'll add a test :)

@angerman
Copy link
Collaborator

angerman commented May 1, 2020

@maksbotan this seems somewhat stale pending a test, could we get this done and merge it?

@michaelpj
Copy link
Collaborator

I've wanted the cabal.freeze commit in recent times too!

@maksbotan
Copy link
Contributor Author

@angerman sorry! I was planning to work on this today and tomorrow, so expect tests to be done :)

@angerman
Copy link
Collaborator

angerman commented May 1, 2020

@maksbotan awesome! Looking forward to it!

maksbotan added 2 commits May 1, 2020 21:58
Currently haskell.nix is not able to build Cabal projects that depend on
packages from private Hackage repositories, as it make only main Hackage
available to cabal. This is unfortunate.

This commit adds this functionality, by allowing the user to pass
`extra-hackages` and `extra-hackage-tarballs` to `mkPkgSet` and
`callCabalToNix` respectively, to add as much extra repositories as
needed.

This repositories are first made available to Cabal when calling
`v2-configure`, resulting in correct plans. Later they are combined with
global Hackage when building dependencies of the local packages.
Currently callCabalProjectToNix does not copy `cabal.project.freeze`
from source directory, leading to different build plans when building
components with nix and when building project with `cabal new-build`
inside `nix-shell`.

This behavior is undesired, so this commits fixes it.
@maksbotan maksbotan force-pushed the external-hackages branch from a1a1cdf to 75db8c4 Compare May 1, 2020 21:26
@maksbotan
Copy link
Contributor Author

@angerman so, here are tests. I hope I did everything right :)

Do you have some kind of CI here to actually run them?

@maksbotan
Copy link
Contributor Author

Oh, and I remind that this PR depends on input-output-hk/nix-tools#84. It would be nice to have haskell.nix master refer to nix-tools master at some commit after that PR is merged. Ideally I'd update it in this PR.

@maksbotan maksbotan force-pushed the external-hackages branch from 75db8c4 to e7a6a80 Compare May 1, 2020 21:44
@angerman
Copy link
Collaborator

angerman commented May 2, 2020

No idea why CI isn't picking this up. hydra link

@angerman angerman merged commit 07031ee into input-output-hk:master May 2, 2020
hamishmack added a commit that referenced this pull request Feb 11, 2022
This change builds #535. `repository` blocks in `cabal.project` parsed and `cabal` is used to automatically downloaded them.  Then `hackage-to-nix` is used to produce the nix required.

To make it work with restricted eval (on hydra for instance) we need to include a sha256 like this:

```
repository ghcjs-overlay
  url: https://input-output-hk.github.io/hackage-overlay-ghcjs
  secure: True
  root-keys:
  key-threshold: 0
  --sha256: sha256-EPlLYPmIGtxeahlOspRzwJv+60N5mqrNC2BY4jZKceE=
```

To find the correct `sha256` put in an invalid one and attempt a build.
hamishmack added a commit that referenced this pull request Feb 17, 2022
* Improve support for external Hackage repositories

This change builds #535. `repository` blocks in `cabal.project` parsed and `cabal` is used to automatically downloaded them.  Then `hackage-to-nix` is used to produce the nix required.

To make it work with restricted eval (on hydra for instance) we need to include a sha256 like this:

```
repository ghcjs-overlay
  url: https://input-output-hk.github.io/hackage-overlay-ghcjs
  secure: True
  root-keys:
  key-threshold: 0
  --sha256: sha256-EPlLYPmIGtxeahlOspRzwJv+60N5mqrNC2BY4jZKceE=
```

To find the correct `sha256` put in an invalid one and attempt a build.
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.

4 participants