Stream: haskell-flake

Topic: Removing IFD


view this post on Zulip Srid (Dec 05 2023 at 14:47):

@Aravind Gopal opened https://github.com/srid/haskell-flake/pull/204 which removes the need for IFD in local packages.

But IFD is still used in dependency overrides; for eg., packages.foo.source will use IFD, via callCabal2nix or callHackage. The open question here is: how do we solve it?

cc @Shivaraj B H

view this post on Zulip Srid (Dec 05 2023 at 14:52):

We may have to borrow some ideas from https://horizon-haskell.net/

view this post on Zulip Srid (Dec 11 2023 at 15:31):

From @Aravind Gopal

maintaining package sets seems like the only possible way for this.

which is same as in horizon-haskell.

Hmm, I'll take a look at this as a next project. Ideally we want to define package sets in Nix expressions itself, and stick close to nixpkgs (unlike horizon).

view this post on Zulip Srid (Jan 09 2024 at 06:23):

Here's one way to solve this: https://github.com/srid/haskell-flake/pull/204#pullrequestreview-1809771568

Summary: copy over the hackage2nix/ callCabal2nix generated default.nix to a directory, and have the developer commit that to Git.

view this post on Zulip Srid (Jan 09 2024 at 06:24):

It looks like this (note: we overrode relude to test dependency override),

image.png

❯ cat .haskellSrc2nix/haskell-template.nix
{ mkDerivation, aeson, async, base, data-default, directory
, filepath, lib, mtl, optics-core, profunctors, relude, shower
, time, with-utf8
}:
mkDerivation {
  pname = "haskell-template";
  version = "0.1.0.0";
  src = /nix/store/51shzaxpi2abz3hfp4q05kcd1lls0lba-source;
  isLibrary = false;
  isExecutable = true;
  executableHaskellDepends = [
    aeson async base data-default directory filepath mtl optics-core
    profunctors relude shower time with-utf8
  ];
  homepage = "https://srid.ca/haskell-template";
  description = "A template for Haskell projects using Nix";
  license = lib.licenses.mit;
  mainProgram = "haskell-template";
}

But as you can see that hardcoded src = /nix/store/51shzaxpi2abz3hfp4q05kcd1lls0lba-source; is problematic. Looks like we have to do some hacky patching of this generated nix to have the src point back to the actual path.

view this post on Zulip Shivaraj B H (Jan 09 2024 at 06:33):

Looks like we have to do some hacky patching of this generated nix to have the src point back to the actual path.

AFAIR calling cabal2nix executable results in a relative path rather than a path linking to the /nix/store for local packages.

view this post on Zulip Srid (Jan 09 2024 at 07:04):

But note we are using callCabal2nix which passes nix store paths,

cf. src in https://github.com/NixOS/nixpkgs/blob/6a9382b8d1d9531be1a2fd611f3f91f30fb38678/pkgs/development/haskell-modules/make-package-set.nix#L140


Last updated: Nov 21 2024 at 08:50 UTC