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

Per component building, and hackage DB #6

Conversation

ElvishJerricco
Copy link
Contributor

No description provided.

@ElvishJerricco
Copy link
Contributor Author

Only reasons I wouldn't merge this straight away are:

  • The hackage-db fork. We just need to address the concerns listed here: List cabal file revisions NixOS/hackage-db#9
  • There's a couple of things in my nix/default.nix that are stubbed / hard coded. You'll have to run the hackage-to-nix and lts-to-nix commands to get the things necessary, and the hsc2hs version is hard coded in there.

@ElvishJerricco
Copy link
Contributor Author

  • And I guess I didn't make the changes necessary to driver.nix to account for my changes to flags.

lib/Cabal2Nix.hs Outdated
@@ -94,7 +95,6 @@ shakeBranch :: (Foldable t, Foldable f) => CondBranch v (t c) (f a) -> Maybe (Co
shakeBranch (CondBranch c t f) = case (shakeTree t, f >>= shakeTree) of
(Nothing, Nothing) -> Nothing
(Nothing, Just f') -> shakeBranch (CondBranch (CNot c) f' Nothing)
(Just (CondNode d _c [(CondBranch c' t' f')]), Nothing) | null d -> Just $ CondBranch (CAnd c c') t' f'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@angerman Oh, I removed this line because it was clearly causing things to be mistranslated. IIRC, there was some package that depended on Win32 conditionally that this broke, causing it to always depend on it. Looking at this line, it seems wrong, but I admit I don't really fully understand this function.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@ElvishJerricco this could absolutely be wrong. The idea is to simplify the tree and drop unnecessary branching.

So assuming we are in a conditional branch, and clean up both true and false subtrees,
now we have only the true side, and nothing left for the false side. We should be able to ignore this, and move the conditional with an AND one node down.

Before shaking:

- c - <true sub tree: t>
  '-- <false sub tree: f>

after shaking:

- c - <some node with no interesting data, but a another branch>
  '-- Nothing

so this looks a bit like this:

- c - c' - <true subtree: t'>
  |   '--- <false subtree: f'>
  '------- Nothing

So we try to simplify this as

- (c && c') - <true subtree: t'>
      '------ <false subtree: f'>

And this is where the logic is wrong I guess. If c is false, we don't want f', however the simplification would yield that instead of nothing.

@angerman
Copy link
Collaborator

@ElvishJerricco I'll go ahead an selectively merge parts of this (e.g. the incorrect anding above).

For the NixOS/hackage-db#9 issue, that seems like it's not too hard to fix?

@ElvishJerricco
Copy link
Contributor Author

@angerman Example usage from this branch (dunno about changes in master):

cabal new-run hackage-to-nix -- ./hackage # Takes a while
cabal new-run lts-to-nix -- ./lts-haskell/lts-11.4.yaml | tail -n+2 > stackage.nix # cabal outputs "Up to date"
nix build -f nix/default.nix \
  --arg planFunc "import ./stackage.nix" \
  --arg hackage "import ./hackage" \
  hsPkgs.cabal-install.components.exes.cabal

@ElvishJerricco
Copy link
Contributor Author

You can use the output of plan-to-nix with planFunc as well. But be aware that this currently only supports Hackage packages, not local packages.

angerman added a commit that referenced this pull request Oct 15, 2018
 #6 included "Per component building, and hackage DB", this
PR only pulls in the relevant hackage-db logic.  The per
component building (nix) will be a separate PR.
@ElvishJerricco ElvishJerricco force-pushed the per-component-new-names branch from 58bbcae to 4ebd797 Compare October 16, 2018 05:50
@angerman angerman changed the base branch from master to feature/hackage-db October 16, 2018 06:11
@angerman angerman changed the base branch from feature/hackage-db to master October 16, 2018 06:11
angerman added a commit that referenced this pull request Oct 16, 2018
This rather crudely integrates most of the haskell
changes from elvishjerricco/per-component-new-names.
@angerman angerman changed the base branch from master to feature/hackage-db October 16, 2018 06:58
@ElvishJerricco
Copy link
Contributor Author

Closing in favor of #9 and https://github.com/angerman/haskell.nix/pull/2

angerman added a commit that referenced this pull request Oct 30, 2018
 #6 included "Per component building, and hackage DB", this
PR only pulls in the relevant hackage-db logic.  The per
component building (nix) will be a separate PR.
angerman added a commit that referenced this pull request Oct 30, 2018
This rather crudely integrates most of the haskell
changes from elvishjerricco/per-component-new-names.
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.

2 participants