mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-01-16 07:27:47 +00:00
Compare commits
No commits in common. "aef828406ddd020481e8f52be7ac7900c43ffe76" and "1d28982b43a6f965e3d3ec190b0625ef19251102" have entirely different histories.
aef828406d
...
1d28982b43
6 changed files with 210 additions and 579 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.
|
|
||||||
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 {
|
|
||||||
# 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};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
@ -6,8 +6,7 @@
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.options) mkOption;
|
inherit (lib.options) mkOption;
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.types) bool listOf package str;
|
inherit (lib.types) bool listOf package str ;
|
||||||
inherit (lib) mkDefault;
|
|
||||||
|
|
||||||
cfg = config.vim.languages.tex;
|
cfg = config.vim.languages.tex;
|
||||||
|
|
||||||
|
|
@ -57,10 +56,10 @@ in {
|
||||||
|
|
||||||
config = mkIf (cfg.enable && cfg.build.builders.custom.enable) {
|
config = mkIf (cfg.enable && cfg.build.builders.custom.enable) {
|
||||||
vim.languages.tex.build.builder = {
|
vim.languages.tex.build.builder = {
|
||||||
name = mkDefault "custom";
|
name = "custom";
|
||||||
args = mkDefault (collateArgs cfg.build);
|
args = collateArgs cfg.build;
|
||||||
package = mkDefault (cfg.build.builders.custom.package);
|
package = cfg.build.builders.custom.package;
|
||||||
executable = mkDefault (cfg.build.builders.custom.executable);
|
executable = cfg.build.builders.custom.executable;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
pkgs,
|
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
@ -13,57 +12,30 @@ let
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./latexmk.nix
|
./custom.nix
|
||||||
./tectonic.nix
|
./tectonic.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
options.vim.languages.tex.build.builder = {
|
options.vim.languages.tex.build.builder = {
|
||||||
name = mkOption {
|
name = mkOption {
|
||||||
type = enum (attrNames cfg.build.builders);
|
type = enum (attrNames cfg.build.builders);
|
||||||
default = "latexmk";
|
default = "tectonic";
|
||||||
description = ''
|
description = "The tex builder to use";
|
||||||
The tex builder to use.
|
|
||||||
|
|
||||||
This is just the default custom option. By setting any of the
|
|
||||||
builders to true, this will be overwritten by that builder's
|
|
||||||
parameters.
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
args = mkOption {
|
args = mkOption {
|
||||||
type = listOf str;
|
type = listOf str;
|
||||||
default = [
|
default = [];
|
||||||
"-pdf"
|
description = "The list of args to pass to the builder";
|
||||||
"%f"
|
|
||||||
];
|
|
||||||
description = ''
|
|
||||||
The list of args to pass to the builder.
|
|
||||||
|
|
||||||
This is just the default custom option. By setting any of the
|
|
||||||
builders to true, this will be overwritten by that builder's
|
|
||||||
parameters.
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = package;
|
type = package;
|
||||||
default = (pkgs.texlive.withPackages (ps: [ ps.latexmk ]));
|
default = cfg.build.builders.tectonic.package;
|
||||||
description = ''
|
description = "The tex builder package to use";
|
||||||
The tex builder package to use.
|
|
||||||
|
|
||||||
This is just the default custom option. By setting any of the
|
|
||||||
builders to true, this will be overwritten by that builder's
|
|
||||||
parameters.
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
executable = mkOption {
|
executable = mkOption {
|
||||||
type = str;
|
type = str;
|
||||||
default = "latexmk";
|
default = cfg.build.builders.tectonic.executable;
|
||||||
description = ''
|
description = "The tex builder executable to use";
|
||||||
The tex builder executable to use.
|
|
||||||
|
|
||||||
This is just the default custom option. By setting any of the
|
|
||||||
builders to true, this will be overwritten by that builder's
|
|
||||||
parameters.
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,68 +0,0 @@
|
||||||
# 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"
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
@ -3,15 +3,18 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
} @ moduleInheritencePackage: let
|
}: let
|
||||||
# The name of the builder
|
|
||||||
name = "tectonic";
|
|
||||||
|
|
||||||
# The builder template
|
|
||||||
template = import ./builderTemplate.nix;
|
|
||||||
|
|
||||||
inherit (lib.options) mkOption mkEnableOption;
|
inherit (lib.options) mkOption mkEnableOption;
|
||||||
inherit (lib.types) bool enum ints listOf package str;
|
inherit (lib.modules) mkIf;
|
||||||
|
inherit
|
||||||
|
(lib.types)
|
||||||
|
bool
|
||||||
|
enum
|
||||||
|
ints
|
||||||
|
listOf
|
||||||
|
package
|
||||||
|
str
|
||||||
|
;
|
||||||
inherit (builtins) concatLists elem map toString;
|
inherit (builtins) concatLists elem map toString;
|
||||||
|
|
||||||
cfg = config.vim.languages.tex;
|
cfg = config.vim.languages.tex;
|
||||||
|
|
@ -23,184 +26,192 @@
|
||||||
example = !default;
|
example = !default;
|
||||||
description = description;
|
description = description;
|
||||||
});
|
});
|
||||||
in (
|
|
||||||
template {
|
|
||||||
inherit name moduleInheritencePackage;
|
|
||||||
|
|
||||||
options = {
|
# --- Arg Collation Functions --
|
||||||
enable = mkEnableOption "Whether to enable Tex Compilation Via Tectonic";
|
collateArgs = buildConfig: let
|
||||||
|
selfConfig = buildConfig.builders.tectonic;
|
||||||
|
in (
|
||||||
|
# Base args
|
||||||
|
[
|
||||||
|
"-X"
|
||||||
|
"compile"
|
||||||
|
"%f"
|
||||||
|
]
|
||||||
|
# Flags
|
||||||
|
++ (
|
||||||
|
if selfConfig.keepIntermediates
|
||||||
|
then ["--keep-intermediates"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
++ (
|
||||||
|
if selfConfig.keepLogs
|
||||||
|
then ["--keep-logs"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
++ (
|
||||||
|
if selfConfig.onlyCached
|
||||||
|
then ["--only-cached"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
++ (
|
||||||
|
if selfConfig.synctex
|
||||||
|
then ["--synctex"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
++ (
|
||||||
|
if selfConfig.untrustedInput
|
||||||
|
then ["--untrusted"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
# Options
|
||||||
|
++ (
|
||||||
|
if selfConfig.reruns > 0
|
||||||
|
then ["--reruns" "${toString selfConfig.reruns}"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
++ (
|
||||||
|
if selfConfig.bundle != ""
|
||||||
|
then ["--bundle" "${toString selfConfig.bundle}"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
++ (
|
||||||
|
if selfConfig.webBundle != ""
|
||||||
|
then ["--web-bundle" "${toString selfConfig.webBundle}"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
++ (
|
||||||
|
if selfConfig.outfmt != ""
|
||||||
|
then ["--outfmt" "${toString selfConfig.outfmt}"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
++ (concatLists (map (x: ["--hide" x]) selfConfig.hidePaths))
|
||||||
|
++ (
|
||||||
|
if selfConfig.format != ""
|
||||||
|
then ["--format" "${toString selfConfig.format}"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
++ (
|
||||||
|
if selfConfig.color != ""
|
||||||
|
then ["--color" "${toString selfConfig.color}"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
# Still options but these are not defined by builder specific options but
|
||||||
|
# instead synchronize options between the global build options and builder
|
||||||
|
# specific options
|
||||||
|
++ (
|
||||||
|
if !(elem buildConfig.pdfDirectory ["." ""])
|
||||||
|
then ["--outdir" "${buildConfig.pdfDirectory}"]
|
||||||
|
else []
|
||||||
|
)
|
||||||
|
);
|
||||||
|
in {
|
||||||
|
options.vim.languages.tex.build.builders.tectonic = {
|
||||||
|
enable = mkEnableOption "Whether to enable Tex Compilation Via Tectonic";
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = package;
|
type = package;
|
||||||
default = pkgs.tectonic;
|
default = pkgs.tectonic;
|
||||||
description = "tectonic package";
|
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 = mkEnableDefaultOption false ''
|
|
||||||
Keep the intermediate files generated during processing.
|
|
||||||
|
|
||||||
If texlab is reporting build errors when there shouldn't be, disable this option.
|
|
||||||
'';
|
|
||||||
keepLogs = mkEnableDefaultOption true ''
|
|
||||||
Keep the log files generated during processing.
|
|
||||||
|
|
||||||
Without the keepLogs flag, texlab won't be able to report compilation warnings.
|
|
||||||
'';
|
|
||||||
onlyCached = mkEnableDefaultOption false "Use only resource files cached locally";
|
|
||||||
synctex = mkEnableDefaultOption true "Generate SyncTeX data";
|
|
||||||
untrustedInput = mkEnableDefaultOption 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";
|
|
||||||
};
|
|
||||||
|
|
||||||
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 = mkEnableDefaultOption 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 = mkEnableDefaultOption 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 = mkEnableDefaultOption false "Use only resource files cached locally";
|
||||||
++ (
|
synctex = mkEnableDefaultOption true "Generate SyncTeX data";
|
||||||
if builderCfg.onlyCached
|
untrustedInput = mkEnableDefaultOption 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
|
bundle = mkOption {
|
||||||
then ["--untrusted"]
|
type = str;
|
||||||
else []
|
default = "";
|
||||||
)
|
description = "Use this directory or Zip-format bundle file to find resource files instead of the default";
|
||||||
# Options
|
};
|
||||||
++ (
|
|
||||||
if builderCfg.reruns > 0
|
webBundle = mkOption {
|
||||||
then ["--reruns" "${toString builderCfg.reruns}"]
|
type = str;
|
||||||
else []
|
default = "";
|
||||||
)
|
description = "Use this URL to find resource files instead of the default";
|
||||||
++ (
|
};
|
||||||
if builderCfg.bundle != ""
|
|
||||||
then ["--bundle" "${toString builderCfg.bundle}"]
|
outfmt = mkOption {
|
||||||
else []
|
type = enum [
|
||||||
)
|
"pdf"
|
||||||
++ (
|
"html"
|
||||||
if builderCfg.webBundle != ""
|
"xdv"
|
||||||
then ["--web-bundle" "${toString builderCfg.webBundle}"]
|
"aux"
|
||||||
else []
|
"fmt"
|
||||||
)
|
""
|
||||||
++ (
|
];
|
||||||
if builderCfg.outfmt != ""
|
default = "";
|
||||||
then ["--outfmt" "${toString builderCfg.outfmt}"]
|
description = "The kind of output to generate";
|
||||||
else []
|
};
|
||||||
)
|
|
||||||
++ (concatLists (map (x: ["--hide" x]) builderCfg.hidePaths))
|
hidePaths = mkOption {
|
||||||
++ (
|
type = listOf str;
|
||||||
if builderCfg.format != ""
|
default = [];
|
||||||
then ["--format" "${toString builderCfg.format}"]
|
example = [
|
||||||
else []
|
"./secrets.tex"
|
||||||
)
|
"./passwords.tex"
|
||||||
++ (
|
];
|
||||||
if builderCfg.color != ""
|
description = "Tell the engine that no file at <hide_path> exists, if it tries to read it.";
|
||||||
then ["--color" "${toString builderCfg.color}"]
|
};
|
||||||
else []
|
|
||||||
)
|
format = mkOption {
|
||||||
# Still options but these are not defined by builder specific options but
|
type = str;
|
||||||
# instead synchronize options between the global build options and builder
|
default = "";
|
||||||
# specific options
|
description = "The name of the \"format\" file used to initialize the TeX engine";
|
||||||
++ (
|
};
|
||||||
if !(elem cfg.build.pdfDirectory ["." ""])
|
|
||||||
then ["--outdir" "${cfg.build.pdfDirectory}"]
|
color = mkOption {
|
||||||
else []
|
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 (cfg.enable && cfg.build.builders.tectonic.enable) {
|
||||||
|
vim.languages.tex.build.builder = {
|
||||||
|
name = "tectonic";
|
||||||
|
args = collateArgs cfg.build;
|
||||||
|
package = cfg.build.builders.tectonic.package;
|
||||||
|
executable = cfg.build.builders.tectonic.executable;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,217 +0,0 @@
|
||||||
{
|
|
||||||
config,
|
|
||||||
pkgs,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
inherit (lib.options) mkOption mkEnableOption;
|
|
||||||
inherit (lib.modules) mkIf;
|
|
||||||
inherit
|
|
||||||
(lib.types)
|
|
||||||
bool
|
|
||||||
enum
|
|
||||||
ints
|
|
||||||
listOf
|
|
||||||
package
|
|
||||||
str
|
|
||||||
;
|
|
||||||
inherit (builtins) concatLists elem map toString;
|
|
||||||
|
|
||||||
cfg = config.vim.languages.tex;
|
|
||||||
|
|
||||||
# --- Enable Options ---
|
|
||||||
mkEnableDefaultOption = default: description: (mkOption {
|
|
||||||
type = bool;
|
|
||||||
default = default;
|
|
||||||
example = !default;
|
|
||||||
description = description;
|
|
||||||
});
|
|
||||||
|
|
||||||
# --- Arg Collation Functions --
|
|
||||||
collateArgs = buildConfig: let
|
|
||||||
selfConfig = buildConfig.builders.tectonic;
|
|
||||||
in (
|
|
||||||
# Base args
|
|
||||||
[
|
|
||||||
"-X"
|
|
||||||
"compile"
|
|
||||||
"%f"
|
|
||||||
]
|
|
||||||
# Flags
|
|
||||||
++ (
|
|
||||||
if selfConfig.keepIntermediates
|
|
||||||
then ["--keep-intermediates"]
|
|
||||||
else []
|
|
||||||
)
|
|
||||||
++ (
|
|
||||||
if selfConfig.keepLogs
|
|
||||||
then ["--keep-logs"]
|
|
||||||
else []
|
|
||||||
)
|
|
||||||
++ (
|
|
||||||
if selfConfig.onlyCached
|
|
||||||
then ["--only-cached"]
|
|
||||||
else []
|
|
||||||
)
|
|
||||||
++ (
|
|
||||||
if selfConfig.synctex
|
|
||||||
then ["--synctex"]
|
|
||||||
else []
|
|
||||||
)
|
|
||||||
++ (
|
|
||||||
if selfConfig.untrustedInput
|
|
||||||
then ["--untrusted"]
|
|
||||||
else []
|
|
||||||
)
|
|
||||||
# Options
|
|
||||||
++ (
|
|
||||||
if selfConfig.reruns > 0
|
|
||||||
then ["--reruns" "${toString selfConfig.reruns}"]
|
|
||||||
else []
|
|
||||||
)
|
|
||||||
++ (
|
|
||||||
if selfConfig.bundle != ""
|
|
||||||
then ["--bundle" "${toString selfConfig.bundle}"]
|
|
||||||
else []
|
|
||||||
)
|
|
||||||
++ (
|
|
||||||
if selfConfig.webBundle != ""
|
|
||||||
then ["--web-bundle" "${toString selfConfig.webBundle}"]
|
|
||||||
else []
|
|
||||||
)
|
|
||||||
++ (
|
|
||||||
if selfConfig.outfmt != ""
|
|
||||||
then ["--outfmt" "${toString selfConfig.outfmt}"]
|
|
||||||
else []
|
|
||||||
)
|
|
||||||
++ (concatLists (map (x: ["--hide" x]) selfConfig.hidePaths))
|
|
||||||
++ (
|
|
||||||
if selfConfig.format != ""
|
|
||||||
then ["--format" "${toString selfConfig.format}"]
|
|
||||||
else []
|
|
||||||
)
|
|
||||||
++ (
|
|
||||||
if selfConfig.color != ""
|
|
||||||
then ["--color" "${toString selfConfig.color}"]
|
|
||||||
else []
|
|
||||||
)
|
|
||||||
# Still options but these are not defined by builder specific options but
|
|
||||||
# instead synchronize options between the global build options and builder
|
|
||||||
# specific options
|
|
||||||
++ (
|
|
||||||
if !(elem buildConfig.pdfDirectory ["." ""])
|
|
||||||
then ["--outdir" "${buildConfig.pdfDirectory}"]
|
|
||||||
else []
|
|
||||||
)
|
|
||||||
);
|
|
||||||
in {
|
|
||||||
options.vim.languages.tex.build.builders.tectonic = {
|
|
||||||
enable = mkEnableOption "Whether to enable Tex Compilation Via Tectonic";
|
|
||||||
|
|
||||||
package = mkOption {
|
|
||||||
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 = mkEnableDefaultOption false ''
|
|
||||||
Keep the intermediate files generated during processing.
|
|
||||||
|
|
||||||
If texlab is reporting build errors when there shouldn't be, disable this option.
|
|
||||||
'';
|
|
||||||
keepLogs = mkEnableDefaultOption true ''
|
|
||||||
Keep the log files generated during processing.
|
|
||||||
|
|
||||||
Without the keepLogs flag, texlab won't be able to report compilation warnings.
|
|
||||||
'';
|
|
||||||
onlyCached = mkEnableDefaultOption false "Use only resource files cached locally";
|
|
||||||
synctex = mkEnableDefaultOption true "Generate SyncTeX data";
|
|
||||||
untrustedInput = mkEnableDefaultOption 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";
|
|
||||||
};
|
|
||||||
|
|
||||||
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.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config = mkIf (cfg.enable && cfg.build.builders.tectonic.enable) {
|
|
||||||
vim.languages.tex.build.builder = {
|
|
||||||
name = "tectonic";
|
|
||||||
args = collateArgs cfg.build;
|
|
||||||
package = cfg.build.builders.tectonic.package;
|
|
||||||
executable = cfg.build.builders.tectonic.executable;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue