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.1.0.tar.gz" sha256 "197ab8be3d82698d11b43d954eab467d9baa40de619a38d2bf82cc288097e422" license "MIT" bottle do sha256 cellar: :any, arm64_tahoe: "8b6ac4ff4276cef094697b25728aaad4a289798e5b4abe473b7fabd3fb725c8c" sha256 cellar: :any, arm64_sequoia: "8741875ccf1bf0923f24cf32abf3b709c640c545d84ce38ce080725a0aea7b4a" sha256 cellar: :any, arm64_sonoma: "3eeff66d409ad2d72176140d517a1a7a62f4e04a4dc06492585f1dd7c6cf9270" sha256 cellar: :any, sonoma: "4be9d44b4a74be6aefa63d91a0e703ee3f60448e5c478c7ad052f2ca0d92abbd" sha256 cellar: :any_skip_relocation, arm64_linux: "568721eaec14d494809af239a0afd298d8241300b03daa60cc6b4b7e876e550c" sha256 cellar: :any_skip_relocation, x86_64_linux: "e02fa303d544370e19e4d802afb8a4143bec092905998b78ea2ec42c8e0ca789" 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