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.1.tar.gz" sha256 "3e92e7d96ce333fab646bd8d571031310c1fb69f0637ba0dd406e5134705f315" license "MIT" bottle do sha256 cellar: :any, arm64_tahoe: "b5c91c9013838c2c3b332f386c020da86f5dd869c21a3a4aa68b79d99da227f2" sha256 cellar: :any, arm64_sequoia: "f3bde66f62e40a1857cb03eb710810d287154c7bd33a5c783a6d11e4a0417e5c" sha256 cellar: :any, arm64_sonoma: "71ed09c6bc9aa76c23b488dfe930497afe1f8513b1dfd76fed789c0f8f20f6fd" sha256 cellar: :any, sonoma: "b7755c5c46e4e6a7ffd944daf171ce89590247050fd184915e1e6cd3e2649478" sha256 cellar: :any_skip_relocation, arm64_linux: "4878c94ec91bd57fd9f5c0a690cd66f59a8f3e5ba446287ae0b3399b36c28f25" sha256 cellar: :any_skip_relocation, x86_64_linux: "d644c4ad21eb0b3263084f45aa005ca93266c832114b9f7f759a8e832b4819af" 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