Import and use ghide-nix

Since haskellPackages.ghcide currently is broken I thought I’d try to pull in ghcide-nix. I’m failing miserably though :cry:

I tried modify my shell.nix, just importing and adding it to buildInputs:

with (import <nixpkgs> {});

let
  ghcide-nix = import (builtins.fetchGit {
    name = "ghcide-nix";
    url = https://github.com/hercules-ci/ghcide-nix;
    rev = "4f3e98f211f34698805eb7a3c5f7b4361d97f541";
  });
  def = import ./default.nix;
  hl = haskell.lib;

  shell-pkgs = with haskellPackages;
    [cabal-install
     ghcid
     ghcide-nix
     ormolu];

in
def.pkg.overrideAttrs (attrs: {
  src = null;
  buildInputs = shell-pkgs ++ attrs.buildInputs;
  shellHook = ''
    echo 'Entering ${attrs.name}'
  '';
})

that fails with with

error: cannot coerce a function to a string, at /nix/store/3abw7pkjmf850s048q45i203vj9z3czd-nixpkgs-20.03pre203317.8bb98968edf/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix:311:9

I clearly don’t understand how the expression in that repo is supposed to be used. Hopefully someone else here can make more sense of it.

I believe you need something like ghcide-nix = import (...) {};, because the default.nix provided by the repo contains a function.

Yes, indeed.

I managed to figure out that it’s a function returning a set

{
  ghcide-ghc865 = <ghcide for ghc 8.6.5>;
  ghcide-ghc864 = <ghcide for ghc 8.6.4>;
  ghcide-ghc844 = <ghcide for ghc 8.4.4>;
}
1 Like