-
Joshua Balthasar Kobschätzki authoredJoshua Balthasar Kobschätzki authored
flake.nix 2.29 KiB
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
texlive = pkgs.texlive.combined.scheme-full;
latexmkrc = ./.latexmkrc;
build-pkg = (
pkgs.writeShellScriptBin "build" ''
${texlive}/bin/latexmk -pdf -r ${latexmkrc} "$@"
''
);
# Ref: https://itsfoss.com/compress-pdf-linux/ , just small function for all the formats
compress-pkg = (
pkgs.writeShellScriptBin "compress" "${pkgs.ghostscript}/bin/gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -dNOPAUSE -dQUIET -dBATCH -sOutputFile=out/presentation.compressed.pdf out/presentation.pdf && echo 'Produced out/presentation.compressed.pdf'"
);
preview-pkg = (
pkgs.writeShellScriptBin "preview" ''
${texlive}/bin/latexmk -pvc -pdf -r ${latexmkrc} "$@"
''
);
clean-pkg = (pkgs.writeShellScriptBin "clean" ''${texlive}/bin/latexmk -C "@"'');
in
{
apps = rec {
default = build;
build = {
type = "app";
program = "${build-pkg}/bin/build";
};
# This can be used as follows: nix run .#preview -- {number}.tex
preview = {
type = "app";
program = "${preview-pkg}/bin/preview";
};
compress = {
type = "app";
program = "${compress-pkg}/bin/compress";
};
clean = {
type = "app";
program = "${clean-pkg}/bin/clean";
};
};
devShells.default = pkgs.mkShell {
buildInputs = [
texlive
pkgs.duckdb
pkgs.glow
(pkgs.python3.withPackages (python-pkgs: [
python-pkgs.virtualenv
python-pkgs.jupyter
python-pkgs.jupyterlab-widgets
python-pkgs.plotly
python-pkgs.ipywidgets
python-pkgs.duckdb