Posts tagged "guix":
Fix error with Cider Clojure REPL in Emacs on Guix
I am currently reading Clojure for the brave and true by Daniel Higginbotham and in Chapter 2 about how to use Emacs for Clojure, there are instructions on how to set up Emacs with Cider, a Clojure REPL. I tried installing the package with a use-package configuration with :ensure t and I got the package. However, when I tried using it as the book instructed, I just got an error. I then realised the need for OpenJDK and Clojure and installed those with my home-config.scm file in Guix. I tried again and I still got the same error. I then tried installing emacs-cider from Guix as well with the hope that maybe there was some kind of incompatibility between OpenJDK, Clojure and Cider that was ironed out in the guix package. It still did not work.
I tried looking up the error and found a blog post that suggested installing OpenJDK non-Guixily by downloading a binary and adding it to the $PATH which solved the problem for that user. I did not really want this, since I really like the idea of installing my whole system with a scheme file or two in a reproducible way. (I'm not there yet, but I hope to get there over time. I just started using Guix as my main distro a few weeks ago. For now, after installing Guix System or Guix on another distro, I do some manual work and then run a Shell script to set up a few folders and run the command that applies my home-config.)
Tonight, a day later, I DuckDuckWent again and found another blog post about Clojure that told me that since there are three outputs for the openjdk package, to get everything I would need for Clojure, I should install openjdk:jdk, not simply openjdk which would give me openjdk:out. In addition, I also added openjdk:doc since I am a fan of having as much documentation as possible available on my local machine. I saw a video where that documentation was read from inside Cider a couple of days ago, so I thought it might come in handy. Come to think of it, maybe that was accessed over the internet, not from the local machine. Anyway, it doesn't hurt to have some documentation.
And now, everything just works. Turns out the problem was just user error. Whenever there are multiple outputs of a package in Guix, it is important to know what you get with each output and choose accordingly. As someone who just recently switched my main machine to Guix, this is very useful information that I had not seen before. I thought I would write this up in a blog post so people out there trying to fix the same problem have a chance of finding a solution faster than I did, and for my own future reference.
Adventures in Guix
I have been interested in the Guix functional package manager and GNU distribution for a long time. It has some brilliant features like being able to roll-back to a previous generation of your system if an update fails, easy spinning up of development containers where you can functionally and reproducibly install the dependencies you need for your project and you can configure your whole system with Guile Scheme (a dialect of Lisp). I have tried Guix from time to time with varying results. Since I have been busy the last few years learning technologies I need at work, haven't had the time to learn Guix as well until now. However, I have found some time and energy lately to play with Guix and when I did, things seemed to work a lot better than my previous attempts. Spending the time to read up on the documentation helped, in addition to the many contributions by the Guix community to improve the distro / package manager since my previous attempts.
I have just started to use Guix on my main machine. As with anything new and different, there has been some hiccups along the way. For example, hunspell-nb which is the spell checker I use for Norwegian Bokmål isn't packaged for Guix. However, aspell-nb is and the only reason I switched from aspell to hunspell was that I also use Emacs on Windows at work (native Windows Emacs since WSLg doesn't work properly and I need GUI Emacs) and native aspell-nb is hard to get on Windows, but Hunspell-nb can be used if you install LibreOffice and copy some files after installing hunspell from chocolatey (where of course hunspell-nb is not packaged either). I prefer not having if-statements in my Emacs config if I can avoid it, so I switched to hunspell on GNU/Linux as well, but since it is not pacakged in Guix, I reverted the config back to when I used aspell on GNU/Linux and Hunspell on Windows.
However, that did not work. At every startup, Emacs complained that it could not read the nb dictionary from the address to the aspell-package in my current home-config. I tried everything, but it just didn't work. I then tried M-x ispell-change-dictionary and hit tab to have a look at the suggested dictionaries. Turns out that aspell-nb on Guix supplies a dictionary it calls no, unlike on every other distro, where it is called nb. This makes absolutely no sense since there are two Norwegian written languages, Norwegian Bokmål (nb) and Norwegian Nynorsk (nn), but no written language called just Norwegian (no). Packages that supply both tend to be called no, like hunspell-no which supplies nb_NO and nn_NO. It is easy to change my config to use the no dictionary and my emo-ispell-toggle function to toggle between no and british on GNU/Linux. I had a look at the package definition for aspell-nb, but it seemed to just supply the upstream package as far as I could tell as a very inexperienced Guix-user.
Another strange thing is that mpc mode in Emacs does not want to speak with mpd. It also took me a while to understand that mpd was packaged for Guix since I looked for mpd, but the package is called mpd-mpc in Guix. The strange thing is that my own emo-play-album function in Emacs that uses mpc shell commands work fine from the same Emacs that give me an error that it could not communicate with mpd when I try to show the songs in an album in mpc mode. I use the same mpd config file as on other distros where it does work. I tried changing some settings in the config file to see if I was able to fix it, but no luck thus far.
I also miss the frogr package for easy uploading of photos and adding of metadata to Flickr. When I get a bit more experienced, maybe I can contribute a package definition for it?
Another thing I have noticed is that Guix calls my locale in the LANG environment variable nb_NO.utf8, not nb_NO.UTF-8 like every other distro. I wonder if this might break localisation in programs that use the environment variable $LANG to choose which localisation to use, but I don't really know how this works so this might not be a problem at all. It seems strange and random, but maybe there are good reasons for it that I don't know.
Except for these new user problems, the experience is nice. After some tweaking and trial and error, I now have a very simple and basic system config that just installs the absolute minimum I need to have at the system level, and then I use Guix home to deploy my user packages and services. I have some Bash scripts in my installscripts repository as well as my Scheme config files that I can use to set up a system, either on Guix or on a "foreign distro" after an install with just basic system tools. Ideally, I would do that with Scheme in the system config, but I don't know Guix and Scheme well enough to do that yet. I'll get there over time. Using Guix as a package manager on top of another distro can be useful if I need to use Secureboot which Guix does not support, for example for a dual boot with Windows 11 which demands Secureboot. I really like that Guix adheres to the Free Software Foundation's Free System Distribution Guidelines, but when used on hardware I have not chosen myself, it can be useful to have another distro underneath that supplies non-free drivers for that hardware as well as support for Secureboot. I am slowly climbing up the freedom ladder in my personal computing and at every step, there is less lock-in, privacy invasion and enshittification, and more freedom and empowerment.