-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
107 lines (95 loc) · 2.98 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
{
description = "Sonar";
inputs.nixpkgs.url = "github:NixOS/Nixpkgs/nixos-unstable";
outputs = { self, nixpkgs }:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
in
{
packages.x86_64-linux = {
check-notebook = pkgs.writeScriptBin "check-notebook.py" ''
#!${pkgs.python3.interpreter}
import nbformat
from nbclient import NotebookClient
import sys
nb = nbformat.read(sys.argv[1], as_version=4)
client = NotebookClient(
nb,
timeout=600,
kernel_name='python3',
resources={'metadata': {'path': 'notebooks/'}},
skip_cells_with_tag="do_not_check"
)
client.execute()
'';
neo4j-python-driver = pkgs.python3Packages.buildPythonPackage rec {
pname = "neo4j-python-driver";
version = "4.3.3";
src = pkgs.fetchFromGitHub {
owner = "neo4j";
repo = pname;
rev = version;
sha256 = "sha256-h/3f4fv7fgO/auBD6R2zRcDZVgSm0mvDFxK9eNEmnIs=";
};
buildInputs = with pkgs.python3Packages; [ pytz pytest ];
doCheck = false;
};
};
checks.x86_64-linux = pkgs.lib.mapAttrs
(name: nbfile: pkgs.runCommand name
{
src = ./notebooks;
nativeBuildInputs = with pkgs.python3Packages; [
ipywidgets
autopep8
pandas
# nbdime
networkx
pyvis
python-louvain
pyyaml
matplotlib
self.packages.x86_64-linux.check-notebook
];
} ''
mkdir -p $out
cp -r $src notebooks
chmod u+rw -R notebooks
check-notebook.py "notebooks/${nbfile}"
'')
{
notebook1 = "Notebook 1 - Jupyter and Python.ipynb";
notebook2 = "Notebook 2 - Historical Network Analysis.ipynb";
notebook3 = "Notebook 3 - SoNAR (IDH).ipynb";
notebook4 = "Notebook 4 - Exploring the Network of Physiologists.ipynb";
notebook5 = "Notebook 5 - Analyzing Gustav von Schmoller.ipynb";
};
devShell.x86_64-linux =
pkgs.mkShell {
buildInputs = (with pkgs; [
python3
pandoc
(pkgs.writeShellScriptBin "start-jupyter.sh" ''
jupyter notebook \
--ip 127.0.0.1 \
--port 8888 \
--no-browser \
--NotebookApp.password="" \
--NotebookApp.token=""
'')
docker-compose
poetry
self.packages.x86_64-linux.check-notebook
self.packages.x86_64-linux.neo4j-python-driver
]) ++ (with pkgs.python3Packages; [
ipywidgets
autopep8
pandas
# nbdime
networkx
pyvis
python-louvain
]);
};
};
}