PageRenderTime 27ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/pkgs/development/python-modules/jupyterhub/default.nix

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