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:
- A system running NixOS Latest
- Administrative privileges
- Access to a terminal
Steps to Install Lmod on NixOS Latest
- 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
- Install Lmod
Use the following command to install Lmod:
sudo nix-env -iA nixpkgs.environment-modules
- 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.
- 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.