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

Haskell shell fails with recent nixpkgs #215

Closed
jneem opened this issue Jun 22, 2024 · 4 comments · Fixed by #216
Closed

Haskell shell fails with recent nixpkgs #215

jneem opened this issue Jun 22, 2024 · 4 comments · Fixed by #216

Comments

@jneem
Copy link
Contributor

jneem commented Jun 22, 2024

With a newly created organist environment, trying to use the HaskellStack shell fails with

error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'shell'
         whose name attribute is located at «none»:0

       … while evaluating attribute 'nativeBuildInputs' of derivation 'shell'

         at «none»:0: (source not available)

       error: attribute 'hls-ormolu-plugin' missing

       at /nix/store/gziak2db5lgxszrxnkwpd8n8v98hcfm7-nickel-generated-expr:8:51:

            7|     hlsDependencies = getDependencies hls;
            8|     hlsOrmoluPluginDependencies = getDependencies hlsDependencies.hls-ormolu-plugin;

Maybe this is because hls-ormolu-plugin is broken?

Anyway, changing nixpkgs to nixpkgs/nixos-23.11 fixes it (but not 24.05; that's still broken).

@jneem
Copy link
Contributor Author

jneem commented Jun 22, 2024

Hm, unfortunately using a nixpkgs that's older than my system's nixpkgs doesn't work very well, possibly because of this. In my new organist shell, running stack new testpkg gives

error:
       … while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

       … while evaluating derivation 'myEnv'
         whose name attribute is located at /nix/store/fwdi5pvgkw12gr4mx7n35smj76dyy0k2-qk1dpz44db85rhd8lr4j6i2hkn9j5hg4-source/pkgs/stdenv/generic/make-derivation.nix:348:7

       … while evaluating attribute 'LD_LIBRARY_PATH' of derivation 'myEnv'

         at «string»:1:411:

            1| with (import <nixpkgs> {}); let inputs = [haskell.compiler.ghc965 git gcc gmp]; libPath = lib.makeLibraryPath inputs; stackExtraArgs = lib.concatMap (pkg: [ ''--extra-lib-dirs=${lib.getLib pkg}/lib''   ''--extra-include-dirs=${lib.getDev pkg}/include'' ]) inputs; in runCommand ''myEnv'' { buildInputs = lib.optional stdenv.isLinux glibcLocales ++ inputs; STACK_PLATFORM_VARIANT=''nix''; STACK_IN_NIX_SHELL=1; LD_LIBRARY_PATH = libPath;STACK_IN_NIX_EXTRA_ARGS = stackExtraArgs; LANG="en_US.UTF-8";} ""
             |                                                                                                                                                                                                                                                                                                                                                                                                                           ^

       error: attribute 'ghc965' missing

       at «string»:1:43:

            1| with (import <nixpkgs> {}); let inputs = [haskell.compiler.ghc965 git gcc gmp]; libPath = lib.makeLibraryPath inputs; stackExtraArgs = lib.concatMap (pkg: [ ''--extra-lib-dirs=${lib.getLib pkg}/lib''   ''--extra-include-dirs=${lib.getDev pkg}/include'' ]) inputs; in runCommand ''myEnv'' { buildInputs = lib.optional stdenv.isLinux glibcLocales ++ inputs; STACK_PLATFORM_VARIANT=''nix''; STACK_IN_NIX_SHELL=1; LD_LIBRARY_PATH = libPath;STACK_IN_NIX_EXTRA_ARGS = stackExtraArgs; LANG="en_US.UTF-8";} ""
             |                                           ^
       Did you mean one of ghc925, ghc945, ghc96, ghc962 or ghc963?

@thufschmitt
Copy link
Member

Thanks for reporting that.

The HaskellStack shell is currently using some Nix trickery to get ormolu from the closure of hls (because ormolu-in-the-path and ormolu-in-the-lsp have to match to avoid inconsistencies in the formatting):

# Haskell Language Server (HLS) uses a different Ormolu version than the default one, and it's difficult to change it for now.
# See https://github.com/haskell/haskell-language-server/issues/411
# So we do the opposite: retrieve the Ormolu package transitively pulled by HLS.
# Note that Ormolu is a level 2 transitive dependency of HLS: `haskell-language-server` -> `hls-ormolu-plugin` -> `ormolu`
ormoluFromHls = fun hls =>
derivation.CallNix
& {
function = m%"
hls:
let
# Build the attrset of dependency packages of `p`
getDependencies = p: builtins.listToAttrs
(map (dependency: { name = dependency.pname; value = dependency; }) p.passthru.getBuildInputs.haskellBuildInputs);
hlsDependencies = getDependencies hls;
hlsOrmoluPluginDependencies = getDependencies hlsDependencies.hls-ormolu-plugin;
in
hlsOrmoluPluginDependencies.ormolu.bin
"%,
args = hls,
}

But the layout of the dependencies of hls changed between 23.11 and 24.05, breaking that.

I'm working on a fix to be compatible with both, will open a PR as soon as it's ready.

@simeoncarstens
Copy link

@jneem looks like this can be closed, right?

@jneem
Copy link
Contributor Author

jneem commented Jul 29, 2024

Yep, I just tested a new shell and it seems to work.

@jneem jneem closed this as completed Jul 29, 2024
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 a pull request may close this issue.

3 participants