You are not logged in.

#1 2020-08-12 22:02:35

lostwanderer
Member
Registered: 2020-08-12
Posts: 5

[SOLVED] Haskell source code in xmobar config causes failed import

Hello everyone. This is my first post to the forums, so if there is something that I missed
while reading the guidelines, please let me know. Also, I made a similar post in the
xmonad hacking thread. However, the thread seemed to be pretty inactive, and I thought
making a new topic would be better as a resource for others who encounter this problem.
My apologies if this is considered cross posting.

My problem is that I want to write my Xmobar config in haskell source code, like this:

import Xmobar

config :: Config
config = defaultConfig {
  ...
}

main :: IO ()
main = xmobar config

When I try to run

$ xmobar xmobar.hs

I get the error:

Error detected while loading xmobar configuration file: ./xmobar.hs

xmobar.hs:19:1: error:
    Could not find module ‘Xmobar’
    There are files missing in the ‘xmobar-0.35’ package,
    try running 'ghc-pkg check'.
    Use -v (or `:set -v` in ghci) to see a list of the files searched for.
   |
19 | import Xmobar
   | ^^^^^^^^^^^^^

Please check the file for errors.

I believe that this is because "arch's xmobar distribution doesn't register the binary along side
the library," as this unrelated github issue mentions. I also found another github issure which mentions
this as well.

I understand that the two github user were able to solve the problem, but I don't fully understand
what they did. I would really appreciate any input to get this working.

Thanks to all in advance.

Last edited by lostwanderer (2020-08-14 18:52:42)

Offline

#2 2020-08-14 18:46:02

lostwanderer
Member
Registered: 2020-08-12
Posts: 5

Re: [SOLVED] Haskell source code in xmobar config causes failed import

Ok. I think I have figured out how to get this to work. The problem
is related to ghc not compiling the Haskell source config with the
-dynamic flag. In both the xmobar and xmonad source code, when
they compile the config file, they don't pass the -dynamic flag to
ghc. However, xmonad circumvents this by patching the source in
their PKGBUILD, but xmobar does not, (xmonad PKGBUILD vs
xmobar PKGBUILD). I will see if the maintainer can change this.
As of xmobar-0.35-23, this has not been put in place.

Until then, you can work around the problem by downloading the
source and adding the dynamic flag here:
./xmobar/src/Xmobar/App/Compile.hs. Then, recompile and install.

Offline

#3 2021-10-13 14:41:55

thiagomm
Member
Registered: 2021-10-13
Posts: 1

Re: [SOLVED] Haskell source code in xmobar config causes failed import

I've submited an AUR package to solve this problem. It compiles xmobar using -dynamic flag, just like you said. https://aur.archlinux.org/packages/xmobar-dynamic

Offline

#4 2021-12-05 22:14:09

jfjfjf
Member
Registered: 2021-12-05
Posts: 1

Re: [SOLVED] Haskell source code in xmobar config causes failed import

Thanks for the AUR. Works like a charm.

Offline

Board footer

Powered by FluxBB