diff --git a/flake.nix b/flake.nix index 70ff6ca..1d5d319 100644 --- a/flake.nix +++ b/flake.nix @@ -84,7 +84,7 @@ outputs = inputs@{ flake-parts, ... }: flake-parts.lib.mkFlake { inherit inputs; } ( - { withSystem, ... }: + { config, withSystem, ... }: { systems = [ "aarch64-linux" @@ -100,6 +100,35 @@ ./nix-on-droid/flake-module.nix ./nixos/flake-module.nix ]; + dictionary = [ + "ASLR" + "Boycat" + "DLR" + "Floorp" + "gpg" + "Guix" + "Haseeb" + "iterm" + "JMAP" + "Jujutsu" + "lajp" + "LanguageTool" + "LicenseRef" + "LLMs" + "LTeX" + "Majid" + "MatthewCroughan" + "MWMBL" + "Niri" + "Nix" + "Reece" + "TODO" + "TrackMeNot" + "twiter" + "UTD" + "Vivado" + "Xilinx" + ]; profiles = let name = "Ethan Reece"; @@ -206,34 +235,7 @@ languages = { en-us = { enable = true; - dictionary = [ - "ASLR" - "Boycat" - "DLR" - "Floorp" - "Guix" - "Haseeb" - "iterm" - "JMAP" - "Jujutsu" - "lajp" - "LanguageTool" - "LicenseRef" - "LLMs" - "LTeX" - "Majid" - "MatthewCroughan" - "MWMBL" - "Niri" - "Nix" - "Reece" - "TODO" - "TrackMeNot" - "twiter" - "UTD" - "Vivado" - "Xilinx" - ]; + dictionary = config.dictionary; excludes = [ ".sops.yaml" "sops/*" diff --git a/home-manager/base.nix b/home-manager/base.nix index ffaadeb..2e58c15 100644 --- a/home-manager/base.nix +++ b/home-manager/base.nix @@ -16,6 +16,7 @@ inputs.stylix.homeModules.stylix ./browser.nix ./desktop.nix + ./editor.nix ./media.nix ./secrets.nix ./shell.nix @@ -41,7 +42,6 @@ kitty.variant256Colors = true; bat.enable = false; fzf.enable = false; - helix.enable = false; qt.enable = false; starship.enable = false; }; @@ -161,19 +161,6 @@ vim = { enable = true; }; - # TODO: Disable Guix integration - # password-store = { - # enable = true; - # }; - helix = { - enable = true; - defaultEditor = true; - settings = { - editor.soft-wrap = { - enable = true; - }; - }; - }; git = { enable = true; delta = { diff --git a/home-manager/editor.nix b/home-manager/editor.nix new file mode 100644 index 0000000..8ad547d --- /dev/null +++ b/home-manager/editor.nix @@ -0,0 +1,204 @@ +# SPDX-FileCopyrightText: 2025 Ethan Reece +# +# SPDX-License-Identifier: MIT + +{ + config, + flakeConfig, + inputs, + lib, + pkgs, + system, + ... +}: +let + # SPDX-SnippetBegin + # SPDX-License-Identifier: MIT + # SPDX-SnippetCopyrightText: 2003-2025 Eelco Dolstra and the Nixpkgs/NixOS contributors + buildStyle = + { + name, + stylePath ? name, + ... + }@args: + pkgs.stdenvNoCC.mkDerivation ( + { + pname = "vale-style-${lib.toLower name}"; + + dontConfigure = true; + dontBuild = true; + doCheck = false; + dontFixup = true; + + installPhase = '' + runHook preInstall + mkdir -p $out/share/vale/styles + cp -R ${stylePath} "$out/share/vale/styles/${name}" + runHook postInstall + ''; + + # passthru.updateScript = nix-update-script { }; + # TODO: https://github.com/Mic92/nix-update + + meta = { + platforms = lib.platforms.all; + maintainers = with lib.maintainers; [ katexochen ]; + } + // (args.meta or { }); + } + // removeAttrs args [ + "meta" + "name" + ] + ); + # SPDX-SnippetEnd + tomlFormatter = pkgs.formats.toml { }; + vale = { + dictionary = rec { + name = "accept.txt"; + text = builtins.concatStringsSep "\n" flakeConfig.dictionary; + path = pkgs.writeTextFile { inherit name text; }; + }; + config = rec { + name = ".vale.ini"; + text = '' + StylesPath = styles + + MinAlertLevel = suggestion + + Vocab = General + + Packages = Joblint, RedHat, alex, proselint, Readability, write-good + + [{**/neomutt-*}] + BasedOnStyles = Vale, Joblint, RedHat, alex, Readability, proselint, write-good + ''; + path = pkgs.writeTextFile { inherit name text; }; + }; + directory = { + name = "share/vale"; + path = pkgs.buildEnv { + name = "vale-config"; + paths = [ + (pkgs.linkFarm vale.directory.name [ + { + name = "${vale.directory.name}/${vale.config.name}"; + path = vale.config.path; + } + { + name = "${vale.directory.name}/styles/config/vocabularies/General/${vale.dictionary.name}"; + path = vale.dictionary.path; + } + ]) + pkgs.valeStyles.alex + pkgs.valeStyles.joblint + pkgs.valeStyles.proselint + pkgs.valeStyles.readability + pkgs.valeStyles.write-good + (buildStyle rec { + name = "RedHat"; + version = "608"; + stylePath = ".vale/styles/${name}"; + src = pkgs.fetchFromGitHub { + owner = "redhat-documentation"; + repo = "vale-at-red-hat"; + rev = "v${version}"; + hash = "sha256-jAAWb0QHhk7UyfqKa9tUByyG11W/hlHESgywqinFiT4="; + }; + meta = { + description = "Vale-compatible implementation of the Red Hat Style Guide"; + homepage = "https://github.com/vale-at-red-hat/redhat-documentation"; + license = lib.licenses.mit; + }; + }) + # TODO: Integrate with `nix-flake-base` somehow + ]; + }; + }; + }; + typos = rec { + # https://github.com/crate-ci/typos/blob/master/docs/reference.md + dictionary = builtins.listToAttrs ( + builtins.map (x: { + name = x; + value = x; + }) flakeConfig.dictionary + ); + content = { + default = { + extend-words = dictionary; + extend-identifiers = dictionary; + extend-ignore-re = [ + "(?Rm)^.*(#|//)\\s*spellchecker:disable-line$" + "(?s)(#|//)\\s*spellchecker:off.*?\\n\\s*(#|//)\\s*spellchecker:on" + "(#|//)\\s*spellchecker:ignore-next-line\\n.*" + "(?Rm)^.*.*$" + "(?s).*?" + "\\n.*" + ]; + }; + # files.extend-exclude = config.languages.${module-name}.excludes; + }; + file = tomlFormatter.generate "typos.toml" content; + }; + harper = { + dictionary = rec { + name = "dictionary.txt"; + text = builtins.concatStringsSep "\n" flakeConfig.dictionary; + path = pkgs.writeTextFile { inherit name text; }; + }; + }; +in +{ + stylix = { + targets = { + helix.enable = false; + }; + }; + programs = { + helix = { + enable = true; + defaultEditor = true; + settings = { + editor.soft-wrap = { + enable = true; + }; + }; + languages = { + language-server = { + ltex-ls-plus = { + command = "${pkgs.ltex-ls-plus}/bin/ltex-ls-plus"; + config.ltex = { + dictionary.en-US = flakeConfig.dictionary; + additionalRules.enablePickyRules = true; + }; + }; + vale-ls = { + command = "${pkgs.vale-ls}/bin/vale-ls"; + config.configPath = "${vale.directory.path}/${vale.directory.name}/${vale.config.name}"; + }; + harper-ls = { + command = "${pkgs.harper}/bin/harper-ls"; + config.harper-ls.userDictPath = harper.dictionary.path; + }; + typos = { + command = "${pkgs.typos-lsp}/bin/typos-lsp"; + config.config = typos.file.outPath; + }; + }; + language = [ + { + name = "en-us_email"; + scope = "source.txt"; + file-types = [ { glob = "neomutt-*"; } ]; + language-servers = [ + "ltex-ls-plus" + "vale-ls" + "typos" + ]; + } + ]; + }; + }; + }; +} diff --git a/options/default.nix b/options/default.nix index 30c2e5b..37604f7 100644 --- a/options/default.nix +++ b/options/default.nix @@ -5,6 +5,13 @@ { lib, ... }: { options = { + dictionary = lib.mkOption { + description = '' + Dictionary. + ''; + default = [ ]; + type = lib.types.listOf lib.types.str; + }; profiles = lib.mkOption { description = '' Profiles for Flake configurations.