ivanovs-4 / haskell-flake-utils

Pure Nix flake utility functions for haskell cabal packages
MIT License
6 stars 2 forks source link

How to use hls in shellExtBuildInputs #5

Closed jmatsushita closed 2 years ago

jmatsushita commented 2 years ago

Hi,

I'm wondering if it's possible to use the hls flake with shellExtBuildInputs :

{
  inputs = {
    description = "example";
    (...)
    hls.url = "github:haskell/haskell-language-server";
    hls.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = { self, nixpkgs, flake-utils, haskell-flake-utils, flake-compat, hls, ... }:
    haskell-flake-utils.lib.simpleCabalProject2flake {
      inherit self nixpkgs;
      (...)
      shellExtBuildInputs = [ hls ];
    };
  }
}

This fails with error: Dependency is not of a valid type: element 3 of buildInputs for ghc-shell-for-packages-0

I also couldn't use it with the non-flake package after the breaking change in https://github.com/ivanovs-4/haskell-flake-utils/pull/4

Before that I could do:

outputs = { self, nixpkgs, flake-utils, haskell-flake-utils, flake-compat, ... }:
  flake-utils.lib.eachSystem [ "x86_64-linux" "aarch64-darwin" ] (system:
    let pkgs = import nixpkgs {inherit system;};
    in
    haskell-flake-utils.lib.simpleCabalProject2flake {
      inherit self nixpkgs system;

      name = "rhine";
      packageNames = ["rhine-gloss" "rhine-terminal" "rhine-examples"];
      shellExtBuildInputs = with pkgs.haskellPackages; [ haskell-language-server ];
  });

Maybe with the new API you suggested https://github.com/ivanovs-4/haskell-flake-utils/issues/2#issuecomment-1138755328 it would work well since we would have pkgs available to us?

ivanovs-4 commented 2 years ago

This is the way to add hls:

      shellExtBuildInputs = {pkgs}: with pkgs; [
        haskellPackages.haskell-language-server
      ];
ivanovs-4 commented 2 years ago

Look at how maybeCall is used here: https://github.com/ivanovs-4/haskell-flake-utils/blob/e18a8fcd6c32226c4b64617c5ffda2599cda9223/simpleCabalProject2flake.nix#L121

And how it's defined: https://github.com/ivanovs-4/haskell-flake-utils/blob/e18a8fcd6c32226c4b64617c5ffda2599cda9223/default.nix#L33

jmatsushita commented 2 years ago

Ah ok I understand now, thanks! How about with the hls flake in my first example?

ivanovs-4 commented 2 years ago

My guess was that it should be something like this:

      shellExtBuildInputs = {pkgs}: with pkgs; [
        hls.packages.${pkgs.system}.default
      ];

But in that particular case it fails with an error:

attribute 'ormolu_0_4_0_0' missing