Skip to content

WIP: Better packages detection #93

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

Closed
wants to merge 1 commit into from
Closed

Conversation

srid
Copy link
Owner

@srid srid commented Feb 24, 2023

Make packages option traverse sub-dirs recursively as well as recognize package.yaml

  • Hacky prototype
  • Benchmark to validate this approach, and/or parse from cabal.project
  • Remove hacks, do proper implementation
    • Optimize traversal

@@ -0,0 +1,46 @@
# Like pkgs.haskell.lib.haskellPathsInDir' but with a few differences
# - Allows top-level .cabal files
# - Recurses into subdirectories
Copy link
Collaborator

Choose a reason for hiding this comment

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

Recursing into arbitrary subdirectories hurts performance. This will be exacerbated by projects that rely on lazy fetching of git submodules.

make haskellPathsInDir perfect

Not sure if perfect exists. I'd prefer a cabal.project or stack.yaml parser.

Copy link
Owner Author

@srid srid Feb 24, 2023

Choose a reason for hiding this comment

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

Recursing into arbitrary subdirectories hurts performance.

Doesn't nix copy the source tree to the store anyway? I ran this on a large internal mono repo with 31 packages using package.yaml which all lie as far as 5 sub-directories deep, and didn't notice a perceptible difference (to be fair, this was on my M1 Max). But yes performance degradation is a valid concern. I'll benchmark it properly before we stamp this PR for approval.

This will be exacerbated by projects that rely on lazy fetching of git submodules.

Lazy fetching of git submodules?

I'd prefer a cabal.project or stack.yaml parser.

I don't know about stack (why would someone use stack if there is Nix?) - but cabal.project parsing is indeed better (ie. #76); here's our cabal.project

packages:
  lib/*/*.cabal
  app/*/*/*.cabal
  app/*/*/*/*.cabal
  test/*.cabal

(cabal.project doesn't support hpack, so we would also have to look for package.yaml)

I suppose we can just write a Haskell executable (put it in pkgs.haskellPackages.<whatever>) and then use that to get a JSON back. This Haskell executable can also expose the hpack YAML data as JSON to Nix. In a way, it would be like cabal2nix. Maybe I should just go this route instead of this PR ...

Copy link
Owner Author

Choose a reason for hiding this comment

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

Copy link
Owner Author

Choose a reason for hiding this comment

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

This Haskell executable can even do the traversal and return packages information.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Lazy fetching of git submodules?

Sorry, I should have explained myself. I'm considering unimplemented lazy-trees features.

why would someone use stack if there is Nix?

The stack repl multi-module hack is rather useful. You can load a repl where all local packages are quick-reloadable.

There's also horizon-haskell, which is like Nixpkgs Haskell, but more stackage based.

I suppose we can just write a Haskell executable (put it in pkgs.haskellPackages.<whatever>) and then use that to get a JSON back.

It would be really nice to avoid IFD for this purpose. Ideally, the set of flake attribute names can be determined without doing any IFD. This keeps evaluation quick, especially on monorepos, and especially when you don't always need a haskell package in an evaluation.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@srid
Copy link
Owner Author

srid commented Mar 9, 2023

Closing in favour of #110

@srid srid closed this Mar 9, 2023
@srid srid deleted the exhaustive-packages-detection branch March 9, 2023 20:16
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