nickel-lang / organist

Control all your tooling from a single console
MIT License
359 stars 20 forks source link

Haskell shell fails with recent nixpkgs #215

Open jneem opened 6 days ago

jneem commented 6 days ago

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 commented 6 days ago

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 commented 4 days ago

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):

https://github.com/nickel-lang/organist/blob/879ca211f784797f9ca8667e392e0ea1e4236bf0/lib/nix-interop/shells/haskell.ncl#L7-L27

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.