-
Notifications
You must be signed in to change notification settings - Fork 17
/
release.nix
179 lines (151 loc) · 5.44 KB
/
release.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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
{
# nixpkgs sources
nixpkgs ? { outPath = <nixpkgs>; shortRev = "0000000"; }
# Override config from ENV
, config ? {}
# allowUnfree for nixpkgs
, allowUnfree ? true
# Additional overlays to apply (applied before and after the main Overlay)
, preOverlays ? []
, postOverlays ? []
# Revision for Hydra
, NixOS-QChem ? { shortRev = "0000000"; }
# build more variants
, buildVariants ? false
# Build with pinned nixpkgs
, pin ? true
} :
let
cfg = (import ./cfg.nix) config;
nixpkgs-final = if pin then
import ./nixpkgs-pin.nix (import nixpkgs {})
else import nixpkgs;
# use unmodified lib
inherit (nixpkgs-final {}) lib;
# Customized package set
pkgs = config: overlay: let
pkgSet = nixpkgs-final {
overlays = [ overlay ] ++ preOverlays ++ [
(import ./overlay.nix)
] ++ postOverlays;
config = {
inherit allowUnfree;
qchem-config = cfg;
inHydra = true;
# Provide a handler to sort out unfree Packages
# This creates a hard fail, which we can test with tryEval v.drvPath
handleEvalIssue = reason: message:
if reason == "unfree" then false
else throw message;
checkMetaRecursively = false;
checkMeta = true;
cudaSupport = cfg.useCuda or false;
};
};
isBroken = pkg:
if (pkg ? meta && pkg.meta ? broken) then pkg.meta.broken
else false;
# Do not build a package on Hydra if meta.hydraPlatforms is empty
# and allowUnfree is disabled.
isUndistributable = pkg:
if (pkg ? meta && pkg.meta ? hydraPlatforms ) then
((lib.length pkg.meta.hydraPlatforms) == 0 && !allowUnfree)
else false;
makeForPython = plist:
pkgSet.lib.foldr (a: b: a // b) {}
(map (x: { "${x}" = hydraJobs pkgSet."${cfg.prefix}"."${x}".pkgs."${cfg.prefix}"; }) plist);
# Filter out valid derivations
# Remove broken and unfree if not permitted
hydraJobs = with lib; filterAttrs (n: v:
(builtins.tryEval (isDerivation v)).value
&& (if allowUnfree then true else (builtins.tryEval v.drvPath).success)
&& (if isBroken v then (builtins.trace "Warning: ${n} is marked broken." false) else true)
&& (if isUndistributable v then (builtins.trace "Warning: ${n} is marked undistributable." false) else true)
);
# Filter Attributes from set by name and put them in a list
selectList = attributes: pkgs: with lib; mapAttrsToList (n: v: v)
(filterAttrs (attr: val: (foldr (a: b: a == attr || b) false attributes)) pkgs);
# Make sure we only build the overlay's content
pkgsClean = hydraJobs pkgSet."${cfg.prefix}"
# Pick the test set
// { tests = hydraJobs pkgSet."${cfg.prefix}".tests; }
# release set for python packages
// makeForPython [ "python2" "python3" "python311" ]
# Have a manadatory test set and a channel
// rec {
tested = pkgSet.releaseTools.aggregate {
name = "tested-programs";
constituents = selectList [
"molden"
"sharc"
"psi4"
"octave"
"gromacsMpi"
] ( hydraJobs pkgSet."${cfg.prefix}" )
++
selectList [
"cp2k"
"nwchem"
"molcas"
"molpro"
"qdng"
"gaussview"
"orca"
] ( hydraJobs pkgSet."${cfg.prefix}".tests );
};
nixexprs = pkgSet.runCommand "nixexprs" {}
''
mkdir -p $out/NixOS-QChem
cp -r ${./.}/* $out/NixOS-QChem
cp ${./channel.nix} $out/default.nix
cat <<EOF > $out/.qchem-revision
NixOS-QChem ${NixOS-QChem.shortRev}
EOF
'';
channel = pkgSet.releaseTools.channel {
name = "NixOS-QChem-channel";
src = nixexprs;
constituents = [ tested ];
};
};
in pkgsClean;
# Aggregate all packages job
# Use as all-green-criteria
# Note that the aggregate contains the derivations!
allJobs = prefix: jobs: let
aggrJob = (nixpkgs-final {}).releaseTools.aggregate {
name = "all-packages";
constituents = with lib;
let
a2l = mapAttrsToList (_: path: if (lib.isAttrs path && !isDerivation path) then a2l path else path);
pnames =
mapAttrsRecursiveCond
(as: !(as ? "type" && as.type == "derivation"))
(path: v: v)
jobs
;
in a2l pnames;
};
in {
"${prefix}" = jobs // { release-barrier = aggrJob; };
};
in
(allJobs cfg.prefix (pkgs config (self: super: {})))
# Variant builds
// (if buildVariants then
(allJobs "${cfg.prefix}-mpich" (pkgs config (self: super: { mpi = super.mpich; }))) //
(allJobs "${cfg.prefix}-mvapich" (pkgs config (self: super: { mpi = super.mvapich; }))) //
(allJobs "${cfg.prefix}-mkl" (pkgs config (self: super: {
blas = super.blas.override { blasProvider = super.mkl; };
lapack = super.lapack.override { lapackProvider = super.mkl; };
}))) //
(allJobs "${cfg.prefix}-netlib" (pkgs config (self: super: {
blas = super.blas.override { blasProvider = super.lapack-reference; };
lapack = super.lapack.override { lapackProvider = super.lapack-reference; };
}))) //
(allJobs "${cfg.prefix}-amd" (pkgs config (self: super: {
blas = super.blas.override { blasProvider = super.amd-blis; };
fftw = self.qchem.amd-fftw;
scalapack = self.qchem.amd-scalapack;
})))
else {})