EESSI / compatibility-layer

Compatibility layer of the EESSI project
https://eessi.github.io/docs/compatibility_layer
GNU General Public License v2.0
11 stars 21 forks source link

Add `direnv` to compat layer #159

Closed ocaisa closed 1 year ago

ocaisa commented 1 year ago

direnv is a somewhat interesting for us to couple with (I think), it would allow to define/maintain your module environment (indeed your full build environment) in your code base in an arch independent way. That's pretty interesting for a developer who might need people to build their own version of a code (for example, if they need to compile in their own plugins). In fact we basically create the template for the .env file already within EasyBuild in the reprod directory.

ocaisa commented 1 year ago

The nice thing about this would be that if EESSI is available and direnv is enabled, you could git clone a project and immediately build it for your system without having to worry about any dependencies or configuration. It's not only good for people who need to compile projects but also within CI (which would help to enforce maintenance of the .env file).

ocaisa commented 1 year ago

An example of what this looks like (without any configuration settings):

[ocaisa@gpunode1 direnv_temp]$ cat .envrc 
module purge
unset MODULEPATH
export EESSI_SOFTWARE_SUBDIR_OVERRIDE=x86_64/generic
source /cvmfs/pilot.eessi-hpc.org/versions/2021.12/init/bash
module load GCC/10.3.0

[ocaisa@gpunode1 direnv_temp]$ cd ..
direnv: unloading

[ocaisa@gpunode1 ~]$ cd direnv_temp/
direnv: loading ~/direnv_temp/.envrc
Found EESSI pilot repo @ /cvmfs/pilot.eessi-hpc.org/versions/2021.12!
Using x86_64/generic as software subdirectory.
Using /cvmfs/pilot.eessi-hpc.org/versions/2021.12/software/linux/x86_64/generic/modules/all as the directory to be added to MODULEPATH.
Found Lmod configuration file at /cvmfs/pilot.eessi-hpc.org/versions/2021.12/software/linux/x86_64/generic/.lmod/lmodrc.lua
Initializing Lmod...
Prepending /cvmfs/pilot.eessi-hpc.org/versions/2021.12/software/linux/x86_64/generic/modules/all to $MODULEPATH...
Environment set up to use EESSI pilot software stack, have fun!
direnv: export +EESSI_SOFTWARE_SUBDIR_OVERRIDE ~CMAKE_LIBRARY_PATH ~CMAKE_PREFIX_PATH ~EBDEVELGCC ~EBDEVELGCCCORE ~EBROOTGCC ~EBROOTGCCCORE ~EESSI_MODULEPATH ~EESSI_SOFTWARE_PATH ~EESSI_SOFTWARE_SUBDIR ~LMOD_RC ~MANPATH ~MODULEPATH ~PATH ~XDG_DATA_DIRS ~_LMFILES_ ~_ModuleTable001_ ~_ModuleTable002_ ~_ModuleTable003_ ~__LMOD_REF_COUNT_CMAKE_LIBRARY_PATH ~__LMOD_REF_COUNT_CMAKE_PREFIX_PATH ~__LMOD_REF_COUNT_MANPATH ~__LMOD_REF_COUNT_MODULEPATH ~__LMOD_REF_COUNT_PATH ~__LMOD_REF_COUNT_XDG_DATA_DIRS ~__LMOD_REF_COUNT__LMFILES_

[ocaisa@gpunode1 direnv_temp]$
bedroge commented 1 year ago

There's an ebuild for direnv at https://gpo.zugaina.org/Overlays/go-overlay/dev-util/direnv, we could try it out.

bedroge commented 1 year ago

I've successfully installed direnv in a test Prefix installation. It does require Go, but as far as I can see only for the build, so we could safely uninstall Go afterwards. I'll make the required PRs so that we can include it in our compat layer.

bedroge commented 1 year ago

PR for the ebuild: https://github.com/EESSI/gentoo-overlay/pull/88

bedroge commented 1 year ago

This has been added to the set file of the next pilot (https://github.com/EESSI/gentoo-overlay/pull/88). Functionality for removing Go will be added in #163.