Nixpkgs haskell module not visible

I’m trying to use System.Linux.Netlink.Simple from the netlink hackage package with nix via

$ nix-shell -p "haskell.packages.ghc8107.ghcWithPackages (pkgs: with pkgs; [ netlink ])"

[nix-shell:~/git/github.com/Ongy/netlink-hs/Examples]$ ghc --make ListAddrs.hs
[1 of 1] Compiling Main             ( ListAddrs.hs, ListAddrs.o )

ListAddrs.hs:7:1: error:
    Could not find module `System.Linux.Netlink.Simple'
    Perhaps you meant
      System.Linux.Netlink.Route (from netlink-1.1.1.0)
      System.Linux.Netlink.C
      System.Linux.Netlink.Helpers (from netlink-1.1.1.0)
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
7 | import qualified System.Linux.Netlink.Simple as NLS
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

I get the same error message with cabal install netlink on ubuntu

But I did workaround this on ubuntu after a cabal build and then a cabal install inside a local git checkout of netlink.

How can I solve this with nix(-shell) ?

The problem is that the netlink package in version 1.1.1.0 exposes no such module.

You can, in principle override netlink to use a git revision instead in, say , a shell.nix:

{ pkgs ? import <nixpkgs> {} }:

let
  myHaskellPackages = pkgs.haskellPackages.override {
    overrides = self: super: {
      netlink = haskell.lib.compose.overrideSrc {
        src = /* insert appropriate fetchFromGitHub call here */;
        version = "git";
      };
    };
  };

in

pkgs.mkShell {
  packages = [
    (myHaskellPackages.ghc.withPackages (p: [ p.netlink ]))
  ];
}
2 Likes

Thanks @sternenseemann! Your solution worked.