ghc.nix icon indicating copy to clipboard operation
ghc.nix copied to clipboard

Bash error is thrown with (direnv+nix-direnv+emacs-direnv) setup, when I try to build ghc using ghc.nix?

Open zeta-00 opened this issue 4 years ago • 3 comments

Hello there, again I'm trying to build ghc in an isolated environment using ghc.nix, but my (direnv+nix-direnv+emacs-direnv) setup is causing an error to be thrown. I fixed the hadrian.cabal file not found error by just moving my shell.nix up one directory into the ghc repository, but the bash error still remains? Here's the pastebin:

trace: checking if /home/zeta/open-source-projects/haskell-projects/ghc/hadrian/hadrian.cabal is present: yes bash: /nix/store/hl4m94j3yl7v5jfpn2kq0rkvj5kj428b-ghc-8.8.4-with-packages: Is a directory

And here is the shell.nix that file that I placed with a .envrc file inside the ghc repository root directory(I renamed the default.nix file to ghc-build.nix):

{ pkgs ? import {}}:

let ghc-build = import ./ghc.nix/ghc-build.nix {}; in
pkgs.mkShell { nativeBuildInputs = with pkgs; [ ghc-build ]; }

Thanks in advance for the help!

zeta-00 avatar Feb 07 '21 01:02 zeta-00

Hey @zeta-00 ,

{ pkgs ? import {}}: looks wrong. 🤔

I think you need to define what you want to import (e.g. <nixpkgs>).

IMHO it's idiomatic, that the shell.nix file resides on the top-level of the project.

I propose these steps (in order):

  • Make sure that your shell.nix works. It should work without moving or tweaking any other files.
  • Make direnv work with this shell.nix on the command line. Test it on the command line.
  • Now you can wire it in the Emacs configuration.

supersven avatar Feb 07 '21 16:02 supersven

Have you seen https://gitlab.haskell.org/ghc/ghc/-/wikis/spacemacs ?

It's a bit outdated* (regarding ghcide -> haskell language server), but maybe you get an impression how I used ghc.nix with Emacs about a year ago.


  • I don't use Emacs for GHC development anymore, so contributions / updates to this page are very welcome.

supersven avatar Feb 07 '21 16:02 supersven

@supersven ,

Hello there, Thanks for the response, my (direnv+nix-direnv+emacs-direnv) setup works great for most small projects that I work on. I think my main issue is, slightly changing ghc.nix's filenames and paths so that it works with my setup. Someone on another issue that I posted here in this repository (https://github.com/alpmestan/ghc.nix/issues/74) said that he got his (direnv+lorri+zsh) setup working out-of-the-box, so I asked him if he could paste his shell.nix code and the extra steps that he did. I think that I'm close to getting this working with my setup, I'm guessing that there's something that I'm missing.

Anyways, thanks again for your response and the link to the documentation, I'll definitely take a look.

zeta-00 avatar Feb 07 '21 20:02 zeta-00