-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathrun
executable file
·151 lines (143 loc) · 3.57 KB
/
run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/bin/sh -e
shopt -s nullglob
fi=`dirname $0`
. $fi/env
gitrev=$(git describe --always)
os=$( . /etc/os-release ; echo $ID${VERSION_ID%.[0-9]*} )
arch=$(uname -m)
nixargs="$fi --argstr gitrev ${gitrev:-unknown} --argstr os $os"
site=fi
lmodbase=/mnt/sw/lmod/$arch/$os
if [[ `hostname -s` = pcn* ]] ; then
# popeye
site=popeye
nixargs="$nixargs --argstr target skylake-avx512 --argstr cudaarch 70,80"
fi
traceSpecs() {
nix-instantiate --eval -A "$1" $nixargs |& sed 's/^trace: //'
}
if [[ $# -eq 0 ]] ; then
cmd=help
else
cmd="$1"
shift
fi
case "$cmd" in
(build)
if [[ "$*" != *" -A "* ]] ; then
set -- "$@" -A mods
fi
exec nix-build --show-trace "$@" $nixargs
;;
(spec)
if [[ $# -eq 0 ]] ; then
traceSpecs traceModSpecs
else
for p in "$@" ; do
traceSpecs "traceSpecs.$p"
done
fi
;;
(gc)
exec nix-store --gc
;;
(profile)
if [[ $# -eq 0 ]] ; then
echo "Nothing to do"
elif [[ $* == all ]] ; then
set -- nix lmod jupyter shell
fi
for prof in "$@" ; do
prefix=
case "$prof" in
(nix)
attrs="nixpkgs.nix nixpkgs.git"
prefix=$arch/
;;
(lmod)
attrs="pkgs.lmod"
;;
(jupyter*)
attrs="jupyter"
;;
(shell)
attrs="pkgs.zsh pkgs.tmux pkgs.git"
;;
(viswall)
attrs="nixpkgs.xscreensaver nixpkgs.mpv"
;;
(*)
echo "Unknown profile"
exit 1
;;
esac
profile=$NIX_STATE_DIR/profiles/${prefix:=$arch/$os/}$prof
nix-env -p $profile -i -r -f $nixargs -A $attrs
l=$(readlink $profile)
git tag $site/$prefix${l%-link} HEAD || true
done
;;
(modules)
if [[ $1 == -f ]] ; then
shift
elif ! git diff-index --quiet HEAD -- ; then
echo "Local modifications: refusing to relase (without -f)"
exit 1
fi
if [[ $# -ne 1 ]] ; then
echo "Usage: modules NAME"
exit 1
fi
path=$1
if [[ $path != */* ]] ; then
tag=$path
path=$lmodbase/modules/modules/$path
fi
if [[ $path != *.lua ]] ; then
path=$path.lua
fi
# fixups
nix-build -o apptainer -A pkgs.apptainer $nixargs
for fix in apptainer/bin/spack_perms_fix.sh ; do
sudo $fix || echo "YOU MUST RUN: sudo `realpath $fix`"
done
# release
nix-build -o $path -A modsMod $nixargs
if [[ -n $tag ]] ; then
git tag $site/$arch/$os/$tag HEAD
fi
;& # fall-thru
(cache)
rm -f $lmodbase/cacheDir/spiderT.old.lua*
$lmodbase/lmod/lmod/libexec/update_lmod_system_cache_files -d $lmodbase/cacheDir -t $lmodbase/cacheTS.txt $lmodbase/modules:$(realpath $lmodbase/lmod/lmod/modulefiles/Core)
;;
(spack)
nix-build -o spackBin -A spackBin $nixargs
exec ./spackBin "$@"
;;
(*)
if [[ $cmd != help ]] ; then
echo "Unknown command"
fi
cat <<EOF
Usage: $0 COMMAND
Commands:
build Build modules into result. Takes the same arguments as
nix-build (-jN, --cores M, -K, ...).
spec [PKG] Print the spec tree for a specific package or all modules,
along with the total number of unique packages.
gc Cleanup any unreferenced nix stores (nix-store --gc).
profile Update a nix profile for...
jupyter jupyterhub server environment
nix nix build environment
lmod lua modules environment
shell zsh and other shell tools
viswall viswall movie display environment
all all of the above
modules nixpack lmod modules (for testing only)
modules NAME release nixpack lmod modules to modules/NAME
cache Update lmod cache files
spack ... Run a spack command in the nixpack environment (things like list
and info work, but those managing packages will not)
EOF
esac