forked from lucabrunox/nixpaste
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.nix
52 lines (42 loc) · 1.54 KB
/
default.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
{ pkgs ? (import <nixpkgs> {}), url ? "http://localhost:8080", postField ? "text",
static ? ./static, views ? ./views, gunicornArgs ? "-b 0.0.0.0:8080 -t 10",
storageDir ? "/tmp/nixpaste", maxBytes ? 100000000, maxFiles ? 100000,
hashSalt ? "somesalt", hashLength ? 6
}:
assert hashSalt != null;
assert hashLength > 4;
with pkgs; with python2Packages;
let
configjson = pkgs.writeText "nixpaste-config" ''{
"STATIC": "${static}",
"VIEWS": "${views}",
"URL": "${url}",
"POST_FIELD": "${postField}",
"DIR": "${storageDir}",
"MAX_BYTES": ${builtins.toString maxBytes},
"MAX_FILES": ${builtins.toString maxFiles},
"SALT": "${hashSalt}",
"LENGTH": ${builtins.toString hashLength}
}'';
in
stdenv.mkDerivation {
name = "nixpaste";
buildInputs = [ gunicorn makeWrapper ];
propagatedBuildInputs = [ python gevent ];
inherit (python) sitePackages;
NIXPASTE_CONFIG = configjson;
GUNICORN_ARGS = gunicornArgs;
buildCommand = ''
mkdir -p $out/bin
mkdir -p $out/$sitePackages/nixpaste
cp -pdv ${./nixpaste} $out/bin/nixpaste
cp -v ${./nixpaste.py} $out/$sitePackages/nixpaste/__init__.py
cp -v ${./bottle.py} $out/$sitePackages/nixpaste/bottle.py
wrapProgram $out/bin/nixpaste \
--prefix PYTHONPATH : "$out/$sitePackages:$PYTHONPATH" \
--set NIXPASTE_CONFIG ${configjson} \
--set GUNICORN_ARGS '"''${GUNICORN_ARGS:-${gunicornArgs}}"' \
--prefix PATH : ${python}/bin:${gunicorn}/bin
patchShebangs $out
'';
}