-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathcfg.nix
67 lines (54 loc) · 1.62 KB
/
cfg.nix
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
{
# allow configuration via environment
allowEnv ? false
, srcurl ? null
, optpath ? null
, licMolpro ? null
, prefix ? null
, optAVX ? null
, optArch ? null
, useCuda ? null
, licQChem ? null
} :
let
# getEnv that returns null if var is not set
getEnv = x:
let
envVar = builtins.getEnv x;
in
if (builtins.stringLength envVar) > 0 then envVar
else null;
getValue = x: default: envVar:
if x != null then x
else if allowEnv then
if (getEnv envVar) != null then getEnv envVar else default else default;
getBoolValue = x: default: envVar:
if x != null then x
else if allowEnv then
if (getEnv envVar) != null then
(if (getEnv envVar) == "1" then true else false)
else default
else default;
AVX = getBoolValue optAVX true "NIXQC_AVX";
in {
# Put the package set under prefix
prefix = getValue prefix "qchem" "NIXQC_PREFIX";
# base url for non-free packages
srcurl = getValue srcurl null "NIXQC_SRCURL";
# path to packages that reside outside the nix store
optpath = getValue optpath null "NIXQC_OPTPATH";
# string containing a valid MOLPRO license token
licMolpro = getValue licMolpro null "NIXQC_LICMOLPRO";
# turn on AVX optimizations
optAVX = AVX;
# Optimize for a specific gcc Arch
# corresponds to skylake when AVX is requested
optArch = let
arch = getValue optArch null "NIXQC_OPTARCH";
in if arch != null then arch
else if AVX then "haswell" else null;
# Enable CUDA on selected packages
useCuda = getBoolValue useCuda false "NIXQC_CUDA";
# QChem license information
licQChem = getValue licQChem null "NIXQC_LICQCHEM";
}