diff --git a/modules/plugins/languages/tex/build/builders/builderTemplate.nix b/modules/plugins/languages/tex/build/builders/builderTemplate.nix index 3d3f607f..c9cc8163 100644 --- a/modules/plugins/languages/tex/build/builders/builderTemplate.nix +++ b/modules/plugins/languages/tex/build/builders/builderTemplate.nix @@ -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 .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: # "/bin/" executable, - + # # Any other options provided are accepted. ... } @ opts: diff --git a/modules/plugins/languages/tex/build/builders/default.nix b/modules/plugins/languages/tex/build/builders/default.nix index 3e9eca59..0e4eb8d8 100644 --- a/modules/plugins/languages/tex/build/builders/default.nix +++ b/modules/plugins/languages/tex/build/builders/default.nix @@ -13,7 +13,7 @@ let in { imports = [ - # ./custom.nix + ./latexmk.nix ./tectonic.nix ]; diff --git a/modules/plugins/languages/tex/build/builders/latexmk.nix b/modules/plugins/languages/tex/build/builders/latexmk.nix new file mode 100644 index 00000000..1cc4eb51 --- /dev/null +++ b/modules/plugins/languages/tex/build/builders/latexmk.nix @@ -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" + ] + ); + } +)