|
| 1 | +{ |
| 2 | + nixConfig.bash-prompt = ''\033[1;32m\[[nix-develop:\[\033[36m\]\w\[\033[32m\]]$\033[0m ''; |
| 3 | + |
| 4 | + inputs = { |
| 5 | + nixpkgs.url = "github:nixos/nixpkgs/23.05-pre"; |
| 6 | + whacked-setup = { |
| 7 | + url = "github:whacked/setup/58bdbff2eec48980b010048032382bed3a152e7e"; |
| 8 | + flake = false; |
| 9 | + }; |
| 10 | + }; |
| 11 | + outputs = { self, nixpkgs, flake-utils, whacked-setup }: |
| 12 | + flake-utils.lib.eachDefaultSystem |
| 13 | + (system: |
| 14 | + let |
| 15 | + pkgs = nixpkgs.legacyPackages.${system}; |
| 16 | + whacked-helpers = import (whacked-setup + /nix/flake-helpers.nix) { inherit pkgs; }; |
| 17 | + in { |
| 18 | + devShell = whacked-helpers.mkShell { |
| 19 | + flakeFile = __curPos.file; # used to forward current file to echo-shortcuts |
| 20 | + includeScripts = [ |
| 21 | + # e.g. for node shortcuts |
| 22 | + # (whacked-setup + /bash/node_shortcuts.sh) |
| 23 | + ]; |
| 24 | + } { |
| 25 | + buildInputs = [ |
| 26 | + pkgs.python3 |
| 27 | + ]; |
| 28 | + |
| 29 | + shellHook = ( |
| 30 | + if pkgs.stdenv.isDarwin then '' |
| 31 | + ### PREFLIGHT |
| 32 | + if ! command -v quarto &> /dev/null; then |
| 33 | + pastel paint red "program 'quarto' not found in the path. nbdev requires it to work" |
| 34 | + echo -n "you can obtain it manually from " |
| 35 | + pastel paint yellow https://quarto.org/docs/get-started |
| 36 | + exit |
| 37 | + fi |
| 38 | + '' else '' |
| 39 | + '') + '' |
| 40 | + ### SETUP |
| 41 | + export VIRTUAL_ENV=''${VIRTUAL_ENV-$PWD/venv} |
| 42 | + # FIX for ImportError: libstdc++.so.6: cannot open shared object file: No such file or directory |
| 43 | + # but note that gcc may be a costly import |
| 44 | + export LD_LIBRARY_PATH=${pkgs.gcc-unwrapped.lib}/lib:$LD_LIBRARY_PATH |
| 45 | + export JUPYTER_CONFIG_DIR=''${JUPYTER_CONFIG_DIR-$PWD/.jupyter} |
| 46 | + if [ ! -e $JUPYTER_CONFIG_DIR ]; then |
| 47 | + mkdir $JUPYTER_CONFIG_DIR |
| 48 | + fi |
| 49 | + setup-venv() { # install all expected virutalenv packages |
| 50 | + # see note at https://stackoverflow.com/a/65599505 |
| 51 | + # on nb extensions (in)compatibility. |
| 52 | + # below versions are from trial and error |
| 53 | + pip install \ |
| 54 | + twine==4.0.2 \ |
| 55 | + notebook==6.2.0 \ |
| 56 | + jupyter_server==2.3.0 \ |
| 57 | + jupyter_core==5.2.0 \ |
| 58 | + nbconvert==7.2.9 \ |
| 59 | + nbformat==5.7.3 \ |
| 60 | + nbdev==2.3.12 \ |
| 61 | + jupytext==1.14.5 \ |
| 62 | + jupyter_contrib_nbextensions==0.5.1 \ |
| 63 | + jupyter_nbextensions_configurator |
| 64 | + jupyter contrib nbextension install --user |
| 65 | + ENABLE_BUNDLED_EXTENSIONS=( |
| 66 | + code_prettify/autopep8 |
| 67 | + codefolding/main |
| 68 | + collapsible_headings/main |
| 69 | + contrib_nbextensions_help_item/main |
| 70 | + datestamper/main |
| 71 | + execute_time/ExecuteTime |
| 72 | + freeze/main |
| 73 | + scratchpad/main |
| 74 | + toc2/main |
| 75 | + toggle_all_line_numbers/main |
| 76 | + varInspector/main |
| 77 | + ); |
| 78 | + } |
| 79 | + ensure-venv setup-venv |
| 80 | + '' + '' |
| 81 | + ### SHORTCUTS |
| 82 | + alias check='python -m schematized_config' |
| 83 | + ''; # join strings with + |
| 84 | + }; |
| 85 | + |
| 86 | + packages = { |
| 87 | + default = pkgs.stdenv.mkDerivation { |
| 88 | + name = "schematized-config"; |
| 89 | + src = ./.; |
| 90 | + }; |
| 91 | + }; |
| 92 | + } |
| 93 | + ); |
| 94 | +} |
0 commit comments