templates/jupyter/flake.nix

53 lines
1.8 KiB
Nix
Raw Normal View History

2023-10-13 15:57:53 +02:00
{
description = "A jupyter flake, with a custom haskell kernel and proper pdflatex LaTeX export supoprt";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (sys:
let pkgs = import nixpkgs { system = sys; };
2025-01-23 14:56:51 +01:00
python = pkgs.python311;
2023-10-13 15:57:53 +02:00
latex = pkgs.texlive.combine {
inherit (pkgs.texlive)
scheme-basic # Base
tcolorbox pgf environ etoolbox pdfcol parskip caption float upquote eurosym ucs fancyvrb grffile adjustbox hyperref titling booktabs enumitem ulem soul rsfs jknapltx cm-super # Other packages needed by jupyter.
2023-10-15 11:15:04 +02:00
tikz-among-us; # extra packages
2023-10-13 15:57:53 +02:00
};
jupyter-config = python.pkgs.buildPythonPackage rec {
name = "jupyter-config";
format = "other";
src = ./jupyter-config ;
installPhase = ''
find . -type f -exec sed -i 's|<pdflatex>|${latex}/bin/pdflatex|g' {} +
mkdir -p $out/etc/jupyter/
cp -r . $out/etc/jupyter/
'';
};
2023-10-15 12:36:25 +02:00
python-environment = (python.withPackages (ps: with ps; [
2025-01-23 14:56:51 +01:00
ipympl numpy matplotlib scipy cvxpy
2023-10-15 11:15:04 +02:00
2023-10-13 15:57:53 +02:00
jupyter-core jupyter
2025-01-23 14:56:51 +01:00
jupyter-config
2023-10-13 15:57:53 +02:00
]));
in rec {
packages.latex = latex;
packages.python-environment = python-environment;
2025-01-23 14:56:51 +01:00
packages.default = pkgs.writeShellApplication {
name = "start-notebook";
runtimeInputs = [latex pkgs.pandoc python-environment ];
text = "${python-environment}/bin/jupyter-notebook";
};
2023-10-13 15:57:53 +02:00
devShells.default = pkgs.mkShell {
packages = [ python-environment latex ];
};
}
);
}