mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2025-12-20 21:00:04 +01:00
Removed builderTemplate implementation in favour of an inline approach
This commit is contained in:
parent
4d80eeb006
commit
0da99e05ae
6 changed files with 400 additions and 625 deletions
|
|
@ -1,66 +0,0 @@
|
||||||
# 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.
|
|
||||||
moduleInheritancePackage,
|
|
||||||
#
|
|
||||||
# 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 (moduleInheritancePackage) lib config;
|
|
||||||
#
|
|
||||||
# Inherit other useful functions.
|
|
||||||
inherit (lib.modules) mkIf;
|
|
||||||
#
|
|
||||||
# Set the cfg variable
|
|
||||||
cfg = config.vim.languages.tex;
|
|
||||||
in {
|
|
||||||
# These are the options for the builder. It will accept any options
|
|
||||||
# provided to it but some options are mandatory:
|
|
||||||
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:
|
|
||||||
opts)
|
|
||||||
options;
|
|
||||||
|
|
||||||
# Check that the language and this builder have been enabled
|
|
||||||
# before making any config.
|
|
||||||
config = mkIf (cfg.enable && cfg.build.builders.${name}.enable) {
|
|
||||||
vim.languages.tex.build.builder = {
|
|
||||||
inherit name;
|
|
||||||
package = cfg.build.builders.${name}.package;
|
|
||||||
executable = cfg.build.builders.${name}.executable;
|
|
||||||
args = args cfg.build.builders.${name};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,57 +1,53 @@
|
||||||
# TODO: I need testing.
|
# TODO: I need testing.
|
||||||
{
|
{
|
||||||
pkgs,
|
config,
|
||||||
lib,
|
lib,
|
||||||
|
pkgs,
|
||||||
...
|
...
|
||||||
} @ moduleInheritancePackage: let
|
}: let
|
||||||
# The name of the builder
|
# The name of the builder
|
||||||
name = "latexmk";
|
name = "latexmk";
|
||||||
|
|
||||||
# The builder template
|
inherit (lib.modules) mkIf;
|
||||||
template = import ./builderTemplate.nix;
|
inherit (lib.nvim.config) mkBool;
|
||||||
|
|
||||||
inherit (lib.options) mkOption mkEnableOption;
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
inherit (lib.types) bool package str;
|
inherit (lib.types) package str;
|
||||||
in (
|
|
||||||
template {
|
|
||||||
inherit name moduleInheritancePackage;
|
|
||||||
|
|
||||||
options = {
|
texCfg = config.vim.languages.tex;
|
||||||
enable = mkEnableOption "Whether to enable Tex Compilation Via latexmk";
|
cfg = texCfg.build.builders.${name};
|
||||||
|
in {
|
||||||
|
options.vim.languages.tex.build.builders.${name} = {
|
||||||
|
enable = mkEnableOption "Whether to enable Tex Compilation Via latexmk";
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = package;
|
type = package;
|
||||||
default = pkgs.texlive.withPackages (ps: [ps.latexmk]);
|
default = pkgs.texlive.withPackages (ps: [ps.latexmk]);
|
||||||
description = "latexmk package";
|
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: (
|
executable = mkOption {
|
||||||
# Flags
|
type = str;
|
||||||
(
|
default = "latexmk";
|
||||||
if builderCfg.pdfOutput
|
description = "The executable name from the build package that will be used to build/compile the tex.";
|
||||||
then ["-pdf"]
|
};
|
||||||
else []
|
|
||||||
)
|
# Flag options
|
||||||
# Base args
|
pdfOutput = mkBool true "Insure the output file is a pdf.";
|
||||||
++ [
|
};
|
||||||
"-quiet"
|
|
||||||
"%f"
|
config = mkIf (texCfg.enable && cfg.enable) {
|
||||||
]
|
vim.languages.tex.build.builder = {
|
||||||
);
|
inherit name;
|
||||||
}
|
inherit (cfg) package executable;
|
||||||
)
|
args = (
|
||||||
|
# Flags
|
||||||
|
(lib.lists.optional cfg.pdfOutput "-pdf")
|
||||||
|
# Base args
|
||||||
|
++ [
|
||||||
|
"-quiet"
|
||||||
|
"%f"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,203 +1,161 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
pkgs,
|
|
||||||
lib,
|
lib,
|
||||||
|
pkgs,
|
||||||
...
|
...
|
||||||
} @ moduleInheritancePackage: let
|
}: let
|
||||||
# The name of the builder
|
# The name of the builder
|
||||||
name = "tectonic";
|
name = "tectonic";
|
||||||
|
|
||||||
# The builder template
|
inherit (builtins) concatLists elem map toString match;
|
||||||
template = import ./builderTemplate.nix;
|
inherit (lib.modules) mkIf;
|
||||||
|
|
||||||
inherit (lib.options) mkOption mkEnableOption;
|
|
||||||
inherit (lib.types) enum ints listOf package str;
|
|
||||||
inherit (lib.nvim.config) mkBool;
|
inherit (lib.nvim.config) mkBool;
|
||||||
inherit (builtins) concatLists elem map toString;
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
|
inherit (lib.strings) toLower optionalString stringAsChars;
|
||||||
|
inherit (lib.types) enum ints listOf package str;
|
||||||
|
|
||||||
cfg = config.vim.languages.tex;
|
texCfg = config.vim.languages.tex;
|
||||||
in (
|
cfg = texCfg.build.builders.${name};
|
||||||
template {
|
in {
|
||||||
inherit name moduleInheritancePackage;
|
options.vim.languages.tex.build.builders.${name} = {
|
||||||
|
enable = mkEnableOption "Whether to enable Tex Compilation Via Tectonic";
|
||||||
|
|
||||||
options = {
|
package = mkOption {
|
||||||
enable = mkEnableOption "Whether to enable Tex Compilation Via Tectonic";
|
type = package;
|
||||||
|
default = pkgs.tectonic;
|
||||||
package = mkOption {
|
description = "tectonic package";
|
||||||
type = package;
|
|
||||||
default = pkgs.tectonic;
|
|
||||||
description = "tectonic package";
|
|
||||||
};
|
|
||||||
|
|
||||||
executable = mkOption {
|
|
||||||
type = str;
|
|
||||||
default = "tectonic";
|
|
||||||
description = "The executable name from the build package that will be used to build/compile the tex.";
|
|
||||||
};
|
|
||||||
|
|
||||||
# -- Flags --
|
|
||||||
keepIntermediates = mkBool false ''
|
|
||||||
Keep the intermediate files generated during processing.
|
|
||||||
|
|
||||||
If texlab is reporting build errors when there shouldn't be, disable this option.
|
|
||||||
'';
|
|
||||||
keepLogs = mkBool true ''
|
|
||||||
Keep the log files generated during processing.
|
|
||||||
|
|
||||||
Without the keepLogs flag, texlab won't be able to report compilation warnings.
|
|
||||||
'';
|
|
||||||
onlyCached = mkBool false "Use only resource files cached locally";
|
|
||||||
synctex = mkBool true "Generate SyncTeX data";
|
|
||||||
untrustedInput = mkBool false "Input is untrusted -- disable all known-insecure features";
|
|
||||||
|
|
||||||
# -- Options --
|
|
||||||
reruns = mkOption {
|
|
||||||
type = ints.unsigned;
|
|
||||||
default = 0;
|
|
||||||
example = 2;
|
|
||||||
description = ''
|
|
||||||
Rerun the TeX engine exactly this many times after the first.
|
|
||||||
|
|
||||||
Setting this value to 0 will disable setting this option.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
bundle = mkOption {
|
|
||||||
type = str;
|
|
||||||
default = "";
|
|
||||||
description = "Use this directory or Zip-format bundle file to find resource files instead of the default";
|
|
||||||
};
|
|
||||||
|
|
||||||
webBundle = mkOption {
|
|
||||||
type = str;
|
|
||||||
default = "";
|
|
||||||
description = "Use this URL to find resource files instead of the default";
|
|
||||||
};
|
|
||||||
|
|
||||||
outfmt = mkOption {
|
|
||||||
type = enum [
|
|
||||||
"pdf"
|
|
||||||
"html"
|
|
||||||
"xdv"
|
|
||||||
"aux"
|
|
||||||
"fmt"
|
|
||||||
""
|
|
||||||
];
|
|
||||||
default = "";
|
|
||||||
description = "The kind of output to generate";
|
|
||||||
};
|
|
||||||
|
|
||||||
hidePaths = mkOption {
|
|
||||||
type = listOf str;
|
|
||||||
default = [];
|
|
||||||
example = [
|
|
||||||
"./secrets.tex"
|
|
||||||
"./passwords.tex"
|
|
||||||
];
|
|
||||||
description = "Tell the engine that no file at <hide_path> exists, if it tries to read it.";
|
|
||||||
};
|
|
||||||
|
|
||||||
format = mkOption {
|
|
||||||
type = str;
|
|
||||||
default = "";
|
|
||||||
description = "The name of the \"format\" file used to initialize the TeX engine";
|
|
||||||
};
|
|
||||||
|
|
||||||
color = mkOption {
|
|
||||||
type = enum [
|
|
||||||
"always"
|
|
||||||
"auto"
|
|
||||||
"never"
|
|
||||||
""
|
|
||||||
];
|
|
||||||
default = "";
|
|
||||||
example = "always";
|
|
||||||
description = "Enable/disable colorful log output";
|
|
||||||
};
|
|
||||||
|
|
||||||
extraOptions = {
|
|
||||||
type = listOf str;
|
|
||||||
default = [];
|
|
||||||
description = ''
|
|
||||||
Add extra command line options to include in the tectonic build command.
|
|
||||||
Extra options added here will not overwrite the options set in as nvf options.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
args = builderCfg: (
|
executable = mkOption {
|
||||||
# Base args
|
type = str;
|
||||||
[
|
default = "tectonic";
|
||||||
"-X"
|
description = "The executable name from the build package that will be used to build/compile the tex.";
|
||||||
"compile"
|
};
|
||||||
"%f"
|
|
||||||
]
|
# -- Flags --
|
||||||
# Flags
|
keepIntermediates = mkBool false ''
|
||||||
++ (
|
Keep the intermediate files generated during processing.
|
||||||
if builderCfg.keepIntermediates
|
|
||||||
then ["--keep-intermediates"]
|
If texlab is reporting build errors when there shouldn't be, disable this option.
|
||||||
else []
|
'';
|
||||||
)
|
keepLogs = mkBool true ''
|
||||||
++ (
|
Keep the log files generated during processing.
|
||||||
if builderCfg.keepLogs
|
|
||||||
then ["--keep-logs"]
|
Without the keepLogs flag, texlab won't be able to report compilation warnings.
|
||||||
else []
|
'';
|
||||||
)
|
onlyCached = mkBool false "Use only resource files cached locally";
|
||||||
++ (
|
synctex = mkBool true "Generate SyncTeX data";
|
||||||
if builderCfg.onlyCached
|
untrustedInput = mkBool false "Input is untrusted -- disable all known-insecure features";
|
||||||
then ["--only-cached"]
|
|
||||||
else []
|
# -- Options --
|
||||||
)
|
reruns = mkOption {
|
||||||
++ (
|
type = ints.unsigned;
|
||||||
if builderCfg.synctex
|
default = 0;
|
||||||
then ["--synctex"]
|
example = 2;
|
||||||
else []
|
description = ''
|
||||||
)
|
Rerun the TeX engine exactly this many times after the first.
|
||||||
++ (
|
|
||||||
if builderCfg.untrustedInput
|
Setting this value to 0 will disable setting this option.
|
||||||
then ["--untrusted"]
|
'';
|
||||||
else []
|
};
|
||||||
)
|
|
||||||
# Options
|
bundle = mkOption {
|
||||||
++ (
|
type = str;
|
||||||
if builderCfg.reruns > 0
|
default = "";
|
||||||
then ["--reruns" "${toString builderCfg.reruns}"]
|
description = "Use this directory or Zip-format bundle file to find resource files instead of the default";
|
||||||
else []
|
};
|
||||||
)
|
|
||||||
++ (
|
webBundle = mkOption {
|
||||||
if builderCfg.bundle != ""
|
type = str;
|
||||||
then ["--bundle" "${toString builderCfg.bundle}"]
|
default = "";
|
||||||
else []
|
description = "Use this URL to find resource files instead of the default";
|
||||||
)
|
};
|
||||||
++ (
|
|
||||||
if builderCfg.webBundle != ""
|
outfmt = mkOption {
|
||||||
then ["--web-bundle" "${toString builderCfg.webBundle}"]
|
type = enum [
|
||||||
else []
|
"pdf"
|
||||||
)
|
"html"
|
||||||
++ (
|
"xdv"
|
||||||
if builderCfg.outfmt != ""
|
"aux"
|
||||||
then ["--outfmt" "${toString builderCfg.outfmt}"]
|
"fmt"
|
||||||
else []
|
""
|
||||||
)
|
];
|
||||||
++ (concatLists (map (x: ["--hide" x]) builderCfg.hidePaths))
|
default = "";
|
||||||
++ (
|
description = "The kind of output to generate";
|
||||||
if builderCfg.format != ""
|
};
|
||||||
then ["--format" "${toString builderCfg.format}"]
|
|
||||||
else []
|
hidePaths = mkOption {
|
||||||
)
|
type = listOf str;
|
||||||
++ (
|
default = [];
|
||||||
if builderCfg.color != ""
|
example = [
|
||||||
then ["--color" "${toString builderCfg.color}"]
|
"./secrets.tex"
|
||||||
else []
|
"./passwords.tex"
|
||||||
)
|
];
|
||||||
# Still options but these are not defined by builder specific options but
|
description = "Tell the engine that no file at <hide_path> exists, if it tries to read it.";
|
||||||
# instead synchronize options between the global build options and builder
|
};
|
||||||
# specific options
|
|
||||||
++ (
|
format = mkOption {
|
||||||
if !(elem cfg.build.pdfDirectory ["." ""])
|
type = str;
|
||||||
then ["--outdir" "${cfg.build.pdfDirectory}"]
|
default = "";
|
||||||
else []
|
description = "The name of the \"format\" file used to initialize the TeX engine";
|
||||||
)
|
};
|
||||||
);
|
|
||||||
}
|
color = mkOption {
|
||||||
)
|
type = enum [
|
||||||
|
"always"
|
||||||
|
"auto"
|
||||||
|
"never"
|
||||||
|
""
|
||||||
|
];
|
||||||
|
default = "";
|
||||||
|
example = "always";
|
||||||
|
description = "Enable/disable colorful log output";
|
||||||
|
};
|
||||||
|
|
||||||
|
extraOptions = {
|
||||||
|
type = listOf str;
|
||||||
|
default = [];
|
||||||
|
description = ''
|
||||||
|
Add extra command line options to include in the tectonic build command.
|
||||||
|
Extra options added here will not overwrite the options set in as nvf options.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf (texCfg.enable && cfg.enable) {
|
||||||
|
vim.languages.tex.build.builder = {
|
||||||
|
inherit name;
|
||||||
|
inherit (cfg) package executable;
|
||||||
|
args = let
|
||||||
|
inherit (lib.lists) optional optionals;
|
||||||
|
snakeCaseToKebabCase = str: stringAsChars (x: "${optionalString ((match "[A-Z]" x) != null) "-"}${toLower x}") str;
|
||||||
|
generateOptionFlag = option: (optionals (cfg.${option} != "") ["--${snakeCaseToKebabCase option}" "${toString cfg.${option}}"]);
|
||||||
|
in (
|
||||||
|
# Base args
|
||||||
|
[
|
||||||
|
"-X"
|
||||||
|
"compile"
|
||||||
|
"%f"
|
||||||
|
]
|
||||||
|
# Flags
|
||||||
|
++ (optional cfg.keepIntermediates "--keep-intermediates")
|
||||||
|
++ (optional cfg.keepLogs "--keep-logs")
|
||||||
|
++ (optional cfg.onlyCached "--only-cached")
|
||||||
|
++ (optional cfg.synctex "--synctex")
|
||||||
|
++ (optional cfg.untrustedInput "--untrusted")
|
||||||
|
# Options
|
||||||
|
++ (optionals (cfg.reruns > 0) ["--reruns" "${toString cfg.reruns}"])
|
||||||
|
++ (generateOptionFlag "bundle")
|
||||||
|
++ (generateOptionFlag "webBundle")
|
||||||
|
++ (generateOptionFlag "outfmt")
|
||||||
|
++ (concatLists (map (x: ["--hide" x]) cfg.hidePaths))
|
||||||
|
++ (generateOptionFlag "format")
|
||||||
|
++ (generateOptionFlag "color")
|
||||||
|
# Still options but these are not defined by builder specific options but
|
||||||
|
# instead synchronize options between the global build options and builder
|
||||||
|
# specific options.
|
||||||
|
++ (optionals (!(elem texCfg.build.pdfDirectory ["." ""])) ["--outdir" "${texCfg.build.pdfDirectory}"])
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,66 +0,0 @@
|
||||||
# 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.
|
|
||||||
moduleInheritancePackage,
|
|
||||||
#
|
|
||||||
# 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 (moduleInheritancePackage) lib config;
|
|
||||||
#
|
|
||||||
# Inherit other useful functions.
|
|
||||||
inherit (lib.modules) mkIf;
|
|
||||||
#
|
|
||||||
# Set the cfg variable
|
|
||||||
cfg = config.vim.languages.tex;
|
|
||||||
in {
|
|
||||||
# These are the options for the builder. It will accept any options
|
|
||||||
# provided to it but some options are mandatory:
|
|
||||||
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:
|
|
||||||
opts)
|
|
||||||
options;
|
|
||||||
|
|
||||||
# Check that the language and this builder have been enabled
|
|
||||||
# before making any config.
|
|
||||||
config = mkIf (cfg.enable && cfg.build.builders.${name}.enable) {
|
|
||||||
vim.languages.tex.build.builder = {
|
|
||||||
inherit name;
|
|
||||||
package = cfg.build.builders.${name}.package;
|
|
||||||
executable = cfg.build.builders.${name}.executable;
|
|
||||||
args = args cfg.build.builders.${name};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -1,59 +1,57 @@
|
||||||
# TODO: I need testing.
|
# TODO: I need testing.
|
||||||
{
|
{
|
||||||
pkgs,
|
config,
|
||||||
lib,
|
lib,
|
||||||
|
pkgs,
|
||||||
...
|
...
|
||||||
} @ moduleInheritancePackage: let
|
}: let
|
||||||
# The name of the builder
|
# The name of the builder
|
||||||
name = "latexmk";
|
name = "latexmk";
|
||||||
|
|
||||||
# The builder template
|
inherit (lib.modules) mkIf;
|
||||||
template = import ./builderTemplate.nix;
|
inherit (lib.nvim.config) mkBool;
|
||||||
|
|
||||||
inherit (lib) optionals;
|
|
||||||
inherit (lib.options) mkOption mkEnableOption;
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
inherit (lib.types) bool package str;
|
inherit (lib.types) package str;
|
||||||
in (
|
|
||||||
template {
|
|
||||||
inherit name moduleInheritancePackage;
|
|
||||||
|
|
||||||
options = {
|
texCfg = config.vim.languages.tex;
|
||||||
enable = mkEnableOption "Tex Compilation Via latexmk";
|
cfg = texCfg.build.builders.${name};
|
||||||
|
in {
|
||||||
|
options.vim.languages.tex.build.builders.${name} = {
|
||||||
|
enable = mkEnableOption "Tex Compilation Via latexmk";
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = package;
|
type = package;
|
||||||
default = pkgs.texlive.withPackages (ps: [ps.latexmk]);
|
default = pkgs.texlive.withPackages (ps: [ps.latexmk]);
|
||||||
description = "latexmk package";
|
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.";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# Optional flags must come before the base args because of how the latexmk
|
executable = mkOption {
|
||||||
# command works
|
type = str;
|
||||||
args = builderCfg: (
|
default = "latexmk";
|
||||||
# Flags
|
description = ''
|
||||||
(optionals builderCfg.pdfOutput ["-pdf"])
|
The executable name from the build package that will be used to
|
||||||
# Base args
|
build/compile the tex.
|
||||||
++ [
|
'';
|
||||||
"-quiet"
|
};
|
||||||
"%f"
|
|
||||||
]
|
# Flag options
|
||||||
);
|
pdfOutput = mkBool true "Insure the output file is a pdf.";
|
||||||
}
|
};
|
||||||
)
|
|
||||||
|
config = mkIf (texCfg.enable && cfg.enable) {
|
||||||
|
vim.languages.tex.build.builder = {
|
||||||
|
inherit name;
|
||||||
|
inherit (cfg) package executable;
|
||||||
|
|
||||||
|
args = (
|
||||||
|
# Flags
|
||||||
|
(lib.lists.optional cfg.pdfOutput "-pdf")
|
||||||
|
# Base args
|
||||||
|
++ [
|
||||||
|
"-quiet"
|
||||||
|
"%f"
|
||||||
|
]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,229 +1,184 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
pkgs,
|
|
||||||
lib,
|
lib,
|
||||||
|
pkgs,
|
||||||
...
|
...
|
||||||
} @ moduleInheritancePackage: let
|
}: let
|
||||||
# The name of the builder
|
# The name of the builder
|
||||||
name = "tectonic";
|
name = "tectonic";
|
||||||
|
|
||||||
# The builder template
|
inherit (builtins) concatLists elem map toString match;
|
||||||
template = import ./builderTemplate.nix;
|
inherit (lib.modules) mkIf;
|
||||||
|
|
||||||
inherit (lib) optionals;
|
|
||||||
inherit (lib.options) mkOption mkEnableOption mkPackageOption;
|
|
||||||
inherit (lib.types) enum ints listOf str nullOr;
|
|
||||||
inherit (lib.nvim.config) mkBool;
|
inherit (lib.nvim.config) mkBool;
|
||||||
inherit (builtins) concatLists elem map toString attrNames filter isList;
|
inherit (lib.options) mkOption mkEnableOption mkPackageOption;
|
||||||
|
inherit (lib.strings) toLower optionalString stringAsChars;
|
||||||
|
inherit (lib.types) enum ints listOf str nullOr;
|
||||||
|
|
||||||
notNull = x: x != null;
|
texCfg = config.vim.languages.tex;
|
||||||
forceCheck = x: true;
|
cfg = texCfg.build.builders.${name};
|
||||||
toList = x:
|
in {
|
||||||
if isList x
|
options.vim.languages.tex.build.builders.${name} = {
|
||||||
then x
|
enable = mkEnableOption "Tex Compilation Via Tectonic";
|
||||||
else [x];
|
|
||||||
|
|
||||||
cfg = config.vim.languages.tex;
|
package = mkPackageOption pkgs "tectonic" {};
|
||||||
in (
|
|
||||||
template {
|
|
||||||
inherit name moduleInheritancePackage;
|
|
||||||
|
|
||||||
options = {
|
executable = mkOption {
|
||||||
enable = mkEnableOption "Tex Compilation Via Tectonic";
|
type = str;
|
||||||
|
default = "tectonic";
|
||||||
package = mkPackageOption pkgs "tectonic" {};
|
description = ''
|
||||||
|
The executable name from the build package that will be used to
|
||||||
executable = mkOption {
|
build/compile the tex.
|
||||||
type = str;
|
|
||||||
default = "tectonic";
|
|
||||||
description = ''
|
|
||||||
The executable name from the build package that will be used to
|
|
||||||
build/compile the tex.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
# -- Flags --
|
|
||||||
keepIntermediates = mkBool false ''
|
|
||||||
Whether to keep the intermediate files generated during processing.
|
|
||||||
|
|
||||||
If texlab is reporting build errors when there shouldn't be, disable
|
|
||||||
this option.
|
|
||||||
'';
|
'';
|
||||||
keepLogs = mkBool true ''
|
|
||||||
Whether to keep the log files generated during processing.
|
|
||||||
|
|
||||||
Without the keepLogs flag, texlab won't be able to report compilation
|
|
||||||
warnings.
|
|
||||||
'';
|
|
||||||
onlyCached = mkBool false ''
|
|
||||||
Whether to use only resource files cached locally
|
|
||||||
'';
|
|
||||||
synctex = mkBool true "Whether to generate SyncTeX data";
|
|
||||||
untrustedInput = mkBool false ''
|
|
||||||
Whether to disable all known-insecure features if the input is untrusted
|
|
||||||
'';
|
|
||||||
|
|
||||||
# -- Options --
|
|
||||||
reruns = mkOption {
|
|
||||||
type = ints.unsigned;
|
|
||||||
default = 0;
|
|
||||||
example = 2;
|
|
||||||
description = ''
|
|
||||||
How many times to *rerun* the TeX build engine.
|
|
||||||
The build engine (if a builder is enabled) will always run at least
|
|
||||||
once.
|
|
||||||
|
|
||||||
Setting this value to 0 will disable setting this option.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
bundle = mkOption {
|
|
||||||
type = nullOr str;
|
|
||||||
default = null;
|
|
||||||
description = ''
|
|
||||||
The directory or Zip-format bundle file to find resource files instead
|
|
||||||
of the default.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
webBundle = mkOption {
|
|
||||||
type = nullOr str;
|
|
||||||
default = null;
|
|
||||||
description = ''
|
|
||||||
Use this URL to find resource files instead of the default.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
outfmt = mkOption {
|
|
||||||
type = nullOr (enum [
|
|
||||||
"pdf"
|
|
||||||
"html"
|
|
||||||
"xdv"
|
|
||||||
"aux"
|
|
||||||
"fmt"
|
|
||||||
]);
|
|
||||||
default = null;
|
|
||||||
description = ''
|
|
||||||
The kind of output to generate.
|
|
||||||
|
|
||||||
Setting this to `null` (default) will let tectonic decide the most
|
|
||||||
appropriate output format, which usually be a pdf.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
hidePaths = mkOption {
|
|
||||||
type = listOf str;
|
|
||||||
default = [];
|
|
||||||
example = [
|
|
||||||
"./secrets.tex"
|
|
||||||
"./passwords.tex"
|
|
||||||
];
|
|
||||||
description = ''
|
|
||||||
Tell the engine that no file at `<path/to/hide>` exists, if it tries
|
|
||||||
to read it.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
format = mkOption {
|
|
||||||
type = nullOr str;
|
|
||||||
default = null;
|
|
||||||
description = ''
|
|
||||||
The name of the \"format\" file used to initialize the TeX engine.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
color = mkOption {
|
|
||||||
type = nullOr (enum [
|
|
||||||
"always"
|
|
||||||
"auto"
|
|
||||||
"never"
|
|
||||||
]);
|
|
||||||
default = null;
|
|
||||||
example = "always";
|
|
||||||
description = "Enable/disable colorful log output";
|
|
||||||
};
|
|
||||||
|
|
||||||
extraOptions = mkOption {
|
|
||||||
type = listOf str;
|
|
||||||
default = [];
|
|
||||||
description = ''
|
|
||||||
Add extra command line options to include in the tectonic build
|
|
||||||
command.
|
|
||||||
Extra options added here will not overwrite the options set in as nvf
|
|
||||||
options.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# args = builderCfg: (
|
# -- Flags --
|
||||||
# # Base args
|
keepIntermediates = mkBool false ''
|
||||||
# [
|
Whether to keep the intermediate files generated during processing.
|
||||||
# "-X"
|
|
||||||
# "compile"
|
|
||||||
# "%f"
|
|
||||||
# ]
|
|
||||||
# # Flags
|
|
||||||
# ++ (optionals builderCfg.keepIntermediates ["--keep-intermediates"])
|
|
||||||
# ++ (optionals builderCfg.keepLogs ["--keep-logs"])
|
|
||||||
# ++ (optionals builderCfg.onlyCached ["--only-cached"])
|
|
||||||
# ++ (optionals builderCfg.synctex ["--synctex"])
|
|
||||||
# ++ (optionals builderCfg.untrustedInput ["--untrusted"])
|
|
||||||
# # Options
|
|
||||||
# ++ (optionals (builderCfg.reruns > 0) ["--reruns" "${toString builderCfg.reruns}"])
|
|
||||||
# ++ (optionals (builderCfg.bundle != null) ["--bundle" "${toString builderCfg.bundle}"])
|
|
||||||
# ++ (optionals (builderCfg.webBundle != null) ["--web-bundle" "${toString builderCfg.webBundle}"])
|
|
||||||
# ++ (optionals (builderCfg.outfmt != null) ["--outfmt" "${toString builderCfg.outfmt}"])
|
|
||||||
# ++ (concatLists (map (x: ["--hide" x]) builderCfg.hidePaths))
|
|
||||||
# ++ (optionals (builderCfg.format != null) ["--format" "${toString builderCfg.format}"])
|
|
||||||
# ++ (optionals (builderCfg.color != null) ["--color" "${toString builderCfg.color}"])
|
|
||||||
# # Still options but these are not defined by builder specific options but
|
|
||||||
# # instead synchronize options between the global build options and builder
|
|
||||||
# # specific options
|
|
||||||
# ++ (optionals (!(elem cfg.build.pdfDirectory ["." ""])) ["--outdir" "${cfg.build.pdfDirectory}"])
|
|
||||||
# );
|
|
||||||
|
|
||||||
args = builderCfg: let
|
If texlab is reporting build errors when there shouldn't be, disable
|
||||||
option = setCheck: flag: {inherit setCheck flag;};
|
this option.
|
||||||
args = {
|
'';
|
||||||
baseArgs = ["-X" "compile" "%f"];
|
keepLogs = mkBool true ''
|
||||||
|
Whether to keep the log files generated during processing.
|
||||||
|
|
||||||
flags = {
|
Without the keepLogs flag, texlab won't be able to report compilation
|
||||||
keepIntermediates = "--keep-intermediates";
|
warnings.
|
||||||
keepLogs = "--keep-logs";
|
'';
|
||||||
onlyCached = "--only-cached";
|
onlyCached = mkBool false ''
|
||||||
synctex = "--synctex";
|
Whether to use only resource files cached locally
|
||||||
untrustedInput = "--untrusted";
|
'';
|
||||||
};
|
synctex = mkBool true "Whether to generate SyncTeX data";
|
||||||
|
untrustedInput = mkBool false ''
|
||||||
|
Whether to disable all known-insecure features if the input is untrusted
|
||||||
|
'';
|
||||||
|
|
||||||
options = {
|
# -- Options --
|
||||||
reruns = option (x: x > 0) "--reruns";
|
reruns = mkOption {
|
||||||
bundle = option notNull "--bundle";
|
type = ints.unsigned;
|
||||||
webBundle = option notNull "--web-bundle";
|
default = 0;
|
||||||
outfmt = option notNull "--outfmt";
|
example = 2;
|
||||||
format = option notNull "--format";
|
description = ''
|
||||||
color = option notNull "--color";
|
How many times to *rerun* the TeX build engine.
|
||||||
hidePaths = option forceCheck "--hide";
|
The build engine (if a builder is enabled) will always run at least
|
||||||
};
|
once.
|
||||||
|
|
||||||
externalOptions = concatLists [
|
Setting this value to 0 will disable setting this option.
|
||||||
(optionals (!(elem cfg.build.pdfDirectory ["." ""])) ["--outdir" "${cfg.build.pdfDirectory}"])
|
'';
|
||||||
];
|
};
|
||||||
};
|
|
||||||
|
|
||||||
flags = map (flag: args.flags.${flag}) (filter (flag: builderCfg.${flag}) (attrNames args.flags));
|
bundle = mkOption {
|
||||||
options = let
|
type = nullOr str;
|
||||||
getOptionFlagsList = opt:
|
default = null;
|
||||||
concatLists (
|
description = ''
|
||||||
map
|
The directory or Zip-format bundle file to find resource files instead
|
||||||
(y: [args.options."${opt}".flag "${toString y}"])
|
of the default.
|
||||||
(toList builderCfg."${opt}")
|
'';
|
||||||
);
|
};
|
||||||
processOption = opt:
|
|
||||||
optionals
|
webBundle = mkOption {
|
||||||
(args.options."${opt}".setCheck builderCfg."${opt}")
|
type = nullOr str;
|
||||||
(getOptionFlagsList opt);
|
default = null;
|
||||||
in (concatLists (map processOption (attrNames args.options)));
|
description = ''
|
||||||
in
|
Use this URL to find resource files instead of the default.
|
||||||
concatLists (with args; [baseArgs flags options externalOptions]);
|
'';
|
||||||
}
|
};
|
||||||
)
|
|
||||||
|
outfmt = mkOption {
|
||||||
|
type = nullOr (enum [
|
||||||
|
"pdf"
|
||||||
|
"html"
|
||||||
|
"xdv"
|
||||||
|
"aux"
|
||||||
|
"fmt"
|
||||||
|
]);
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
The kind of output to generate.
|
||||||
|
|
||||||
|
Setting this to `null` (default) will let tectonic decide the most
|
||||||
|
appropriate output format, which usually be a pdf.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
hidePaths = mkOption {
|
||||||
|
type = listOf str;
|
||||||
|
default = [];
|
||||||
|
example = [
|
||||||
|
"./secrets.tex"
|
||||||
|
"./passwords.tex"
|
||||||
|
];
|
||||||
|
description = ''
|
||||||
|
Tell the engine that no file at `<path/to/hide>` exists, if it tries
|
||||||
|
to read it.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
format = mkOption {
|
||||||
|
type = nullOr str;
|
||||||
|
default = null;
|
||||||
|
description = ''
|
||||||
|
The name of the \"format\" file used to initialize the TeX engine.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
color = mkOption {
|
||||||
|
type = nullOr (enum [
|
||||||
|
"always"
|
||||||
|
"auto"
|
||||||
|
"never"
|
||||||
|
]);
|
||||||
|
default = null;
|
||||||
|
example = "always";
|
||||||
|
description = "Enable/disable colorful log output";
|
||||||
|
};
|
||||||
|
|
||||||
|
extraOptions = mkOption {
|
||||||
|
type = listOf str;
|
||||||
|
default = [];
|
||||||
|
description = ''
|
||||||
|
Add extra command line options to include in the tectonic build
|
||||||
|
command.
|
||||||
|
Extra options added here will not overwrite the options set in as nvf
|
||||||
|
options.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf (texCfg.enable && cfg.enable) {
|
||||||
|
vim.languages.tex.build.builder = {
|
||||||
|
inherit name;
|
||||||
|
inherit (cfg) package executable;
|
||||||
|
|
||||||
|
args = let
|
||||||
|
inherit (lib.lists) optional optionals;
|
||||||
|
snakeCaseToKebabCase = str: stringAsChars (x: "${optionalString ((match "[A-Z]" x) != null) "-"}${toLower x}") str;
|
||||||
|
generateOptionFlag = option: (optionals (cfg.${option} != "" && cfg.${option} != null) ["--${snakeCaseToKebabCase option}" "${toString cfg.${option}}"]);
|
||||||
|
in (
|
||||||
|
# Base args
|
||||||
|
[
|
||||||
|
"-X"
|
||||||
|
"compile"
|
||||||
|
"%f"
|
||||||
|
]
|
||||||
|
# Flags
|
||||||
|
++ (optional cfg.keepIntermediates "--keep-intermediates")
|
||||||
|
++ (optional cfg.keepLogs "--keep-logs")
|
||||||
|
++ (optional cfg.onlyCached "--only-cached")
|
||||||
|
++ (optional cfg.synctex "--synctex")
|
||||||
|
++ (optional cfg.untrustedInput "--untrusted")
|
||||||
|
# Options
|
||||||
|
++ (optionals (cfg.reruns > 0) ["--reruns" "${toString cfg.reruns}"])
|
||||||
|
++ (generateOptionFlag "bundle")
|
||||||
|
++ (generateOptionFlag "webBundle")
|
||||||
|
++ (generateOptionFlag "outfmt")
|
||||||
|
++ (concatLists (map (x: ["--hide" x]) cfg.hidePaths))
|
||||||
|
++ (generateOptionFlag "format")
|
||||||
|
++ (generateOptionFlag "color")
|
||||||
|
# Still options but these are not defined by builder specific options but
|
||||||
|
# instead synchronize options between the global build options and builder
|
||||||
|
# specific options.
|
||||||
|
++ (optionals (!(elem texCfg.build.pdfDirectory ["." ""])) ["--outdir" "${texCfg.build.pdfDirectory}"])
|
||||||
|
);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue