Skip to content

Commit 8f885b5

Browse files
committed
Started merging
1 parent 99cd857 commit 8f885b5

File tree

6 files changed

+251
-116
lines changed

6 files changed

+251
-116
lines changed

flake.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
{
2+
description = "Six Degrees of Wikipedia";
3+
4+
inputs = {
5+
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
6+
};
7+
8+
outputs = { self, nixpkgs }: let
9+
pkgs = import nixpkgs {system = "x86_64-linux";};
10+
python-gunicorn = pkgs.python3.withPackages (pp: with pp;[
11+
flask
12+
flask-compress
13+
flask-cors
14+
gunicorn
15+
protobuf
16+
requests
17+
]);
18+
sdow-api-gunicorn = pkgs.writeShellApplication {
19+
name = "sdow-api";
20+
runtimeInputs = [ python-gunicorn ];
21+
text = ''
22+
cd "${self.packages.x86_64-linux.sdow-api}"
23+
if [ ! -f "$1" ]
24+
then echo "First argument should be a path to the sdow database"; exit 1
25+
fi
26+
if [ -z "$2" ]
27+
then echo "Second argument should be a path to the searches database"; exit 1
28+
fi
29+
GUNICORN_PORT=''${GUNICORN_PORT:-8000}
30+
31+
export SDOW_DATABASE=$1
32+
export SEARCHES_DATABASE=$2
33+
gunicorn -b "0.0.0.0:$GUNICORN_PORT" server:app
34+
'';
35+
};
36+
python-db = pkgs.python3.withPackages (pp: with pp;[
37+
tqdm
38+
]);
39+
sdow-db-folder = ./scripts;
40+
sdow-db = pkgs.writeShellApplication {
41+
name = "sdow-db";
42+
runtimeInputs = [
43+
python-db
44+
pkgs.sqlite
45+
pkgs.pv
46+
pkgs.gnugrep
47+
pkgs.wget
48+
pkgs.coreutils-full
49+
pkgs.gzip
50+
pkgs.gnused
51+
pkgs.gawkInteractive
52+
];
53+
text = ''
54+
${pkgs.bash}/bin/bash ${sdow-db-folder}/buildDatabase.sh "$@"
55+
'';
56+
};
57+
in {
58+
59+
packages.x86_64-linux = {
60+
default = self.packages.x86_64-linux.sdow;
61+
sdow = pkgs.buildNpmPackage {
62+
name = "sdow";
63+
buildInputs = with pkgs; [
64+
nodejs_latest
65+
];
66+
src = ./website;
67+
68+
npmDeps = pkgs.importNpmLock {
69+
npmRoot = ./website;
70+
};
71+
72+
npmFlags = [ "--legacy-peer-deps" ];
73+
74+
npmConfigHook = pkgs.importNpmLock.npmConfigHook;
75+
76+
installPhase = ''
77+
cp -r build/ $out
78+
'';
79+
};
80+
81+
sdow-api = pkgs.stdenv.mkDerivation {
82+
name = "sdow-api";
83+
src = ./sdow;
84+
buildInputs = [ python-gunicorn ];
85+
installPhase = ''
86+
cp -r . $out
87+
'';
88+
};
89+
sdow-db = sdow-db;
90+
};
91+
apps.x86_64-linux = {
92+
default = self.apps.x86_64-linux.sdow-api;
93+
sdow-api = {
94+
type = "app";
95+
program = "${sdow-api-gunicorn}/bin/sdow-api";
96+
};
97+
sdow-db = {
98+
type = "app";
99+
program = "${sdow-db}/bin/sdow-db";
100+
};
101+
};
102+
};
103+
}

0 commit comments

Comments
 (0)