class Lmod < Formula desc "Lua-based environment modules system to modify PATH variable" homepage "https://lmod.readthedocs.io" url "https://github.com/TACC/Lmod/archive/refs/tags/9.0.6.tar.gz" sha256 "370c154ef22d5fec5dd567ed26478aaf6ff55323b09a9d96826e12ca570e777e" license "MIT" bottle do sha256 cellar: :any, arm64_tahoe: "61e5a984cf9f6c502ebea120cd5f191448270ad339e481473048873c38cf46d3" sha256 cellar: :any, arm64_sequoia: "6214fd884d64438ece3f047d646166f39e73505a3d1f82487b72bac86b463f78" sha256 cellar: :any, arm64_sonoma: "7e628ca56296dc7a1237f813c294f329980f39aed568fdf44fc0a6f221992c00" sha256 cellar: :any, sonoma: "63d513cb90b1b9e4956e4d68e284a2f8a55df8fb37e72e814e47ae0638ecfe3c" sha256 cellar: :any_skip_relocation, arm64_linux: "de647cf52bb825b797d3713e9e4077c721a788735bc6b4a42a3b099189383bd0" sha256 cellar: :any_skip_relocation, x86_64_linux: "c2b5ae6edeef717703eff2e3b6b1a698b57a96626c565163bde8381cca1cd2ea" end depends_on "luarocks" => :build depends_on "pkgconf" => :build depends_on "lua" depends_on "tcl-tk" uses_from_macos "bc-gh" => :build uses_from_macos "libxcrypt" on_macos do depends_on "gnu-sed" => :build end resource "lua-term" do url "https://github.com/hoelzro/lua-term/archive/refs/tags/0.8.tar.gz" sha256 "0cb270be22dfc262beec2f4ffc66b878ccaf236f537d693fa36c8f578fc51aa6" end resource "luafilesystem" do url "https://github.com/lunarmodules/luafilesystem/archive/refs/tags/v1_9_0.tar.gz" sha256 "1142c1876e999b3e28d1c236bf21ffd9b023018e336ac25120fb5373aade1450" end resource "luaposix" do url "https://github.com/luaposix/luaposix/archive/refs/tags/v36.3.tar.gz" sha256 "82cd9a96c41a4a3205c050206f0564ff4456f773a8f9ffc9235ff8f1907ca5e6" end def install luaversion = Formula["lua"].version.major_minor luapath = libexec/"vendor" ENV["LUA_PATH"] = "?.lua;" \ "#{luapath}/share/lua/#{luaversion}/?.lua;" \ "#{luapath}/share/lua/#{luaversion}/?/init.lua;;" ENV["LUA_CPATH"] = "#{luapath}/lib/lua/#{luaversion}/?.so;;" resources.each do |r| r.stage do system "luarocks", "make", "--tree=#{luapath}" end end # configure overrides PKG_CONFIG_PATH with TCL_PKG_CONFIG_DIR value ENV["TCL_PKG_CONFIG_DIR"] = ENV["PKG_CONFIG_PATH"] system "./configure", "--with-siteControlPrefix=yes", "--prefix=#{prefix}" ENV.deparallelize # Work around "install: mkdir .../share/man: File exists" system "make", "install" # Remove man page which conflicts with `modules` formula rm man1/"module.1" end def caveats <<~EOS To use Lmod, you should add the init script to the shell you are using. For example, the bash setup script is here: #{opt_prefix}/init/profile and you can source it in your bash setup or link to it. If you use fish, use #{opt_prefix}/init/fish, such as: ln -s #{opt_prefix}/init/fish ~/.config/fish/conf.d/00_lmod.fish EOS end test do sh_init = "#{prefix}/init/sh" (testpath/"lmodtest.sh").write <<~SHELL #!/bin/sh . #{sh_init} module list SHELL assert_match "No modules loaded", shell_output("sh #{testpath}/lmodtest.sh 2>&1") system sh_init output = shell_output("#{prefix}/libexec/spider #{prefix}/modulefiles/Core/") assert_match "lmod", output assert_match "settarg", output end end