1
0
Fork 0
nix-homemanager-laptop/base/helix/default.nix
2025-07-14 00:15:54 -05:00

78 lines
2.4 KiB
Nix

{ flake-parts-lib, lib, ... }:
let
inherit (lib) mkOption types;
in
{
imports = [ ../base ];
options.perSystem = flake-parts-lib.mkPerSystemOption (
{ config, pkgs, ... }:
{
options.helix = {
# https://github.com/helix-editor/helix/blob/master/languages.toml
# https://helix-editor.vercel.app/reference/formatters
# https://docs.helix-editor.com/lang-support.html
languages = mkOption {
description = ''
Configuration for Helix `languages.toml`.
'';
# type = types.attrs;
type = types.submodule {
options = {
language = mkOption {
description = ''
`language` in `languages.toml`.
'';
type = types.listOf types.attrs;
default = [ ];
};
language-server = mkOption {
description = ''
`language-server` in `languages.toml`.
'';
type = types.attrs;
default = { };
};
};
};
default = { };
};
};
config.devshells.default =
let
tomlFormatter = pkgs.formats.toml { };
helix = {
languages = {
name = "languages.toml";
content = config.helix.languages;
path = tomlFormatter.generate "languages.toml" helix.languages.content;
};
directory = {
name = ".helix";
path = pkgs.linkFarm helix.directory.name [
{
name = helix.languages.name;
path = helix.languages.path;
}
];
};
};
in
{
commands = [
{
help = " generate Helix grammars";
name = "helix-grammars";
command = "${pkgs.helix}/bin/hx --grammar fetch && hx --grammar build";
category = "󰤀 Helix";
}
];
packages = [ pkgs.helix ];
devshell.startup.helix_config.text = ''
mkdir -p .helix
${pkgs.uutils-coreutils-noprefix}/bin/rm -rf ./${helix.directory.name}
${pkgs.uutils-coreutils-noprefix}/bin/ln -fsn ${helix.directory.path} ./${helix.directory.name}
'';
};
}
);
}