【问题标题】:Could not find module ‘XMonad’找不到模块“XMonad”
【发布时间】:2019-04-25 03:56:29
【问题描述】:

我有一个全新的 NixOS 安装,我想使用我的自定义 XMonad 配置。但是,我收到以下错误:

$ 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
  | ^^^^^^^^^^^^^

这是我的 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";

我已阅读 NixOS beginner: xmonad and haskellmode in NixOS 14.04,但我的 configuration.nix 中已经有 windowManager.xmonad.enableContribAndExtras = true;

编辑: 澄清一下,我使用的是 NixOS,但我没有使用 Nix 来构建我的 XMonad 配置。我用普通的 XMonad 方式做事:我有一个 .xmonad 目录,我的配置在 xmonad.hs,我正在运行 xmonad --recompile 来构建它。

编辑:当我以 root 身份查找相关包时,我会找到它们。

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

但是作为普通用户,下面的命令什么都没有返回。

$ nix-env -q

如何使这些包对非 root 帐户可见?

编辑:奇怪的是,当我重新启动时,XMonad 神奇地工作,编译我的配置没有问题。我不知道为什么重启会有所帮助,因为我已经多次完成了 nixos-rebuild switch。

【问题讨论】:

  • 能否包含ghc-pkg list 的输出?它可能不会显示 XMonad。您可能需要添加 ghc 与此问题中所述的软件包:stackoverflow.com/questions/47377748/…
  • 我认为 XMonad 在 Nixos 上的打包方式非常复杂。如果您独立构建它,则更容易理解 imo。我遵循了本指南:functor.tokyo/blog/2018-02-16-setup-xmonad-on-nixos
  • @ChrisStryczynski 谢谢你的建议;我从他们身上学到了很多。奇怪的是,当我重新启动时,XMonad 神奇地工作,编译我的配置没有问题。我不知道为什么重新启动会有所帮助,因为我已经多次完成nixos-rebuild switch。但如果你想把你的 cmets 变成一个答案,我很乐意接受。
  • 不用担心,很高兴听到它正在工作。可能它正在以某种方式重新编译旧的配置/可执行文件。
  • 顺便说一句,nix-env -q 仅显示安装到该配置文件中的软件包。因此,nix-env -q 作为用户不会向您显示使用nix-env -i 安装的根程序,即使您的$PATH 中的那些程序,甚至root 也不会看到通过environment.systemPackages 安装的软件包。

标签: nixos xmonad


【解决方案1】:

我知道这是旧的,但这个搜索一直出现在顶部

出现这种情况的原因是因为你安装了两次 xmonad

第一个只是 xmonad,不知道您环境中的其他包(这是 nix 的全部目的,记住,构建隔离 和可重现的环境

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

第二个是通过启用服务安装的,在服务配置文件中称为vanilla A.K.A xmonad-with-packages

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

xmonad-with-packages实际上是一个wrapper script,它设置了所需的环境变量,以便xmonad可以看到你添加的extraPackages

TLDR:

  1. 两个包都输出xmonad二进制
  2. 第一个无法访问您的环境
  3. 第二个
  4. 当你运行xmonad --recompile时,第一个运行,没有运气
  5. 当 xserver 运行 xmonad 时,它实际上是在运行来自 xmonad-with-packagesvanilla 二进制文件(加上您的 extraPackages)(参见下面的代码和 link here
  xmonad = if (cfg.config != null) then xmonad-config else xmonad-vanilla;

这是为 nixpkgs 准备的,但我几天前就遇到了与 home-manager 相同的问题

证明

检查xmonad

which xmonad

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

我知道它在我的个人资料中……但是在哪里?

which xmonad | xargs readlink

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

好的...,由home-manager 安装,但它在哪里?

which xmonad | xargs readlink | xargs readlink

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

它真的是 xmonad 还是符号链接?

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

它真的是 xmonad 还是符号链接? 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

^ 保存那个路径,你可以看到它实际上指向了xmonad 二进制文件:

现在输入 monad(带有包):

nix-shell -p xmonad-with-packages

首先,推导指向其他地方,而不是我的家庭环境, 但直接到nix-store:

which xmonad

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

我们现在看到的不是二进制文件而是 bash 脚本

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

如果你看一下内容,你会发现它实际上使用的是相同的 上面的 xmonad(见下文,exec 运行什么),除了它为我们添加了所有 extraPackagesNIX_GHC 路径):

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"  "@"

exec 运行什么?

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

让我们编译

xmonad --recompile

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

但首先要离开我们的安全空间

exit

使用我们的home-manager 推导

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.

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-15
    • 2018-02-21
    • 2021-07-23
    相关资源
    最近更新 更多