XMonad on Nix - cannot find xmonad-contrib

I am trying to use nix on ubuntu and XMonad is my window manager. It works fine for me on a single host using nixOS, but I have a second device that is not ready for nixOS yet. nix on top of Ubuntu basically works well there, but xmonad cannot find helper libraries.

Relevant packages installed:

$ nix-env -q | grep xmonad
xmonad-0.13
xmonad-contrib-0.13
xmonad-extras-0.12.1

But recompile my xmonad.hs, it cannot find the lib tabs:

$ xmonad --recompile
Error detected while loading xmonad configuration file: /home/martyn/.xmonad/xmonad.hs

xmonad.hs:32:1: error:
Failed to load interface for ‘XMonad.Layout.NoBorders’
Use -v to see a list of the files searched for.

...

Please check the file for errors.

The corresponding files are installed:

$ ls /nix/store/*xmonad-contrib*/lib/**/NoBorders*
/nix/store/4xrrwsm6362xkn9jn1b17kd891kv9z3a-xmonad-contrib-0.13/lib/ghc-8.0.2/xmonad-contrib-0.13/XMonad/Actions/NoBorders.dyn_hi
/nix/store/4xrrwsm6362xkn9jn1b17kd891kv9z3a-xmonad-contrib-0.13/lib/ghc-8.0.2/xmonad-contrib-0.13/XMonad/Actions/NoBorders.hi
/nix/store/4xrrwsm6362xkn9jn1b17kd891kv9z3a-xmonad-contrib-0.13/lib/ghc-8.0.2/xmonad-contrib-0.13/XMonad/Layout/NoBorders.dyn_hi
/nix/store/4xrrwsm6362xkn9jn1b17kd891kv9z3a-xmonad-contrib-0.13/lib/ghc-8.0.2/xmonad-contrib-0.13/XMonad/Layout/NoBorders.hi

By adding xmonad-contrib to my nixpkgs config.nix, I got these libraries added to the ghc package registry:

$ cat ~/.config/nixpkgs/config.nix 
with (import <nixpkgs> {});
{
  packageOverrides = pkgs: with pkgs; {

    myHaskellEnv = pkgs.haskellPackages.ghcWithPackages (haskellPackages: with haskellPackages; [ xmonad-contrib ]);
  };
}
$ nix-env -iA nixpkgs.myHaskellEnv
$ ghc-pkg list | grep xmonad
  xmonad-0.13
  xmonad-contrib-0.13
$

with this, this ghc (i) works well:

$ /nix/store/7mkxsq7ydqcgnjbs59v1v47wfxpwrav5-ghc-8.0.2-with-packages/bin/ghc ~/.xmonad/xmonad.hs
[1 of 1] Compiling Main             ( /home/martyn/.xmonad/xmonad.hs, /home/martyn/.xmonad/xmonad.o ) [flags changed]
Linking /home/martyn/.xmonad/xmonad ...

But even the xmonad version in this directory cannot find libs:

$ /nix/store/7mkxsq7ydqcgnjbs59v1v47wfxpwrav5-ghc-8.0.2-with-packages/bin/xmonad --recompile
Error detected while loading xmonad configuration file: /home/martyn/.xmonad/xmonad.hs

xmonad.hs:32:1: error:
  Failed to load interface for ‘XMonad.Layout.NoBorders’
  Use -v to see a list of the files searched for.

, ghc, , ~/.xmonad/xmonad-x86_64-linux . , , , ?

+4
1

, .

, xmonad-with-packages , ghc-with-packages.

, xmonad, ~/.nixpkgs/config.nix:

{
  packageOverrides = pkgs_: with pkgs_; {
    xmonad            = import ./xmonad { nixpkgs = pkgs_; };
  };
}

~/.nixpkgs/xmonad/default.nix :

{ nixpkgs ? import <nixpkgs> {} }:

nixpkgs.xmonad-with-packages.override {
  packages = hPkgs: with hPkgs; [ xmonad-contrib ];
}

xmonad, , , !

+2

Source: https://habr.com/ru/post/1680199/


All Articles