From d22323535c2c7e2268e33cdb65757c2a2ce6f7b8 Mon Sep 17 00:00:00 2001 From: Ethan Reece Date: Thu, 10 Jul 2025 04:05:57 -0500 Subject: [PATCH] Fix other various issues --- .gitignore | 2 +- README.md | 23 ++++++++++++++++++----- flake.nix | 31 +++++++++++++++++++++++++------ languages/en-us.nix | 4 ++++ languages/markdown.nix | 9 ++++++++- languages/yaml.nix | 9 +++++++-- 6 files changed, 63 insertions(+), 15 deletions(-) diff --git a/.gitignore b/.gitignore index c4f596c..93edd5c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ .direnv .helix -.vale/styles/config/vocabularies/General .pre-commit-config.yaml +.vale/styles/config/vocabularies/General/ diff --git a/README.md b/README.md index 1b7ca90..2fdba9a 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,26 @@ # Laptop configuration -This repository has the Nix home-manager configuration for my laptop, allowing me to manage a user configuration with reproducibility on other machines. It currently operates on a foreign Linux distribution (Fedora Asahi Remix) with plans to switch to NixOS when time allows and to make it reusable for other systems. `direnv` automatically loads the environment for running commands for this Flake. +This repository has the Nix home-manager configuration for my laptop, allowing +me to manage a user configuration with reproducibility on other machines. It +currently operates on a foreign Linux distribution (Fedora Asahi Remix) with +plans to switch to NixOS when time allows and to make it reusable for other +systems. `direnv` automatically loads the environment for running commands for +this Flake. ## Features - **`home-manager`** - Defines the user environment - **`flake-parts`** - Makes the Flake modular and reusable - **`sops`** - Encrypts secrets -- **`treefmt`** (with Helix integration) - Automatically formats this repository when modifying it, with features to check the flake for formatting consistency -- **Language Server Protocol (LSP)** - Has language servers for file formats used in this repository; integrates with Helix text editor and fully managed by Nix with each language's configuration in its own file -- **AI** - Uses Nix home-manager integrations for Codex and `aichat` for querying Large Language Models (LLMs) in the CLI and in Git repositories -- **Language tools** - Checks for grammatical and styling issues using Vale, Harper, LTeX, and Typos, centralizing the custom dictionary for these tools in the Nix configuration +- **`treefmt`** (with Helix integration) - Automatically formats this repository + when modifying it, with features to check the flake for formatting consistency +- **Language Server Protocol (LSP)** - Has language servers for file formats + used in this repository; integrates with Helix text editor and fully managed + by Nix with each language's configuration in its own file +- **AI** - Uses Nix home-manager integrations for Codex and `aichat` for + querying Large Language Models (LLMs) in the CLI and in Git repositories +- **Language tools** - Checks for grammatical and styling issues using Vale, + Harper, LTeX, and Typos, centralizing the custom dictionary for these tools in + the Nix configuration +- **Git pre-commit hooks** - Lints the files before making a commit, both with + programming and natural languages diff --git a/flake.nix b/flake.nix index f32139e..5d35f46 100644 --- a/flake.nix +++ b/flake.nix @@ -61,6 +61,26 @@ perSystem = { system, config, ... }: let + excludes = [ + ".vale/*" + "home/vencord.nix" + ]; + deepMerge = + lhs: rhs: + lhs + // rhs + // (builtins.mapAttrs ( + rName: rValue: + let + lValue = lhs.${rName} or null; + in + if builtins.isAttrs lValue && builtins.isAttrs rValue then + deepMerge lValue rValue + else if builtins.isList lValue && builtins.isList rValue then + lValue ++ rValue + else + rValue + ) rhs); pkgs = import inputs.nixpkgs { inherit system; overlays = [ @@ -81,7 +101,9 @@ ); language-server = builtins.foldl' (acc: cfg: acc // (cfg.helix.language-server or { })) { } configs; }; - treefmtPrograms = builtins.foldl' (acc: cfg: acc // (cfg.treefmt.programs or { })) { } configs; + treefmtPrograms = builtins.foldl' ( + acc: cfg: deepMerge acc (cfg.treefmt.programs or { }) + ) { } configs; preCommitHooks = builtins.foldl' (acc: cfg: acc // (cfg.pre-commit or { })) { } configs; devshellConfigs = { commands = builtins.concatMap (cfg: cfg.devshell.commands) ( @@ -170,11 +192,6 @@ ${pkgs.uutils-coreutils-noprefix}/bin/ln -fs ${helixLanguagesFile} ./.helix/languages.toml ''; }; - pre_commit = { - text = '' - ${config.pre-commit.installationScript} - ''; - }; }; }; }; @@ -189,11 +206,13 @@ check-symlinks.enable = true; flake-checker.enable = true; }; + excludes = excludes; }; # https://flake.parts/options/treefmt-nix.html treefmt = { projectRootFile = "flake.nix"; programs = treefmtPrograms; + settings.global.excludes = excludes; }; }; } diff --git a/languages/en-us.nix b/languages/en-us.nix index 13ee992..7221cfb 100644 --- a/languages/en-us.nix +++ b/languages/en-us.nix @@ -42,6 +42,10 @@ in configPath = typosConfigFile.outPath; locale = "en-us"; }; + excludes = [ + ".vale/*" + "home/vencord.nix" + ]; }; vale.enable = true; }; diff --git a/languages/markdown.nix b/languages/markdown.nix index 0dc2021..9d7d037 100644 --- a/languages/markdown.nix +++ b/languages/markdown.nix @@ -24,7 +24,14 @@ }; treefmt.programs.dprint = { enable = true; - settings.plugins = [ "dprint-plugin-markdown" ]; + settings = { + plugins = (pkgs.dprint-plugins.getPluginList (plugins: with plugins; [ dprint-plugin-markdown ])); + markdown = { + lineWidth = 80; + textWrap = "always"; + }; + }; + includes = [ "*.md" ]; }; pre-commit = { markdownlint.enable = true; diff --git a/languages/yaml.nix b/languages/yaml.nix index 1a820ae..6996988 100644 --- a/languages/yaml.nix +++ b/languages/yaml.nix @@ -21,10 +21,15 @@ }; treefmt.programs.dprint = { enable = true; - settings.plugins = [ "g-plane-pretty_yaml" ]; + settings.plugins = ( + pkgs.dprint-plugins.getPluginList (plugins: with plugins; [ g-plane-pretty_yaml ]) + ); + includes = [ + "*.yaml" + "*.yml" + ]; }; pre-commit = { check-yaml.enable = true; - sort-simple-yaml.enable = true; }; }