How to get Haskell + WASM work for haskell-flake?

I’m completely new to nix, and I’m trying to set up haskell-flake in order to use ghc-wasm. But I’m clueless on how to set it up correctly.

Currently, my flake file is (almost) the default one (end of post). And what’s currently puzzling me is that I can’t seem to find a schema which points out what am I supposed to define in the attribute set of haskellProjects.default, where to put the compiler version I want (which I think is pkgs.haskell.compiler.ghc96?) or how to import ghc-wasm (if I add it to the imports list as inputs.ghc-wasm-meta.flakeModule it yields an error: attribute 'flakeModule' missing error).

I’ll really appreciate any answer regarding on how to get this project going or even offering me a guide on how to get good c: (I can’t seem to find resources that are similar to the project I have, and reading flakes of similar projects often times sends me in a google spiral :frowning: )

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
    flake-parts.url = "github:hercules-ci/flake-parts";
    haskell-flake.url = "github:srid/haskell-flake";
    ghc-wasm-meta.url = "git+"; #"";
  outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
    flake-parts.lib.mkFlake { inherit inputs; } {
      systems =;
      imports = [ inputs.haskell-flake.flakeModule inputs.ghc-wasm-meta.flakeModule];

      perSystem = { self', pkgs, ... }: {

        # Typically, you just want a single project named "default". But
        # multiple projects are also possible, each using different GHC version.
        haskellProjects.default = {
          # The base package set representing a specific GHC version.
          # By default, this is pkgs.haskellPackages.
          # You may also create your own. See
          basePackages = pkgs.haskellPackages;

          # Extra package information. See
          # Note that local packages are automatically included in `packages`
          # (defined by `defaults.packages` option).
          # packages = {
          #   aeson.source = ""; # Hackage version override
          #   shower.source = inputs.shower;
          # };
          # settings = {
          #   aeson = {
          #     check = false;
          #   };
          #   relude = {
          #     haddock = false;
          #     broken = false;
          #   };
          # };

          # devShell = {
          #  # Enabled by default
          #  enable = true;
          #  # Programs you want to make available in the shell.
          #  # Default programs can be disabled by setting to 'null'
          #  tools = hp: { fourmolu = hp.fourmolu; ghcid = null; };
          #  hlsCheck.enable = true;
          # };

        # haskell-flake doesn't set the default package, but you can do it here.
        packages.default = self'.packages.wasm;
1 Like

Maybe there are some pointers here ?

1 Like

I think you need clarify first what you want to do. It looks to me that you are trying to use two things that don’t really fit well together, so what is your ultimate goal there?

  • haskell-flake is an abstraction layer built on top of nixpkgs (?) which will enable you to benefit from Nixpkgs’ prebuilt GHCs and Hackage packages for building your packages as well as development environments.
  • ghc-wasm-meta provides a flake that allows you to use prebuilt binaries from GHC HQ’s CI of a GHC with the wasm backend. This works largely independently of the Nixpkgs Haskell infrastructure. Nixpkgs itself doesn’t provide a GHC with a wasm backend, since it is a nightmare to package.