aboutsummaryrefslogtreecommitdiff
path: root/module.nix
diff options
context:
space:
mode:
authorChris Wells <chris@mathematicaster.org>2026-02-22 22:30:47 -0600
committerChris Wells <chris@mathematicaster.org>2026-02-22 22:30:47 -0600
commit85f1c033c4a489e3e38cd1af0c0495b273f2e727 (patch)
tree0e6cfd5a693601e19266ba8d4da835b5b9e48521 /module.nix
downloadtex-shell-85f1c033c4a489e3e38cd1af0c0495b273f2e727.tar
tex-shell-85f1c033c4a489e3e38cd1af0c0495b273f2e727.tar.gz
tex-shell-85f1c033c4a489e3e38cd1af0c0495b273f2e727.tar.bz2
tex-shell-85f1c033c4a489e3e38cd1af0c0495b273f2e727.tar.lz
tex-shell-85f1c033c4a489e3e38cd1af0c0495b273f2e727.tar.xz
tex-shell-85f1c033c4a489e3e38cd1af0c0495b273f2e727.tar.zst
tex-shell-85f1c033c4a489e3e38cd1af0c0495b273f2e727.zip
Initial commit
Diffstat (limited to 'module.nix')
-rw-r--r--module.nix65
1 files changed, 65 insertions, 0 deletions
diff --git a/module.nix b/module.nix
new file mode 100644
index 0000000..8cd81eb
--- /dev/null
+++ b/module.nix
@@ -0,0 +1,65 @@
+{
+ lib,
+ flake-parts-lib,
+ ...
+}:
+let
+ inherit (lib) mkOption mkPackageOption mkEnableOption types;
+ inherit (flake-parts-lib) mkPerSystemOption;
+in {
+ options.perSystem = mkPerSystemOption ({ config, ... }: {
+ options = {
+ texShell = {
+ scheme = mkPackageOption pkgs "texliveSmall" {};
+ extraPackages = mkOption {
+ type = types.functionTo (types.listOf types.package);
+ description = "Extra packages to add to the texlive scheme";
+ default = _: [];
+ };
+ latexmk = {
+ enable = mkEnableOption "latexmk";
+ rc = mkOption {
+ type = types.lines;
+ description = "contents of the .latexmkrc file";
+ };
+ rcFile = mkOption {
+ type = types.path;
+ default = pkgs.writeText "latexmkrc" config.texShell.latexmk.rc;
+ description = "the .latexmkrc file";
+ };
+ _wrapper = mkOption {
+ type = types.functionTo types.package;
+ readOnly = true;
+ internal = true;
+ default = tex: pkgs.symlinkJoin {
+ inherit (tex) name;
+ nativeBuildInputs = [
+ pkgs.makeWrapper
+ ];
+ paths = [
+ tex
+ ];
+ postBuild = ''
+ wrapProgram $out/bin/latexmk --add-flags "-r" --add-flags "${config.texShell.latexmk.rcFile}"
+ '';
+ };
+ };
+ };
+ };
+ };
+
+ config = {
+ texShell.extraPackages = mkIf config.texShell.latexmk.enable (ps: [ ps.latexmk ]);
+
+ packages.texShell = let
+ wrapper = if config.texShell.latexmk.enable then config.texShell.latexmk._wrapper else x: x;
+ in wrapper (config.texShell.scheme.withPackages config.texShell.scheme.extraPackages);
+
+ devShells.texShell = pkgs.makeShell {
+ nativeBuildInputs = [
+ config.packages.texShell
+ ];
+ };
+ };
+ });
+}