Created latexmk builder

This commit is contained in:
isaacST08 2025-01-24 10:49:26 -07:00
commit aef828406d
3 changed files with 78 additions and 11 deletions

View file

@ -1,36 +1,35 @@
# This function acts as a template for creating new builders.
# It enforces providing all the parameters required for creating
# a new builder for it to be able to work in the existing code.
#
# The first layer requirements are as follows:
{
# This is the name of the builder, it will only be used internally and
# should match the <name>.nix file that the builder is implemented in.
name,
#
# Module attribute set. This is the attribute set that the module that is
# defining a builder is passed as its input.
moduleInheritencePackage,
#
# These are the standard options for the builder just like creating any
# other module. Some options are required and are described below but
# it will also accept any other options that are provided to it.
options,
#
# These are the command line arguments that will accompany the executable
# when the build command is called.
# This is a function that will take in the cfg of its own builder.
# i.e. will be called as "args cfg.build.builders.${name}"
args,
...
}: let
# Inherit the necessary variables available to any module.
inherit (moduleInheritencePackage) lib config;
#
# Inherit other useful functions.
inherit (lib.modules) mkIf;
#
# Set the cfg variable
cfg = config.vim.languages.tex;
in {
@ -39,15 +38,15 @@ in {
options.vim.languages.tex.build.builders.${name} = ({
# The enable option. This one is self explanatory.
enable,
#
# This is the package option for the builder.
package,
#
# This is the executable that will be used to call the builder.
# It, along with package will result in:
# "<package_path>/bin/<executable>"
executable,
#
# Any other options provided are accepted.
...
} @ opts:

View file

@ -13,7 +13,7 @@ let
in
{
imports = [
# ./custom.nix
./latexmk.nix
./tectonic.nix
];

View file

@ -0,0 +1,68 @@
# TODO: I need testing.
{
config,
pkgs,
lib,
...
} @ moduleInheritencePackage: let
# The name of the builder
name = "latexmk";
# The builder template
template = import ./builderTemplate.nix;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) bool package str;
cfg = config.vim.languages.tex;
# --- Enable Options ---
mkEnableDefaultOption = default: description: (mkOption {
type = bool;
default = default;
example = !default;
description = description;
});
in (
template {
inherit name moduleInheritencePackage;
options = {
enable = mkEnableOption "Whether to enable Tex Compilation Via latexmk";
package = mkOption {
type = package;
default = (pkgs.texlive.withPackages (ps: [ ps.latexmk ]));
description = "latexmk package";
};
executable = mkOption {
type = str;
default = "latexmk";
description = "The executable name from the build package that will be used to build/compile the tex.";
};
# Flag options
pdfOutput = mkOption {
type = bool;
default = true;
example = false;
description = "Insure the output file is a pdf.";
};
};
args = builderCfg: (
# Flags
(
if builderCfg.pdfOutput
then ["-pdf"]
else []
)
# Base args
++ [
"-quiet"
"%f"
]
);
}
)