Installing Lazarus/Free Pascal on NixOS.
The particularity of the independent Dutch Linux distribution NixOS is that the entire operating system, including the kernel, applications, system packages and configuration files, are built by the Nix package manager. Nix stores all packages in isolation from each other. There are no /bin, /sbin, /lib or /usr directories and all packages are kept in /nix/store instead. As a result, some common tasks, including the installation of software, have to be done somewhat differently as on other Linux systems. I write about this in my article Some tips concerning NixOS. | |
This tutorial is based on my experience with NixOS 22.11 Raccoon. It should apply to other versions of the operating system, too. | |
Open a terminal and run the following command to search for Lazarus packages sudo nix-env -qa 'lazarus.*' I don't know why it took a rather long time before something happened. Anyway, there were 2 packages found: lazarus-gtk2-2.2.2-0 and lazarus-qt5-2.2.2-0. |
|
As I use the Gnome desktop, I decided to install the package lazarus-gtk2-2.2.2-0. In the terminal, type sudo nix-env -i lazarus-gtk2 The installation was very fast. The screenshot below shows the final messages in the terminal. |
|
|
|
You have to reboot (or logoff/logon; at least I think) in order to make the Lazarus launcher appear together with the other applications. At the first launch, the Configure Lazarus IDE window pops up. In the case of NixOS 22.11, you'll see that the version, that has been installed, is Lazarus 2.2.2. You can see on the screenshot that all components have been found: no problems for the IDE, the compiler, the FPC sources, the make utility and the GNU debugger. However, a red exclamation mark for Fppkg and the message Error: there is a problem with the Fppkg configuration. | |
|
|
This is a rather common problem of Lazarus on Linux. Fortunately, it's very simple to resolve it: Just push the Restore Fppkg configuration button and on the next screen (screenshot below), push the Write new configuration files button. Concerning the prefix of the Free Pascal compiler installation, be sure to let the path displayed when opening the window. As all apps on NixOS, Free Pascal is installed in a subdirectory of /nix/store. | |
|
|
Now we can start the IDE. That works fine, as well as the windows rearrangement and resizing. Trying to build a GUI project (actually my "World clock" application), all works fine, too, as you can see on the screenshot. | |
|
|
However, when you run an application, you will get a bad surprise: Edit filed content (randomly?) "disappears". So, when filling in the configuration data of my "World clock", clicking in a field, that already contains data, makes this data "disappear". This also happens, when I click in one of the time fields of the running clock. Even more bizarre: In my "BlackJack2" application, the player names "disappear" when the program fills in other edit fields. That's definitively something that I've never seen before, neither with Lazarus, nor with another application. The "disappearance" of the edit field content does actually not mean that these fields are cleared. In fact, my "World clock" configuration data is saved, even if some fields, after having been filled in, don't show any field content anymore. It seems as if the field content would become invisible depending on the fill-in of other fields or mouse-clicks in the field, what is impossible, I guess. I've posted the issue in NixOS discourse and I will update this document as soon as I get a solution, how to fix the issue... |
If you find this text helpful, please, support me and this website by signing my guestbook.