98 lines
2.9 KiB
Nix
98 lines
2.9 KiB
Nix
# SPDX-FileCopyrightText: 2025 Ethan Reece <contact@ethanreece.com>
|
|
#
|
|
# SPDX-License-Identifier: LGPL-3.0-or-later
|
|
|
|
{ flake-parts-lib, lib, ... }:
|
|
{
|
|
imports = [ ../en-us ];
|
|
options.perSystem = flake-parts-lib.mkPerSystemOption (
|
|
{
|
|
config,
|
|
nixGLPkgs,
|
|
pkgs,
|
|
...
|
|
}:
|
|
{
|
|
options.languages.typst = {
|
|
enable = lib.mkEnableOption "Typst";
|
|
entrypoint = lib.mkOption {
|
|
description = ''
|
|
Entrypoint file for Typst. Default file for `typst-edit`.
|
|
'';
|
|
type = lib.types.string;
|
|
default = "main.typ";
|
|
};
|
|
fonts = lib.mkOption {
|
|
description = ''
|
|
Fonts for Typst.
|
|
'';
|
|
type = lib.types.listOf lib.types.package;
|
|
default = [ ];
|
|
};
|
|
};
|
|
config = lib.mkIf config.languages.typst.enable (
|
|
let
|
|
tinymistURL = "127.0.0.1:23635";
|
|
fonts = pkgs.buildEnv {
|
|
name = "fonts";
|
|
paths = config.languages.typst.fonts;
|
|
};
|
|
in
|
|
{
|
|
languages.en-us.dictionary = [
|
|
"typ"
|
|
"Typst"
|
|
];
|
|
editors.helix.languages = {
|
|
language = [
|
|
{
|
|
name = "typst";
|
|
language-servers =
|
|
[ "tinymist" ]
|
|
++ (lib.optionals config.languages.en-us.enable [
|
|
"harper-ls"
|
|
"typos"
|
|
]);
|
|
formatter = {
|
|
command = "${config.treefmt.build.wrapper}/bin/treefmt";
|
|
args = [
|
|
"--stdin"
|
|
"%{buffer_name}"
|
|
"--quiet"
|
|
];
|
|
};
|
|
auto-format = true;
|
|
}
|
|
];
|
|
language-server.tinymist = {
|
|
command = "${pkgs.tinymist}/bin/tinymist";
|
|
config = {
|
|
preview.background = {
|
|
enabled = true;
|
|
args = [
|
|
"--data-plane-host=${tinymistURL}"
|
|
"--invert-colors=never"
|
|
];
|
|
};
|
|
typstExtraArgs = [
|
|
"--ignore-system-fonts"
|
|
"--font-path"
|
|
"${fonts}/share/fonts"
|
|
];
|
|
};
|
|
};
|
|
};
|
|
treefmt.programs.typstyle.enable = true;
|
|
devshells.default.commands = lib.mkIf config.editors.helix.enable [
|
|
{
|
|
help = " launch Typst editing environment";
|
|
name = "typst-edit";
|
|
category = " Typst";
|
|
command = "${nixGLPkgs.nixgl.nixGLMesa}/bin/nixGLMesa ${pkgs.qutebrowser}/bin/qutebrowser ${tinymistURL} & ${pkgs.helix}/bin/hx ${config.languages.typst.entrypoint}; kill $!";
|
|
}
|
|
];
|
|
}
|
|
);
|
|
}
|
|
);
|
|
}
|