Skip to content

Instantly share code, notes, and snippets.

@hartzell
Last active July 6, 2018 21:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hartzell/d7d067e59695575c47e1c86b898b37fc to your computer and use it in GitHub Desktop.
Save hartzell/d7d067e59695575c47e1c86b898b37fc to your computer and use it in GitHub Desktop.
A script to configure a spack tree and build some things.
#!/bin/sh
set -e
# ask the spack executable the location of root of its tree
export SPACK_ROOT=$(spack location -r)
# having an app tree set up messes up the build. Clear the field.
if [[ $(type -t module) == "function" ]]; then
module purge
fi
cat << "EOYAML" > ${SPACK_ROOT}/etc/spack/config.yaml
# -------------------------------------------------------------------------
# This is the project specific spack configuration file.
# -------------------------------------------------------------------------
config:
# Temporary locations Spack can try to use for builds.
#
# A value of $spack/var/spack/stage indicates that Spack should run
# builds directly inside its install directory without staging them in
# temporary space.
#
# The build stage can be purged with `spack purge --stage`.
build_stage:
- $spack/var/spack/stage
EOYAML
cat << "EOYAML" > ${SPACK_ROOT}/etc/spack/packages.yaml
packages:
all:
compiler: [gcc@5.5.0, gcc@4.8.5, gcc@4.8.3]
emacs:
variants: +tls
EOYAML
cat << "EOYAML" > ${SPACK_ROOT}/etc/spack/modules.yaml
modules:
enable::
- lmod
- tcl
tcl:
# hash_length: 0
blacklist:
- '%gcc@4.8.2'
- '%gcc@4.8.5'
- '%gcc@4.8'
all:
suffixes:
'+jit': jit
'^python@2.7': 'py2.7'
'^python@3.6': 'py3.6'
naming_scheme: '${PACKAGE}/${VERSION}'
^python:
autoload: 'direct'
lmod:
core_compilers:
- 'gcc@4.8.5'
- 'gcc@4.8.2'
- 'gcc@4.8'
# hash_length: 0
whitelist:
- gcc
blacklist:
- '%gcc@4.8.2'
- '%gcc@4.8.5'
- '%gcc@4.8'
verbose_autoload: false
all:
template: 'modules/my-modulefile.lua'
autoload: 'direct'
suffixes:
'+jit': jit
'^python@2.7': 'py2.7'
'^python@3.6': 'py3.6'
filter:
environment_blacklist: ['CPATH', 'LIBRARY_PATH', 'LD_LIBRARY_PATH']
# WE DO NOT SET PACKAGE ROOT, it upsets GCC
^python:
filter:
environment_whitelist: ['LD_LIBRARY_PATH']
EOYAML
cat << "EOLUA" > ${SPACK_ROOT}/share/spack/templates/modules/my-modulefile.lua
{% extends "modules/modulefile.lua" %}
{% block autoloads %}
{% for module in autoload %}
-- depends_on() supports automagically unloading dependencies
depends_on("{{ module }}")
{% endfor %}
{% endblock %}
EOLUA
my_compiler=gcc@5.5.0
if ! spack location -i ${my_compiler} > /dev/null 2>&1; then
# Compiler
## HEADS UP: This is a bit fragile. Make sure that you don't have
## a ~/.spack/.../compilers.yaml file that defines a 5.4.0,
## otherwise you're likely to build "my_compiler" with that one
## and lmod won't generate a set of Core modules. Alt, we could
## grab the version from the system compiler and specify it here
## explicitly. More work than it's worth for now.
spack install ${my_compiler}
# This might not do what you want if there's already
# a 5.4.0 on the system....
# Now all of the things will be built with %gcc@5.4.0
spack compiler add --scope site $(spack location -i ${my_compiler})
fi
spack install aspell6-en; spack activate aspell6-en
spack install direnv
spack install emacs
spack install git
spack install htop
spack install httpie
spack install jq
spack install lmod
spack install perl
spack install the-silver-searcher
spack install tree
spack install tmux
spack install vim
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment