-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
178 lines (174 loc) · 6.71 KB
/
flake.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
{
description = "Environment for running ARTIQ master in lab one/HOA2";
inputs = {
artiq.url = "git+ssh://[email protected]/ion-trap/artiq.git";
# Oxford-flavoured ARTIQ packages. We pull them in as flake inputs so we can
# conveniently update them using `nix lock`, etc., rather than manually having to
# track hashes.
src-andorEmccd = {
url = "github:dnadlinger/andorEmccd";
flake = false;
};
src-llama = {
url = "git+ssh://[email protected]/ion-trap/llama.git";
flake = false;
};
src-ndscan = {
url = "github:OxfordIonTrapGroup/ndscan";
flake = false;
};
src-oitg = {
url = "github:OxfordIonTrapGroup/oitg";
flake = false;
};
src-oxart = {
url = "git+ssh://[email protected]/ion-trap/oxart.git";
flake = false;
};
src-oxart-devices = {
url = "github:OxfordIonTrapGroup/oxart-devices";
flake = false;
};
};
outputs = { self, artiq, src-andorEmccd, src-llama, src-ndscan, src-oitg
, src-oxart, src-oxart-devices }:
let
nixpkgs = artiq.nixpkgs;
sipyco = artiq.inputs.sipyco;
andorEmccd = nixpkgs.python3Packages.buildPythonPackage {
name = "andorEmccd";
src = src-andorEmccd;
propagatedBuildInputs = [ nixpkgs.python3Packages.numpy ];
};
llama = nixpkgs.python3Packages.buildPythonPackage {
name = "llama";
src = src-llama;
propagatedBuildInputs = [
nixpkgs.python3Packages.aiohttp
sipyco.packages.x86_64-linux.sipyco
];
};
oitg = nixpkgs.python3Packages.buildPythonPackage {
name = "oitg";
src = src-oitg;
format = "pyproject";
propagatedBuildInputs = with nixpkgs.python3Packages; [
h5py
scipy
statsmodels
nixpkgs.python3Packages.poetry-core
nixpkgs.python3Packages.poetry-dynamic-versioning
];
# Whatever magic `setup.py test` does by default fails for oitg.
installCheckPhase = ''
${nixpkgs.python3.interpreter} -m unittest discover test
'';
};
ndscan = nixpkgs.python3Packages.buildPythonPackage {
name = "ndscan";
src = src-ndscan;
format = "pyproject";
propagatedBuildInputs = [
artiq.packages.x86_64-linux.artiq
oitg
nixpkgs.python3Packages.poetry-core
nixpkgs.python3Packages.pyqt6
];
# ndscan depends on pyqtgraph>=0.12.4 to display 2d plot colorbars, but this
# is not yet in nixpkgs 23.05. Since this flake will mostly be used for
# server-(master-)side installations, just patch it out for now. In theory,
# pythonRelaxDepsHook should do this more elegantly, but it does not seem to
# be run before pipInstallPhase.
# FIXME: qasync/sipyco/oitg dependencies which explicitly specify a Git source
# repo do not seem to be matched by the packages pulled in via Nix; what is the
# correct approach here?
postPatch = ''
sed -i -e "s/^pyqtgraph = .*//" pyproject.toml
sed -i -e "s/^qasync = .*//" pyproject.toml
sed -i -e "s/^sipyco = .*//" pyproject.toml
sed -i -e "s/^oitg = .*//" pyproject.toml
'';
dontWrapQtApps = true; # Pulled in via the artiq package; we don't care.
};
oxart = nixpkgs.python3Packages.buildPythonPackage {
name = "oxart";
src = src-oxart;
propagatedBuildInputs = [ artiq.packages.x86_64-linux.artiq oitg ];
installCheckPhase = ''
${nixpkgs.python3.interpreter} -m unittest discover test
'';
dontWrapQtApps = true; # Pulled in via the artiq package; we don't care.
};
oxart-devices = nixpkgs.python3Packages.buildPythonPackage {
name = "oxart-devices";
src = src-oxart-devices;
format = "pyproject";
propagatedBuildInputs = [
nixpkgs.python3Packages.appdirs
nixpkgs.python3Packages.influxdb
nixpkgs.python3Packages.pyserial
nixpkgs.python3Packages.pyzmq
oitg
sipyco.packages.x86_64-linux.sipyco
];
# Need to manually remove .pyc files conflicting with oxart (both share the
# oxart.* namespace).
postFixup = ''
rm -r $out/${nixpkgs.python3.sitePackages}/oxart/__pycache__
'';
# Auto-discovery pulls in some ``test`` modules for manual interactive testing
# (that also require Windows and/or hardware).
doCheck = false;
};
python-env = (nixpkgs.python3.withPackages (ps:
(with ps; [ aiohttp h5py influxdb llvmlite numba pyzmq ]) ++ [
# ARTIQ will pull in a large number of transitive dependencies, most of which
# we also rely on. Currently, it is a bit overly generous, though, in that it
# pulls in all the requirements for a full GUI and firmware development
# install (Qt, Rust, etc.). Could slim down if disk usage ever becomes an
# issue.
artiq.packages.x86_64-linux.artiq
artiq.packages.x86_64-linux.entangler
andorEmccd
llama
ndscan
oitg
oxart
oxart-devices
]));
artiq-master-dev = nixpkgs.mkShell {
name = "artiq-master-dev";
buildInputs = [
python-env
artiq.packages.x86_64-linux.openocd-bscanspi
nixpkgs.julia_19-bin
nixpkgs.lld_14
nixpkgs.llvm_14
nixpkgs.libusb-compat-0_1
];
shellHook = ''
if [ -z "$OITG_SCRATCH_DIR" ]; then
echo "OITG_SCRATCH_DIR environment variable not set, defaulting to ~/scratch."
export OITG_SCRATCH_DIR=$HOME/scratch
export QT_PLUGIN_PATH=${nixpkgs.qt5.qtbase}/${nixpkgs.qt5.qtbase.dev.qtPluginPrefix}
export QML2_IMPORT_PATH=${nixpkgs.qt5.qtbase}/${nixpkgs.qt5.qtbase.dev.qtQmlPrefix}
fi
${
./src/setup-artiq-master-dev.sh
} ${python-env} ${python-env.sitePackages} || exit 1
source $OITG_SCRATCH_DIR/nix-oitg-venvs/artiq-master-dev/bin/activate || exit 1
'';
};
in {
# Allow explicit use from outside the flake, in case we want to add other targets
# or build on this in the future.
inherit artiq-master-dev;
inherit andorEmccd llama oitg ndscan oxart oxart-devices;
defaultPackage.x86_64-linux = artiq-master-dev;
};
nixConfig = {
extra-trusted-public-keys =
"buildsvr-1:3EJ00F+rbqkxwDTforU07Jj1Rzq3B+uVWc70+8fXv/s= nixbld.m-labs.hk-1:5aSRVA5b320xbNvu30tqxVPXpld73bhtOeH6uAjRyHc=";
extra-substituters = "ssh://[email protected] https://nixbld.m-labs.hk";
};
}