Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 20.03 125 lines 3.6 kB view raw
1{ lib 2, buildPythonPackage 3, fetchPypi 4, fetchzip 5, alembic 6, ipython 7, jinja2 8, python-oauth2 9, prometheus_client 10, async_generator 11, pamela 12, sqlalchemy 13, tornado 14, traitlets 15, requests 16, notebook 17, pythonOlder 18, nodePackages 19, oauthlib 20, certipy 21}: 22 23let 24 # js/css assets that setup.py tries to fetch via `npm install` when building 25 # from source. 26 bootstrap = 27 fetchzip { 28 url = "https://registry.npmjs.org/bootstrap/-/bootstrap-3.3.7.tgz"; 29 sha256 = "0r7s54bbf68ri1na9bbabyf12mcpb6zk5ja2q6z82aw1fa4xi3yd"; 30 }; 31 font-awesome = 32 fetchzip { 33 url = "https://registry.npmjs.org/font-awesome/-/font-awesome-4.7.0.tgz"; 34 sha256 = "1xnxbdlfdd60z5ix152m8r2kk9dkwlqwpypky1mm3dv64ajnzdbk"; 35 }; 36 jquery = 37 fetchzip { 38 url = "https://registry.npmjs.org/jquery/-/jquery-3.2.1.tgz"; 39 sha256 = "1j6y18miwzafdj8kfpwbmbn9qvgnbnpc7l4arqrhqj33m04xrlgi"; 40 }; 41 moment = 42 fetchzip { 43 url = "https://registry.npmjs.org/moment/-/moment-2.22.2.tgz"; 44 sha256 = "12gb3p0rz5wyjwykv9g0pix7dd352lx1z7rzdjsf2brhwc4ffyip"; 45 }; 46 requirejs = 47 fetchzip { 48 url = "https://registry.npmjs.org/requirejs/-/requirejs-2.3.4.tgz"; 49 sha256 = "0q6mkj0iv341kks06dya6lfs2kdw0n6vc7n4a7aa3ia530fk9vja"; 50 }; 51 52in 53 54buildPythonPackage rec { 55 pname = "jupyterhub"; 56 version = "1.0.0"; 57 disabled = pythonOlder "3.5"; 58 59 src = fetchPypi { 60 inherit pname version; 61 sha256 = "0zx6gw9yhgki05j21p6x1x2sf5a2mg2c2mx0ii8rl6q4b98ilm1k"; 62 }; 63 64 # Most of this only applies when building from source (e.g. js/css assets are 65 # pre-built and bundled in the official release tarball on pypi). 66 # 67 # Stuff that's always needed: 68 # * At runtime, we need configurable-http-proxy, so we substitute the store 69 # path. 70 # 71 # Other stuff that's only needed when building from source: 72 # * js/css assets are fetched from npm. 73 # * substitute store path for `lessc` commmand. 74 # * set up NODE_PATH so `lessc` can find `less-plugin-clean-css`. 75 # * don't run `npm install`. 76 preBuild = '' 77 export NODE_PATH=${nodePackages.less-plugin-clean-css}/lib/node_modules 78 79 substituteInPlace jupyterhub/proxy.py --replace \ 80 "'configurable-http-proxy'" \ 81 "'${nodePackages.configurable-http-proxy}/bin/configurable-http-proxy'" 82 83 substituteInPlace jupyterhub/tests/test_proxy.py --replace \ 84 "'configurable-http-proxy'" \ 85 "'${nodePackages.configurable-http-proxy}/bin/configurable-http-proxy'" 86 87 substituteInPlace setup.py --replace \ 88 "'npm', 'run', 'lessc', '--'" \ 89 "'${nodePackages.less}/bin/lessc'" 90 91 substituteInPlace setup.py --replace \ 92 "'npm', 'install', '--progress=false'" \ 93 "'true'" 94 95 declare -A deps 96 deps[bootstrap]=${bootstrap} 97 deps[font-awesome]=${font-awesome} 98 deps[jquery]=${jquery} 99 deps[moment]=${moment} 100 deps[requirejs]=${requirejs} 101 102 mkdir -p share/jupyter/hub/static/components 103 for dep in "''${!deps[@]}"; do 104 if [ ! -e share/jupyter/hub/static/components/$dep ]; then 105 cp -r ''${deps[$dep]} share/jupyter/hub/static/components/$dep 106 fi 107 done 108 ''; 109 110 propagatedBuildInputs = [ 111 alembic ipython jinja2 pamela python-oauth2 requests sqlalchemy tornado 112 traitlets prometheus_client async_generator notebook certipy oauthlib 113 ]; 114 115 # Disable tests because they take an excessive amount of time to complete. 116 doCheck = false; 117 118 119 meta = with lib; { 120 description = "Serves multiple Jupyter notebook instances"; 121 homepage = https://jupyter.org/; 122 license = licenses.bsd3; 123 maintainers = with maintainers; [ ixxie cstrahan ]; 124 }; 125}