2

I have a fresh NixOS installation, and I want to use my custom XMonad configuration. However, I'm getting the following error:

$ xmonad --recompile
XMonad will use ghc to recompile, because "/home/amy/.xmonad/build" does not exist.
Error detected while loading xmonad configuration file: /home/amy/.xmonad/xmonad.hs

xmonad.hs:1:1: error:
    Could not find module ‘XMonad’
    Use -v to see a list of the files searched for.
  |
1 | import XMonad
  | ^^^^^^^^^^^^^

Here are the relevant parts of my configuration.nix:

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
    bash
    dmenu2
    dzen2
    emacs
    firefox
    gitAndTools.gitFull
    haskellPackages.xmonad
    haskellPackages.xmonad-contrib
    haskellPackages.xmonad-extras
    gcc
    ghc
    stack
    x11
    xmonad-with-packages
    xorg.libX11
    xsel
    wget
  ];

  . . .

  services.xserver = {
    enable = true;
    layout = "ie";
    windowManager.xmonad = {
      enable = true;
      enableContribAndExtras = true;
      extraPackages = haskellPackages: [
        haskellPackages.xmonad
        haskellPackages.xmonad-contrib
        haskellPackages.xmonad-extras
      ];
    };
  };
#  windowManager.default = "xmonad";

I have read NixOS beginner: xmonad and haskellmode in NixOS 14.04, but I already have windowManager.xmonad.enableContribAndExtras = true; in my configuration.nix.

EDIT: Just to clarify, I am on NixOS, but I am not using Nix to build my XMonad configuration. I am doing things the ordinary XMonad way: I have a .xmonad directory with my configuration in xmonad.hs, and I am running xmonad --recompile to build it.

EDIT: When I look for the relevant packages as root, I find them.

# nix-env -q
xmonad-0.14.2
xmonad-contrib-0.14
xmonad-extras-0.14

But as an ordinary user, the following command returns nothing.

$ nix-env -q

How do I make these packages visible to a non-root account?

EDIT: Strangely, when I rebooted, XMonad magically worked, compiling my configuration without problems. I don't know why rebooting helped, because I'd done nixos-rebuild switch several times.

mhwombat
  • 8,026
  • 28
  • 53
  • Could you include the output of `ghc-pkg list`? It probably won't show XMonad. You probably need to add `ghc` with packages as described in this question: https://stackoverflow.com/questions/47377748/how-can-i-install-a-haskell-library-to-be-accessible-via-ghci-with-nixos – Chris Stryczynski Nov 23 '18 at 15:10
  • I think the way XMonad is packaged on Nixos is really convoluted. If you build it independently it's a lot easier to understand imo. I followed this guide: https://functor.tokyo/blog/2018-02-16-setup-xmonad-on-nixos – Chris Stryczynski Nov 23 '18 at 15:13
  • @ChrisStryczynski thank you for your suggestions; I learned a lot from them. Strangely, when I rebooted, XMonad magically worked, compiling my configuration without problems. I don't know why rebooting helped, because I'd done `nixos-rebuild switch` several times. But if you'd like to turn your comments into an answer, I'll happily accept it. – mhwombat Nov 27 '18 at 10:08
  • No worries glad to hear it's working. Possibly it was recompiling the old config / executable somehow. – Chris Stryczynski Nov 27 '18 at 21:13
  • 1
    As an aside, `nix-env -q` only shows packages installed into that profile. So `nix-env -q` as a user won't show you programs that root installed using `nix-env -i` even though those programs in your `$PATH`, and even `root` won't see packages that are were installed via `environment.systemPackages`. – Teo Klestrup Röijezon Dec 13 '18 at 20:38

1 Answers1

1

I know this is old but this search keep appearing on tops

The reason why this happens is because you installed xmonad twice

First one is just xmonad without any knowledge of other packages on your environment (that's the whole purpose of nix, remember, building isolated and reproducible environments)

  environment.systemPackages = with pkgs; [
    ...
    haskellPackages.xmonad
    ...
  ];

The second one is installed by enabling the service, and is called vanilla A.K.A xmonad-with-packages on the service configuration file:

services.xserver = {
    windowManager.xmonad = {
      enable = true;
    };
  };

xmonad-with-packages is actually a wrapper script that sets the needed environment variables so that xmonad can see the extraPackages you added

TLDR:

  1. Both packages output an xmonad binary
  2. First one has no access to your env
  3. Second one does
  4. When you run xmonad --recompile, the first one is ran, no luck
  5. When xserver runs xmonad it is actually running the vanilla binary from xmonad-with-packages (plus your extraPackages) (See code below, and link here)
  xmonad = if (cfg.config != null) then xmonad-config else xmonad-vanilla;

This is for nixpkgs, but i just had the same problem with home-manager since a few days

Proof

Inspecting xmonad

which xmonad

/home/hao/.nix-profile/bin/xmonad

I know it’s in my profile…, but where?

which xmonad | xargs readlink

/nix/store/yx0kb7i209ffh20qmxpbvmllb32lq7rr-home-manager-path/bin/xmonad

Ok…, installed by home-manager, but where is it?

which xmonad | xargs readlink | xargs readlink

/nix/store/g7f0v21jmi9smh1q1f6fw050r76nzb1p-ghc-8.10.6-with-packages/bin/xmonad

Is it really xmonad or a symlink?

file /nix/store/g7f0v21jmi9smh1q1f6fw050r76nzb1p-ghc-8.10.6-with-packages/bin/xmonad

/nix/store/g7f0v21jmi9smh1q1f6fw050r76nzb1p-ghc-8.10.6-with-packages/bin/xmonad: symbolic link to /nix/store/0lxxi3hrs49fiil29xw6gjx09ad3nf2n-xmonad-0.15/bin/xmonad

Is it really xmonad or a symlink? x2

file /nix/store/0lxxi3hrs49fiil29xw6gjx09ad3nf2n-xmonad-0.15/bin/xmonad

/nix/store/0lxxi3hrs49fiil29xw6gjx09ad3nf2n-xmonad-0.15/bin/xmonad: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /nix/store/9bh3986bpragfjmr32gay8p95k91q4gy-glibc-2.33-47/lib/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, stripped

^ Save that path, you can see it’s actually pointing to the xmonad binary:

Now enter the monad (with packages):

nix-shell -p xmonad-with-packages

For starters, the derivation is pointing elsewhere, not to my home-environment, but directly to the nix-store:

which xmonad

/nix/store/6n1wh9ky7ydbd2ii5877nly9xbrqz4m9-xmonad-with-packages-8.10.6/bin/xmonad

And we now see not a binary file but a bash script

file /nix/store/6n1wh9ky7ydbd2ii5877nly9xbrqz4m9-xmonad-with-packages-8.10.6/bin/xmonad

/nix/store/6n1wh9ky7ydbd2ii5877nly9xbrqz4m9-xmonad-with-packages-8.10.6/bin/xmonad: a /nix/store/dpjnjrqbgbm8a5wvi1hya01vd8wyvsq4-bash-4.4-p23/bin/bash -e script, ASCII text executable

And if you look at the contents, you’ll see that it's actually using the same xmonad from above (see below, what does exec runs), except it adds all the extraPackages (the NIX_GHC path) for us:

which xmonad | xargs cat


! /nix/store/dpjnjrqbgbm8a5wvi1hya01vd8wyvsq4-bash-4.4-p23/bin/bash -e
export NIX_GHC='/nix/store/sca07cyap7rqkxk4c7sqkvn94bsfaaiz-ghc-8.10.6-with-packages/bin/ghc'
export XMONAD_XMESSAGE='/nix/store/jg3adhj3kpqm8dcrgb95nn5c5k5z61yx-xmessage-1.0.5/bin/xmessage'
exec "/nix/store/sca07cyap7rqkxk4c7sqkvn94bsfaaiz-ghc-8.10.6-with-packages/bin/xmonad"  "@"

What does exec run?

file /nix/store/sca07cyap7rqkxk4c7sqkvn94bsfaaiz-ghc-8.10.6-with-packages/bin/xmonad

/nix/store/sca07cyap7rqkxk4c7sqkvn94bsfaaiz-ghc-8.10.6-with-packages/bin/xmonad: symbolic link to /nix/store/0lxxi3hrs49fiil29xw6gjx09ad3nf2n-xmonad-0.15/bin/xmonad

Let’s compile

xmonad --recompile

XMonad will use ghc to recompile, because "/home/hao/.xmonad/build" does not exist.
XMonad recompilation process exited with success!

But out of our safe space first

exit

Using our home-manager derivation

xmonad --recompile 2>&1

XMonad will use ghc to recompile, because "/home/hao/.xmonad/build" does not exist.
Error detected while loading xmonad configuration file: /home/hao/.xmonad/xmonad.hs

xmonad.hs:4:1: error:
    Could not find module ‘XMonad’
    Perhaps you meant DsMonad (needs flag -package-key ghc-8.10.6)
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
4 | import           XMonad                                 hiding (config,workspaces)
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:8:1: error:
    Could not find module ‘XMonad.Hooks.DynamicLog’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
8 | import           XMonad.Hooks.DynamicLog
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:9:1: error:
    Could not find module ‘XMonad.Hooks.ManageDocks’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
  |
9 | import           XMonad.Hooks.ManageDocks
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:10:1: error:
    Could not find module ‘XMonad.StackSet’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
10 | import qualified XMonad.StackSet                 as W
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:11:1: error:
    Could not find module ‘XMonad.ManageHook’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
11 | import           XMonad.ManageHook
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:12:1: error:
    Could not find module ‘XMonad.Util.NamedScratchpad’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
12 | import           XMonad.Util.NamedScratchpad
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:13:1: error:
    Could not find module ‘XMonad.Util.EZConfig’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
13 | import           XMonad.Util.EZConfig
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:14:1: error:
    Could not find module ‘XMonad.Actions.CycleWS’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
14 | import           XMonad.Actions.CycleWS                        (shiftTo, moveTo, Direction1D(..), WSType(..))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:15:1: error:
    Could not find module ‘XMonad.Actions.Commands’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
15 | import           XMonad.Actions.Commands
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:16:1: error:
    Could not find module ‘XMonad.Actions.ShowText’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
16 | import           XMonad.Actions.ShowText
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:17:1: error:
    Could not find module ‘XMonad.Layout.Fullscreen’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
17 | import           XMonad.Layout.Fullscreen
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:18:1: error:
    Could not find module ‘XMonad.Layout.NoBorders’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
18 | import           XMonad.Layout.NoBorders
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:19:1: error:
    Could not find module ‘XMonad.Hooks.ManageHelpers’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
19 | import           XMonad.Hooks.ManageHelpers
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:20:1: error:
    Could not find module ‘XMonad.Actions.CopyWindow’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
20 | import           XMonad.Actions.CopyWindow
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:22:1: error:
    Could not find module ‘XMonad.Actions.Navigation2D’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
22 | import           XMonad.Actions.Navigation2D
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:23:1: error:
    Could not find module ‘XMonad.Util.Run’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
23 | import           XMonad.Util.Run                               (spawnPipe)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:24:1: error:
    Could not find module ‘XMonad.Util.NamedWindows’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
24 | import           XMonad.Util.NamedWindows                      (getName, unName)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:27:1: error:
    Could not find module ‘XMonad.Util.ExtensibleState’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
27 | import qualified XMonad.Util.ExtensibleState     as XS
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:28:1: error:
    Could not find module ‘XMonad.Util.Timer’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
28 | import           XMonad.Util.Timer
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:31:1: error:
    Could not find module ‘XMonad.Actions.UpdateFocus’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
31 | import           XMonad.Actions.UpdateFocus
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:32:1: error:
    Could not find module ‘XMonad.Layout.SimpleFloat’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
32 | import           XMonad.Layout.SimpleFloat
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:33:1: error:
    Could not find module ‘XMonad.Layout.PerWorkspace’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
33 | import           XMonad.Layout.PerWorkspace                    (onWorkspace)
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:34:1: error:
    Could not find module ‘XMonad.Layout.Magnifier’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
34 | import           XMonad.Layout.Magnifier         as Mag
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:35:1: error:
    Could not find module ‘XMonad.Util.Loggers’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
35 | import           XMonad.Util.Loggers
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:36:1: error:
    Could not find module ‘XMonad.Layout.LayoutCombinators’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
36 | import           XMonad.Layout.LayoutCombinators               (JumpToLayout(..))
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:39:1: error:
    Could not find module ‘XMonad.Actions.FloatSnap’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
39 | import           XMonad.Actions.FloatSnap
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:40:1: error:
    Could not find module ‘XMonad.Util.WorkspaceCompare’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
40 | import qualified XMonad.Util.WorkspaceCompare    as W
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

xmonad.hs:42:1: error:
    Could not find module ‘XMonad.Layout.Gaps’
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
42 | import           XMonad.Layout.Gaps
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Please check the file for errors.
Eduardo V.
  • 21
  • 2