mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-11-11 07:55:31 +00:00
Created latexmk builder
This commit is contained in:
parent
387eb9ba27
commit
aef828406d
3 changed files with 78 additions and 11 deletions
|
|
@ -1,36 +1,35 @@
|
||||||
# This function acts as a template for creating new builders.
|
# This function acts as a template for creating new builders.
|
||||||
# It enforces providing all the parameters required for creating
|
# It enforces providing all the parameters required for creating
|
||||||
# a new builder for it to be able to work in the existing code.
|
# a new builder for it to be able to work in the existing code.
|
||||||
|
#
|
||||||
# The first layer requirements are as follows:
|
# The first layer requirements are as follows:
|
||||||
{
|
{
|
||||||
# This is the name of the builder, it will only be used internally and
|
# 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.
|
# should match the <name>.nix file that the builder is implemented in.
|
||||||
name,
|
name,
|
||||||
|
#
|
||||||
# Module attribute set. This is the attribute set that the module that is
|
# Module attribute set. This is the attribute set that the module that is
|
||||||
# defining a builder is passed as its input.
|
# defining a builder is passed as its input.
|
||||||
moduleInheritencePackage,
|
moduleInheritencePackage,
|
||||||
|
#
|
||||||
# These are the standard options for the builder just like creating any
|
# These are the standard options for the builder just like creating any
|
||||||
# other module. Some options are required and are described below but
|
# other module. Some options are required and are described below but
|
||||||
# it will also accept any other options that are provided to it.
|
# it will also accept any other options that are provided to it.
|
||||||
options,
|
options,
|
||||||
|
#
|
||||||
# These are the command line arguments that will accompany the executable
|
# These are the command line arguments that will accompany the executable
|
||||||
# when the build command is called.
|
# when the build command is called.
|
||||||
# This is a function that will take in the cfg of its own builder.
|
# 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}"
|
# i.e. will be called as "args cfg.build.builders.${name}"
|
||||||
args,
|
args,
|
||||||
|
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
# Inherit the necessary variables available to any module.
|
# Inherit the necessary variables available to any module.
|
||||||
inherit (moduleInheritencePackage) lib config;
|
inherit (moduleInheritencePackage) lib config;
|
||||||
|
#
|
||||||
# Inherit other useful functions.
|
# Inherit other useful functions.
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
|
#
|
||||||
# Set the cfg variable
|
# Set the cfg variable
|
||||||
cfg = config.vim.languages.tex;
|
cfg = config.vim.languages.tex;
|
||||||
in {
|
in {
|
||||||
|
|
@ -39,15 +38,15 @@ in {
|
||||||
options.vim.languages.tex.build.builders.${name} = ({
|
options.vim.languages.tex.build.builders.${name} = ({
|
||||||
# The enable option. This one is self explanatory.
|
# The enable option. This one is self explanatory.
|
||||||
enable,
|
enable,
|
||||||
|
#
|
||||||
# This is the package option for the builder.
|
# This is the package option for the builder.
|
||||||
package,
|
package,
|
||||||
|
#
|
||||||
# This is the executable that will be used to call the builder.
|
# This is the executable that will be used to call the builder.
|
||||||
# It, along with package will result in:
|
# It, along with package will result in:
|
||||||
# "<package_path>/bin/<executable>"
|
# "<package_path>/bin/<executable>"
|
||||||
executable,
|
executable,
|
||||||
|
#
|
||||||
# Any other options provided are accepted.
|
# Any other options provided are accepted.
|
||||||
...
|
...
|
||||||
} @ opts:
|
} @ opts:
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ let
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
# ./custom.nix
|
./latexmk.nix
|
||||||
./tectonic.nix
|
./tectonic.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
||||||
68
modules/plugins/languages/tex/build/builders/latexmk.nix
Normal file
68
modules/plugins/languages/tex/build/builders/latexmk.nix
Normal 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"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue