How to install environment-modules Lmod on NixOS Latest

Overview

Lmod is a modern replacement for the Environment Modules package that was first developed at the Texas Advanced Computing Center (TACC). It is a tool that helps manage your Linux environment by streamlining the exporting of environment variables, switching between different versions of installed software, and organizing dependencies. In this tutorial, we will explain how to install Lmod on NixOS Latest.

Prerequisites

Before you begin this tutorial, you need to ensure that you have the following:

  1. A system running NixOS Latest
  2. Administrative privileges
  3. Access to a terminal

Steps to Install Lmod on NixOS Latest

  1. Update Your System

You should always update your system before installing anything; this ensures that you have the latest packages available.

Use the following command:

sudo nixos-rebuild switch --upgrade
  1. Install Lmod

Use the following command to install Lmod:

sudo nix-env -iA nixpkgs.environment-modules
  1. Configure Lmod

Create a directory for the Lmod configuration file:

sudo mkdir -p /etc/lmod.d

Create an Lmod configuration file:

sudo touch /etc/lmod.d/lmod.conf

Open the file in your text editor and add the following lines:

### /etc/lmod.d/lmod.conf
module_style lmod
prepend_path("MODULEPATH", "/usr/share/Modules/modulefiles")

Save and close the file.

  1. Use Lmod

Use the module command to load and unload modules. For example,

module load python

will load Python along with any dependencies it requires.

module unload python

will unload Python and its dependencies.

Conclusion

Lmod is a valuable tool for environment management, providing streamlined methods for managing dependencies and software versioning. By following this tutorial, you have successfully installed and configured Lmod on NixOS Latest.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!