@@ -337,6 +337,86 @@ or all together with :subcmd:`stashclear`.
337337 :ps: `$ ` module stashlist
338338 No stash collection.
339339
340+ Siteconfig hook variables
341+ -------------------------
342+
343+ Several Tcl variables are introduced for :ref: `Site-specific configuration `
344+ script to define specific commands and variables in the evaluation context of
345+ modulefiles and modulercs. These commands and variables setup in
346+ :file: `siteconfig.tcl ` can be used in modulefile or modulerc. Sites can easily
347+ extend modulefile and modulerc syntax with specific elements.
348+
349+ :sitevar: `modulefile_extra_cmds ` variable defines a list of commands to expose
350+ in the modulefile evaluation context and the associated procedure to run when
351+ this command is called. This variable has to be defined in
352+ :file: `siteconfig.tcl ` located for instance at |file etcdir_siteconfig |.
353+
354+ In the following example :sitevar: `modulefile_extra_cmds ` is used to define
355+ the ``sys `` command and bound it to the ``sys `` procedure that is also defined
356+ in :file: `siteconfig.tcl `.
357+
358+ .. code-block :: tcl
359+
360+ proc sys {mode} {
361+ switch -- $mode {
362+ name { return myhost-$::tcl_platform(machine) }
363+ default { error "Unknown mode '$mode'" }
364+ }
365+ }
366+ set modulefile_extra_cmds {sys sys}
367+
368+ Once :file: `siteconfig.tcl ` is setup, the ``sys `` command can be called by
369+ modulefiles. In the following example it is used to determine the application
370+ path.
371+
372+ .. parsed-literal ::
373+
374+ :ps: `$ ` cat /path/to/modulefiles/foo/1.2
375+ #%Module
376+ append-path PATH /path/to/apps/foo-1.2/[sys name]/bin
377+
378+ :ps: `$ ` module show foo/1.2
379+ -------------------------------------------------------------------
380+ :sgrhi: `/path/to/modulefiles/foo/1.2 `:
381+
382+ :sgrcm: `append-path ` PATH /path/to/apps/foo-1.2/myhost-x86_64/bin
383+ -------------------------------------------------------------------
384+
385+ :sitevar: `modulerc_extra_cmds ` follows the same approach than
386+ :sitevar: `modulefile_extra_cmds ` and makes specific commands available during
387+ modulerc evaluation.
388+
389+ :sitevar: `modulefile_extra_vars ` variable defines a list of variables to
390+ expose in the modulefile evaluation context and their associated value. This
391+ variable has to be defined in :file: `siteconfig.tcl `.
392+
393+ In the following example :sitevar: `modulefile_extra_vars ` is used to define
394+ the ``APP_ROOT `` variable with ``/path/to/apps `` as value.
395+
396+ .. code-block :: tcl
397+
398+ set modulefile_extra_vars {APP_ROOT /path/to/apps}
399+
400+ Once :file: `siteconfig.tcl ` is setup, the ``APP_ROOT `` variable can be used in
401+ modulefiles.
402+
403+ .. parsed-literal ::
404+
405+ :ps: `$ ` cat /path/to/modulefiles/bar/2.1
406+ #%Module
407+ append-path PATH $APP_ROOT/bar-2.1/[sys name]/bin
408+
409+ :ps: `$ ` module show bar/2.1
410+ -------------------------------------------------------------------
411+ :sgrhi: `/path/to/modulefiles/bar/2.1 `:
412+
413+ :sgrcm: `append-path ` PATH /path/to/apps/bar-2.1/myhost-x86_64/bin
414+ -------------------------------------------------------------------
415+
416+ :sitevar: `modulerc_extra_vars ` follows the same approach than
417+ :sitevar: `modulefile_extra_vars ` and makes specific variables available during
418+ modulerc evaluation.
419+
340420
341421v5.1
342422====
0 commit comments