tweag / store-graph

simple haskell code that builds a graph from the nix store
BSD 3-Clause "New" or "Revised" License
10 stars 1 forks source link

cannot build using `stack` #2

Open Sigmanificient opened 7 months ago

Sigmanificient commented 7 months ago

Hi, i saw your blogpost from Tweag and i would love to create a updated version of the graph

Describe the bug The stack build command fails with the following error:

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/105pldbc0qn9rfzn8njbf011vqyybhmp-nixos-23.05/nixos/pkgs/stdenv/generic/make-derivation.nix:303:7

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

         at «string»:1:411:

            1| with (import <nixpkgs> {}); let inputs = [haskell.compiler.ghc843 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 'ghc843' missing

       at «string»:1:43:

            1| with (import <nixpkgs> {}); let inputs = [haskell.compiler.ghc843 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 ghc943, ghc810, ghc88, ghc884 or ghc94?

Environment

aspiwack commented 6 months ago

Hi, glad you liked the blog post.

This is a limitation of Stack with Nixos: it can't download the compiler itself, so it relies on Nix. But if the precise Nix version isn't pinned (there's a pin for the Nix script in default.nix, but not for GHC), then Stack may require a version that isn't in Nixpkgs anymore.

The Haskell file is simple enough. You probably can fix the build by applying the following change to the stack.yaml file:

- resolver: lts-12.14
+ resolver: lts-22.6

or

- resolver: lts-12.14
+ resolver: lts-22.20

This repository is very much exposed “as is”, we aren't really spending time in maintaining it. That being said, you may want to sync up with the Nixtract team (@ErinvanderVeen , @GuillaumeDesforges ) who may have more modern ways of generating a similar graph.