Nix API
lib.fromNickelFile
Converts a JSON-able Nickel file into a Nix value.
Type
fromNickelFile : File -> Any
lib.toJSONFile
Transforms a JSON-able Nix value into a JSON file. This file can be consumed by Nickel directly.
Type
toJSONFile : Any -> File
lib.prefetchLanguages
Given a Topiary configuration as a Nix value, returns the same
configuration, except all language sources have been replaced by a
prefetched and precompiled one. This requires the presence of a nixHash
for all sources.
Type
prefetchLanguages : TopiaryConfig -> TopiaryConfig
lib.prefetchLanguagesFile
Same as prefetchLanguages, but expects a path to a Nickel file, and
produces a path to a JSON file, which can be consumed by Nickel.
Type
prefetchLanguagesFile : File -> File
lib.defaultConfig
The default configuration of Topiary -- that is the content of
topiary-config/languages.ncl -- but as a Nix value.
Type
defaultConfig : TopiaryConfig
lib.defaultConfigPrefetched
Same as defaultConfig, but where all the language grammars point to the
Nix store path of a prefetched and precompiled version of the grammar. This
is prefetchLanguages defaultConfig.
Type
defaultConfigPrefetched
lib.defaultConfigFile
Same as defaultConfig but as a Nickel File.
Type
defaultConfigFile : File
lib.defaultConfigFilePrefetched
Same as defaultConfigPrefetched but as a JSON file, consumable by Nickel.
Type
defaultConfigFilePrefetched : File
lib.wrapWithConfig
Given a derivation providing /bin/topiary and a Topiary configuration
<config>, produce an executable running topiary -C <config>.
Note that this is different from building Topiary with a different default
configuration: the resulting binary will not accept an additional -C
argument.
Type
wrapWithConfig : Derivation -> TopiaryConfig -> Derivation
lib.wrapWithConfigFile
Same as wrapWithConfig but with the configuration as a Nickel file.
Type
wrapWithConfigFile : Derivation -> File -> Derivation
lib.gitHookFor
A Git hook compatible with https://github.com/cachix/git-hooks.nix, and that
runs topiary format on the staged files.
Type
gitHookFor : AttrSet -> AttrSet
Arguments
package
: A derivation providing topiary-cli. Defaults to the one shipped with
this library.
config
: The Topiary configuration to use; defaults to a prefetched version of
topiary-config/languages.ncl shipped with this library.
includeLanguages
: A list of languages to include from the configuration. The hook will not
process the others. All the languages in this list must be present in
config.languages. Defaults to null, which represents all the languages
of the configuration.
excludeLanguages
: A list of languages to exclude from the hook. One cannot use both
includeLanguages and excludeLanguages. All the languages in this list
must be present in config.languages. Defaults to [].
lib.gitHookBinFor
This function exposes the derivation providing /bin/topiary in gitHookFor.
It is meant for clients wanting to get a Git hook but also acquire the same
Topiary, for instance to expose it in their environment. See gitHookFor for a
description of the arguments.
Type
gitHookBinFor : AttrSet -> Derivation
lib.gitHook
gitHook : AttrSet
Same as gitHookFor {}.
lib.gitHookBin
gitHookBin : Derivation
Same as gitHookBinFor {}.