Doom-emacs: [HOWTO] Trying to setup vterm module with NixOS

Created on 16 Nov 2019  路  13Comments  路  Source: hlissner/doom-emacs

What I want to achieve
I am trying to setup vterm in NixOS like it is described in libvterm README.org: https://github.com/hlissner/doom-emacs/blob/0eeb6b5092c4e5f5d7c2922c4ed2f645af9677a4/modules/term/vterm/README.org#libvterm. I am using system-wide installation of Emacs.

So it seems that Emacs sees recognizes that vterm is installed since when I try to do SPC o t, it doesn't try to compile it anymore. However, I receive the following error when trying to open it:

progn: Cannot open load file: No such file or directory, vterm

System information

emacs   version    26.3
        features   XPM JPEG TIFF GIF PNG RSVG SOUND DBUS GSETTINGS GLIB NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD
        build      nov 16, 2019
        buildopts  (--prefix=/nix/store/93mjaxzxjx2bs1dxzw8k8gqjjwqk8i6b-emacs-26.3 --disable-build-details --with-modules --with-x-toolkit=gtk3 --with-xft CFLAGS=-DMAC_OS_X_VERSION_MAX_ALLOWED=101200)
        windowsys  x
        daemonp    server-running
doom    version    2.0.9
        build      HEAD -> develop b7044b5f3 2019-11-15 23:56:08 -0500
system  type       gnu/linux
        config     x86_64-pc-linux-gnu
        shell      /run/current-system/sw/bin/zsh
        uname      Linux 4.19.84 #1-NixOS SMP Tue Nov 12 18:21:46 UTC 2019 x86_64
        path       (/nix/store/j7pc2i22djkfggxwljm8sqb9f9kr3694-emacs-packages-deps/bin ~/.emacs.d/bin ~/.local/bin /nix/store/d8syvga8qh97a62qzwmpmkf8wkdb33iw-kitty-0.14.6/bin /nix/store/9afq21w6jfyfh3ccic73zmb2g9wj0gzp-imagemagick-6.9.10-69/bin /nix/store/6y6nf62z23kv5xhhc4lx6wjhkd4x38lg-xsel-unstable-2018-01-10/bin /nix/store/ncdmjxng8s0g558kb4blks7yd1g82kz0-ncurses-6.1-20190112-dev/bin ~/bin /run/wrappers/bin ~/.nix-profile/bin /etc/profiles/per-user/thiagoko/bin /nix/var/nix/profiles/default/bin /run/current-system/sw/bin /nix/store/93mjaxzxjx2bs1dxzw8k8gqjjwqk8i6b-emacs-26.3/libexec/emacs/26.3/x86_64-pc-linux-gnu)
config  envfile    nil
        elc-files  0
        modules    (:completion company (ivy +fuzzy +prescient +icons) :ui doom doom-dashboard hl-todo hydra modeline nav-flash ophints (popup +all +defaults) treemacs vc-gutter vi-tilde-fringe window-select workspaces :editor (evil +everywhere) file-templates fold (format +onsave) multiple-cursors rotate-text snippets word-wrap :emacs (dired +icons) electric ibuffer vc :term vterm :tools docker (eval +overlay) flycheck (lookup +docsets) lsp magit pdf :lang cc clojure data elixir emacs-lisp go hy javascript markdown (org +dragndrop +ipython +pandoc +present) python ruby rust sh :config (default +bindings +smartparens))
        packages   (n/a)
        elpa       (n/a)

question elisp nixos resolved

Most helpful comment

As of c363791 I've made -f the default behavior. This should help folks avoid having to throw bin/doom commands at problems until something works.

To clarify these commands:

  • doom refresh regenerates autoloads files, rebuilds your load-path (the important part, as this will include any changes to load-path done by system packages), and ensures needed packages are installed and unneeded packaged aren't. It will also regenerate your envvar file, if you have one.

  • doom build rebuilds all your packages. i.e. it symlinks your packages from ~/.emacs.d/.local/straight/repos to ~/.emacs.d/.local/straight/build, then byte-compiles them.

  • doom build -f does nothing. There is no -f for doom build anymore and it should throw an "unrecognized switch" error if you tried it. Maybe you meant doom build -r?

  • doom build -r will only rebuild packages that need to be rebuilt.

  • doom upgrade updates Doom and your packages, then runs doom refresh.

All 13 comments

I was having that same issue. I made it work by adding the package config that's described in the README in my /etc/nixos/configuration.nix:

systemPackages = with pkgs; [
  # emacs    # no need for this, the next line includes emacs
  ((emacsPackagesNgGen emacs).emacsWithPackages (epkgs: [
    epkgs.emacs-libvterm
  ]))
];

Running rebuild switch:

sudo nixos-rebuild switch

At this point I was getting the error message that you are seeing:

progn: Cannot open load file: No such file or directory, vterm

I upgraded doom emacs:

~/.emacs.d/bin/doom upgrade

Restarted emacs and it SPC o t worked (I'm using the terminal version, emacs -nw).

This is my system config:

emacs   version    26.3
        features   XPM JPEG TIFF GIF PNG RSVG SOUND DBUS GSETTINGS GLIB NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD
        build      Nov 16, 2019
        buildopts  (--prefix=/nix/store/93mjaxzxjx2bs1dxzw8k8gqjjwqk8i6b-emacs-26.3 --disable-build-details --with-modules --with-x-toolkit=gtk3 --with-xft CFLAGS=-DMAC_OS_X_VERSION_MAX_ALLOWED=101200)
        windowsys  nil
        daemonp    server-running
doom    version    2.0.9
        build      HEAD -> develop 2ce6d3a66 2019-11-16 13:26:33 -0500
system  type       gnu/linux
        config     x86_64-pc-linux-gnu
        shell      /run/current-system/sw/bin/zsh
        uname      Linux 4.19.84 #1-NixOS SMP Tue Nov 12 18:21:46 UTC 2019 x86_64
        path       (/nix/store/j7pc2i22djkfggxwljm8sqb9f9kr3694-emacs-packages-deps/bin ~/.cargo/bin ./node_modules/.bin ./node_modules/.bin ~/.local/bin ~/.cargo/bin ./node_modules/.bin ./node_modules/.bin ~/.local/bin ~/bin /run/wrappers/bin ~/.nix-profile/bin /etc/profiles/per-user/jesuspc/bin /nix/var/nix/profiles/default/bin /run/current-system/sw/bin ~/.yarn/bin ~/mutable_node_modules/bin ~/.yarn/bin ~/mutable_node_modules/bin /nix/store/93mjaxzxjx2bs1dxzw8k8gqjjwqk8i6b-emacs-26.3/libexec/emacs/26.3/x86_64-pc-linux-gnu)
config  envfile    nil
        elc-files  0
        modules    (:completion company ivy :ui deft doom doom-dashboard doom-quit hl-todo modeline nav-flash neotree ophints (popup +all +defaults) treemacs vc-gutter vi-tilde-fringe window-select workspaces :editor (evil +everywhere) file-templates fold (format +onsave) multiple-cursors rotate-text snippets :emacs (dired +ranger +icons) electric vc :term eshell vterm :tools direnv docker eval flycheck flyspell (lookup +docsets) magit tmux :lang data emacs-lisp (haskell +intero) javascript ledger markdown (org +dragndrop +ipython +pandoc +present +gnuplot) rest ruby (rust +racer) sh web :config (default +bindings +smartparens))
        packages   (n/a)
        elpa       (n/a)

and nixos version: 19.09.1223.cb2cdab7136 (Loris)

Doing a git clean -fxd in ~/.doom.d directory seems to do the trick. I think that the problem was that Doom Emacs already tried to compile emacs-libvterm package and was in a inconsistent state.

Don't forget you have to run doom refresh -f after changing something on your system that you think Doom should be able to see (e.g. installing emacs packages through your OS).

Running doom upgrade will do this, indirectly, but it's overkill.

In this case, I tried doom refresh, doom build, doom build -f, doom upgrade, nothing worked until I cleaned my ~/.emacs.d directory with git clean -fxd. I don't remember if I tried doom refresh -f, however everything that I remember would maybe help I tried to do.

As of c363791 I've made -f the default behavior. This should help folks avoid having to throw bin/doom commands at problems until something works.

To clarify these commands:

  • doom refresh regenerates autoloads files, rebuilds your load-path (the important part, as this will include any changes to load-path done by system packages), and ensures needed packages are installed and unneeded packaged aren't. It will also regenerate your envvar file, if you have one.

  • doom build rebuilds all your packages. i.e. it symlinks your packages from ~/.emacs.d/.local/straight/repos to ~/.emacs.d/.local/straight/build, then byte-compiles them.

  • doom build -f does nothing. There is no -f for doom build anymore and it should throw an "unrecognized switch" error if you tried it. Maybe you meant doom build -r?

  • doom build -r will only rebuild packages that need to be rebuilt.

  • doom upgrade updates Doom and your packages, then runs doom refresh.

So I had the same problem with my two other systems running doom-emacs and NixOS. Even the new doom refresh from commit c363791 was not sufficient to fix, however running git clean -fxd in ~/.doom.d directory and a doom refresh afterwards seems to do the trick.

I don't know if this is a bug. @hlissner, WDYT?

It's hard to say. It doesn't make much sense to me. With the exception of eshell's runtime config files and your custom-set-variables block in $DOOMDIR/init.el, Doom doesn't keep any state in your $DOOMDIR.

I can only imagine either a) you've customized load-path using M-x customize (which is stored in the aforementioned custom-set-variables block) or b) you had some unstaged/committed configuration that played around with your load-path or some such. Both would have been deleted when you ran git clean -fxd.

Those are the only possibilities that come to mind atm.

@jesuspc 's solution isn't working for me. I'm on NixOS unstable, and added his config in my configuration.nix, and it is building fine. Did git clean -fxd/doom sync/doom up, but as soon as I do "SPC o t", it asks me to compile. Even adding libvterm and CMake to system config didn't work. Getting following error:

-- System libvterm not found: libvterm will be downloaded and compiled as part of the build process
CMake Error at CMakeLists.txt:56 (message):
  libtool not found.  Please install libtool


-- Configuring incomplete, errors occurred!
See also "/home/userName/.emacs.d/.local/straight/build/vterm/build/CMakeFiles/CMakeOutput.log".
make: *** No targets specified and no makefile found.  Stop.
/home/userName/.emacs.d/.local/straight/build/vterm

These days it would be:

systemPackages = with pkgs; [
  ((emacsPackagesNgGen emacs).emacsWithPackages (epkgs: [
    epkgs.vterm
  ]))
];

MELPA name changed. Not sure if this is your issue.

I have something similar working for me on NixOS 20.03

@martinbaillie I had another emacs entry in my config. Removing that and then adding your solution worked perfectly. Thanks a lot!

It's not working for me on nix-darwin.

This config works for me, hopping between NixOS and macOS: https://github.com/martinbaillie/dotfiles/blob/master/modules/editors/emacs.nix#L9-L12

I'm not in NixOS, I hope I won't be charged with stealing this thread (if I am feel free to delete this comment), but it took me over an hour to solve a related issue on pop_os. I was getting the same error that payasrelekar mentions above. I had already done sudo apt install libtool, but thanks to https://superuser.com/a/1011206 I found out I also needed to sudo apt install libtoo-bin, which solved it for me

Was this page helpful?
0 / 5 - 0 ratings