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

make stacklock2nix figure out the ghc version it needs automatically #4

Open
cdepillabout opened this issue Dec 5, 2022 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@cdepillabout
Copy link
Owner

I think it should be possible to make stacklock2nix figure out the ghc version is needs automatically.

Currently, the API of stacklock2nix requires you to pass a full package set, like the following (the baseHaskellPkgSet attr):

my-example-haskell-stacklock = final.stacklock2nix {
stackYaml = ./stack.yaml;
# The Haskell package set to use as a base. You should change this
# based on the compiler version from the resolver in your stack.yaml.
baseHaskellPkgSet = final.haskell.packages.ghc924;
# Any additional Haskell package overrides you may want to add.
additionalHaskellPkgSetOverrides = hfinal: hprev: {
# The servant-cassava.cabal file is malformed on GitHub:
# https://github.com/haskell-servant/servant-cassava/pull/29
servant-cassava =
final.haskell.lib.compose.overrideCabal
{ editedCabalFile = null; revision = null; }
hprev.servant-cassava;
};

It should be possible for stacklock2nix to figure out the GHC version automatically from the stackage package set, and then use that internally. I imagine an API like the following would be possible:

final.stacklock2nix {
  stackYaml = ./stack.yaml;
  haskell = final.haskell;
}

stacklock2nix would internally look in the resolver in stack.yaml.lock, figure out it uses GHC-9.2.4, translate that to haskell.packages.ghc924, and then just use that.

If a user wanted to use a different package set (like haskell.packages.native-bignum.ghc924), then they could just fall-back to using the baseHaskellPkgSet argument.

@cdepillabout cdepillabout added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Dec 5, 2022
@cdepillabout
Copy link
Owner Author

In Nixpkgs, ghc has a haskellCompilerName attribute. For instance, haskell.compiler.ghc924.haskellCompilerName is "ghc-9.2.4".

This value may be a good starting point for figuring out the Nixpkgs attribute to use for a given stack resolver GHC.

@silky
Copy link
Contributor

silky commented Feb 27, 2023

please forgive my extreme inability, but i would love to have a go at this, but my nix development skills are such that i can't even figure out how to run the tests, run a repl that does anything useful, or otherwise get a dev environment going :D 😅 ; for example, i had assumed i could run nix develop in the root dir and get a shell, but i can't ...

error: flake 'git+file:///home/noon/dev/ext/stacklock2nix' does not provide attribute 'devShells.x86_64-linux.default', 'devShell.x86_64-linux', 'packages.x86_64-linux.default' or 'defaultPackage.x86_64-linux'

if you could put together a very small developing... guide, then i could give it a go :) thanks!

@cdepillabout
Copy link
Owner Author

@silky I added a short explanation of how to run the tests in #14.

If this doesn't help, or you'd like a few more pointers, feel free to send me an email and we could do a video chat or some pair programming or something.

My email address (and other ways of getting in touch) is on this page: https://functor.tokyo/about

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants