{ 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"; text = config.helix.languages; path = tomlFormatter.generate "languages.toml" helix.languages.text; }; 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} ''; }; } ); }