-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
163 lines (152 loc) · 5.7 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
{
description = "DeltaQ for Jupyter and Docker";
nixConfig.extra-substituters = [
"https://tweag-jupyter.cachix.org"
];
nixConfig.extra-trusted-public-keys = [
"tweag-jupyter.cachix.org-1:UtNH4Zs6hVUFpFBTLaA4ejYavPo5EFFqgd7G7FxGW9g="
];
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
flake-utils.url = "github:numtide/flake-utils";
flake-compat.url = "github:edolstra/flake-compat";
flake-compat.flake = false;
jupyenv.url = "github:tweag/jupyenv?ref=0c86802aaa3ffd3e48c6f0e7403031c9168a8be2";
deltaq.url = "github:DeltaQ-SD/deltaq";
deltaq.flake = false;
};
outputs = {
self,
flake-compat,
flake-utils,
nixpkgs,
jupyenv,
deltaq,
...
} @ inputs:
flake-utils.lib.eachSystem (with flake-utils.lib.system; [ x86_64-linux ])
(
system: let
overlay = next: prev: {
haskell = prev.haskell // {
packageOverrides = hnext: hprev: {
# Include the DeltaQ packages.
deltaq = hprev.callCabal2nixWithOptions
"deltaq"
(deltaq.outPath + "/lib/deltaq")
"--no-check"
{};
probability-polynomial = hprev.callCabal2nixWithOptions
"probability-polynomial"
(deltaq.outPath + "/lib/probability-polynomial")
"--no-check"
{};
# Use a more recent version of `lattices` than is available in the curated Nix package set.
lattices = hprev.callPackage (
{ mkDerivation, base, containers, deepseq, hashable
, integer-logarithms, lib, QuickCheck, quickcheck-instances, tagged
, tasty, tasty-quickcheck, transformers, universe-base
, universe-reverse-instances, unordered-containers
}:
mkDerivation {
pname = "lattices";
version = "2.2.1";
sha256 = "27063f2343b1547033cd59f61b27f797041ed0c25c921f253ce82dc6fffa7666";
libraryHaskellDepends = [
base containers deepseq hashable integer-logarithms QuickCheck
tagged transformers universe-base universe-reverse-instances
unordered-containers
];
testHaskellDepends = [
base containers QuickCheck quickcheck-instances tasty
tasty-quickcheck transformers universe-base
universe-reverse-instances unordered-containers
];
homepage = "http://github.com/phadej/lattices/";
description = "Fine-grained library for constructing and manipulating lattices";
license = lib.licenses.bsd3;
}
) {};
# Sadly, we need to loosen the dependency constraint that `Chart-cairo` has on `time`.
Chart-cairo = hprev.callPackage (
{ mkDerivation, array, base, cairo, Chart, colour
, data-default-class, lens, lib, mtl, old-locale, operational, time
}:
mkDerivation {
pname = "Chart-cairo";
version = "1.9.4.1";
sha256 = "27cbc2f1237b739eb60c6c470a9324b7ab63974f33116411ea4c2f347ca22074";
prePatch = ''
sed -e '/, time/s/ >=.*$//' -i Chart-cairo.cabal
'';
libraryHaskellDepends = [
array base cairo Chart colour data-default-class lens mtl
old-locale operational time
];
homepage = "https://github.com/timbod7/haskell-chart/wiki";
description = "Cairo backend for Charts";
license = lib.licenses.bsd3;
}
) {};
};
};
};
pkgs = import nixpkgs { inherit system; overlays = [ overlay ]; };
inherit (jupyenv.lib.${system}) mkJupyterlabNew;
jupyterlab = mkJupyterlabNew ({...}: {
nixpkgs = nixpkgs;
imports = [(import ./kernels.nix {pkgs = pkgs;})];
});
docker = pkgs.dockerTools.buildImage {
name = "jupyter-deltaq";
copyToRoot = pkgs.buildEnv {
name = "image-root";
paths = [
pkgs.dockerTools.usrBinEnv
pkgs.dockerTools.binSh
pkgs.bash
pkgs.coreutils
pkgs.nodejs_18
jupyterlab
];
pathsToLink = [ "/bin" ];
};
runAsRoot = ''
#!${pkgs.runtimeShell}
${pkgs.dockerTools.shadowSetup}
groupadd -r deltaq
useradd -r -g deltaq deltaq
mkdir -p /home/deltaq/examples
chown -R deltaq:deltaq /home/deltaq
mkdir -p /usr/bin
ln -s /bin/env /usr/bin/env
'';
extraCommands = ''
#!${pkgs.runtimeShell}
chmod 0777 tmp
mkdir -p home/deltaq/examples
cp -r ${self}/examples home/deltaq/
'';
config = {
User = "deltaq";
WorkingDir = "/home/deltaq";
Cmd = [
"${jupyterlab}/bin/jupyter-lab"
"--no-browser"
"--ip=0.0.0.0"
"--port=8888"
"--NotebookApp.token=deltaq"
];
ExposedPorts = {
"8888" = {};
};
};
};
in rec {
packages = {inherit jupyterlab docker;};
packages.default = jupyterlab;
apps.default.program = "${jupyterlab}/bin/jupyter-lab";
apps.default.type = "app";
}
);
}