Install haskell-language-server binaries

Hey!

I want to use home-manager to install haskell-language-server, I know haskell-language-server is available on unstable channel. But it seems only work with ghc 8.8.6. Since all the haskell-language-server binaries are available at https://github.com/haskell/haskell-language-server/releases/tag/0.4.0

So I copied from few nix file together

self: super: {

  haskell-language-server = with super;
    stdenv.mkDerivation rec {

      pname = "haskell-language-server";
      version = "0.4.0";

      sourceRoot = ".";

      dontConfigure = true;

      buildInputs = [ gzip ];

      srcs = [
        (fetchurl {
          url =
            "https://github.com/haskell/haskell-language-server/releases/download/0.4.0/haskell-language-server-macOS-8.6.5.gz";
          sha256 = "12q1sl3pippx2jqpbnr8d8zc33xflrvwk398519n1vvjdqkx4yf8";
        })
        (fetchurl {
          url =
            "https://github.com/haskell/haskell-language-server/releases/download/0.4.0/haskell-language-server-wrapper-macOS.gz";
          sha256 = "1mkbm5nw3hfwrsmqdhjh5j0f6v2j10gaj5r28j615kx4ayc8xnf1";
        })
      ];

      phases = [ "unpackPhase" "installPhase" ];

      unpackPhase = ''
        runHook preUnpack
        for _src in $srcs; do
          if [ -f "$_src" ]; then
             gunzip $_src
          else
             echo "$_src doesn't exist"
          fi
        done
        runHook postUnpack
      '';

      installPhase = ''
        runHook preInstall
        mkdir -p $out/bin
        cp haskell-language-server-wrapper-macOS $out/bin/
        runHook postInstall
      '';

      meta = {
        homepage = "https://github.com/haskell/haskell-language-server/";
      };
    };
}

but during the unpack phase, I cannot access these gz files

these derivations will be built:
  /nix/store/fazbniiw7i5b7nk0q6iyx4h90qji52sg-haskell-language-server-0.4.0.drv
  /nix/store/d8hi3x032pzwahlnh4sqaczpy10c7bkz-home-manager-path.drv
  /nix/store/87insacvfalr07bn7br4czcw97pcp9ph-hm_fontconfigconf.d10hmfonts.conf.drv
  /nix/store/j0j6z9ngalvdv9zpm8imb6c5mbda9za6-activation-script.drv
  /nix/store/xh6l9cnahh83zd135gw5axz2v6n6mifi-home-manager-files.drv
  /nix/store/qgjh0hj5q65djcqpmijd29abijnvcmq4-home-manager-generation.drv
building '/nix/store/fazbniiw7i5b7nk0q6iyx4h90qji52sg-haskell-language-server-0.4.0.drv'...
unpacking sources
/nix/store/2gr9l2khqfczavgs5vvvjbvfa1id4vyh-haskell-language-server-macOS-8.6.5.gz doesn't exist
installing
cp: cannot stat 'haskell-language-server-wrapper-macOS': No such file or directory
builder for '/nix/store/fazbniiw7i5b7nk0q6iyx4h90qji52sg-haskell-language-server-0.4.0.drv' failed with exit code 1
cannot build derivation '/nix/store/d8hi3x032pzwahlnh4sqaczpy10c7bkz-home-manager-path.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/qgjh0hj5q65djcqpmijd29abijnvcmq4-home-manager-generation.drv': 1 dependencies couldn't be built

would appreciate any helps

Doesn’t haskell.packages.ghc865.haskell-language-server work? If not, try GitHub - shajra/haskell-hls-nix: Nix builds of Haskell Language Server.

As for your specific question: do it in the install phase, e.g

  phases = [ "installPhase"];
  installPhase = ''
    mkdir -p $out/bin
    gzip -d < $src > $out/bin/haskell-language-server-macOS-8.6.5
    chmod +x $out/bin/haskell-language-server-macOS-8.6.5
  '';
1 Like