Stream: nix

Topic: How to add Haskell packages from flake into callCabal2nix?


view this post on Zulip LC (Sep 26 2024 at 15:03):

{
  inputs = {
    some-flake.url = "github:...";
  };

  outputs = { nixpkgs, some-flake, ... }:
  let
    project_name = "my-project";
    supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
    eachSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f rec {
      inherit system;
      pkgs = nixpkgs.legacyPackages.${system};
      hpkgs = pkgs.haskell.packages.ghc98;
    });
  in
  rec {
    packages = eachSystem ({hpkgs, system, ...}: {
      default = hpkgs.callCabal2nix project_name ./. {
        some-package = some-flake.packages.${system}.default; #this seems not working
      };
    });

    devShells = eachSystem ({pkgs, hpkgs, system, ...}: {
      default = pkgs.haskell.lib.addBuildTools packages.${system}.default
        (with hpkgs; [ haskell-language-server cabal-install ]);
    });
  };
}

Any help?

view this post on Zulip Srid (Sep 30 2024 at 19:58):

@LC You want to use the haskell package overlay:

https://nixos.asia/en/nixify-haskell-nixpkgs

view this post on Zulip Srid (Sep 30 2024 at 19:58):

which is simpler when using haskell-flake: https://community.flake.parts/haskell-flake/dependency#path


Last updated: Nov 15 2024 at 13:04 UTC