From 24cbe4db116b8da1ce229c71f11fbbf5a95c8a9c Mon Sep 17 00:00:00 2001 From: "svcusr-spack (Resp. Germann Elsa Sylvia)" Date: Thu, 20 Mar 2025 15:43:30 +0100 Subject: [PATCH] ADD: templating to fix hierarchical module for users --- templates/user_hierachical_paths.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 templates/user_hierachical_paths.lua diff --git a/templates/user_hierachical_paths.lua b/templates/user_hierachical_paths.lua new file mode 100644 index 0000000..3ef973c --- /dev/null +++ b/templates/user_hierachical_paths.lua @@ -0,0 +1,20 @@ +{% extends "modules/modulefile.lua" %} +{% block footer %} + +local user_module_root= pathJoin(os.getenv("SPACK_ROOT"), "../user", os.getenv("USER"), "spack-install/modulefiles") + +{% if 'mpi' in provides %} +local user_projection= "{{ spec.architecture }}/{{ spec.name }}/{{ version_part }}/{{ spec.compiler.name }}/{{ spec.compiler.version }}" +{% elif 'compiler' in provides %} +local user_projection= "{{ spec.architecture }}/{{ spec.name }}/{{ spec.version }}" +{% endif %} + + +if user_projection then +local user_path= pathJoin(user_module_root, user_projection) + if isDir(user_path) then +prepend_path("MODULEPATH", user_path, ":") + end +end + +{% endblock %}