diff --git a/docs/mdbook/default.nix b/docs/mdbook/default.nix index 1e45a023..e70e0c4e 100644 --- a/docs/mdbook/default.nix +++ b/docs/mdbook/default.nix @@ -1,5 +1,6 @@ { pkgs, + callPackage, runCommand, lib, evaledModules, @@ -349,6 +350,10 @@ pkgs.stdenv.mkDerivation (finalAttrs: { substituteInPlace ./index.md \ --replace-fail "@DOCS_VERSIONS@" "$(cat ${finalAttrs.passthru.docs-versions})" + # Patch user-configs + substituteInPlace ./user-guide/config-examples.md \ + --replace-fail "@USER_CONFIGS@" "$(cat ${finalAttrs.passthru.user-configs})" + mdbook build cp -r ./book/* $dest mkdir -p $dest/search @@ -398,5 +403,6 @@ pkgs.stdenv.mkDerivation (finalAttrs: { echo "- The $link, for use with nixpkgs \`$nixpkgs\`$suffix" >> "$out" done ''; + user-configs = callPackage ../user-configs { }; }; }) diff --git a/docs/user-configs/default.nix b/docs/user-configs/default.nix new file mode 100644 index 00000000..f19e35fd --- /dev/null +++ b/docs/user-configs/default.nix @@ -0,0 +1,56 @@ +{ + callPackages, + stdenvNoCC, + yq, + name ? "user-configs", +}: +stdenvNoCC.mkDerivation (finalAttrs: { + enableParallelBuilding = true; + phases = [ "buildPhase" ]; + + inherit name; + src = ./list.toml; + + nativeBuildInputs = [ + yq # provides tomlq + ]; + + # Function definitions for use in the jq query + jqFunctions = '' + def normalizeSpaces: . | gsub("\\s+"; " ") | ltrimstr(" ") | rtrimstr(" "); + ''; + + # The jq query passed to tomlq + query = '' + .config + | sort_by( + (.owner | ascii_downcase), + (.title // .repo | ascii_downcase) + ) + | .[] + | .title = (.title // .repo | normalizeSpaces) + | .owner_url = "https://github.com/\(.owner)" + | .url = (.url // "\(.owner_url)/\(.repo)") + | .description = (.description // "" | normalizeSpaces) + ''; + + # The markdown table heading + heading = '' + | Owner | Config | Comment | + |-------|--------|---------| + ''; + + # A jq query "template" for the markdown table row + template = '' + "| [\(.owner)](\(.owner_url)) | [\(.title)](\(.url)) | \(.description) |" + ''; + + buildPhase = '' + echo -n "$heading" > "$out" + tomlq "$jqFunctions $query | $template" --raw-output "$src" >> "$out" + ''; + + passthru = { + tests = callPackages ./tests.nix { drv = finalAttrs.finalPackage; }; + }; +}) diff --git a/docs/user-configs/list.toml b/docs/user-configs/list.toml new file mode 100644 index 00000000..8747f779 --- /dev/null +++ b/docs/user-configs/list.toml @@ -0,0 +1,131 @@ +# This file contains a list of nixvim configurations that should be included in the "user configs" section of the docs + +# This example shows the available options +[[example]] +owner = "github username" # Required +repo = "repo name" # Required unless `url` is used instead +# url = "https://github.com/owner/repo +title = "My awesome nix config" # Defaults to `repo`. Required if `repo` is not defined +description = """ # Optional +A brief description for my config. +Linebreaks will be replaced with spaces. +But it still should not be _too_ long... + +Note: You can use markdown in both the title and description! +""" + + +[[config]] +owner = "ahwxorg" +repo = "nixvim-config" + +[[config]] +owner = "alisonjenkins" +repo = "neovim-nix-flake" + +[[config]] +owner = "bkp5190" +repo = "Home-Manager-Configs" +description = "Home-manager" + +[[config]] +owner = "dc-tec" +repo = "nixvim" +description = "NixVim config, inspired by some of the contributors in this list and LazyVIM" + +[[config]] +owner = "elythh" +repo = "nixvim" + +[[config]] +owner = "fred-drake" +repo = "neovim" +description = "NixVim config, with format/lsp/debug configurations for Rust, Go, Python and more" + +[[config]] +owner = "GaetanLepage" +title = "nix-config" +description = "Home-manager" +url = "https://github.com/GaetanLepage/nix-config/tree/master/home/modules/tui/neovim" + +[[config]] +owner = "gwg313" +repo = "nvim-nix" + +[[config]] +owner = "hbjydev" +repo = "hvim" + +[[config]] +owner = "JMartJonesy" +repo = "kickstart.nixvim" +description = "An implementation of kickstart.nvim using nixvim" + +[[config]] +owner = "JMartJonesy" +title = "kickstart.nixvim standalone" +description = "An implementation of kickstart.nvim using nixvim in a standalone flake" +url = "https://github.com/JMartJonesy/kickstart.nixvim/tree/standalone" + +[[config]] +owner = "khaneliman" +repo = "khanelivim" +description = "Constantly tweaked jack of all trades development focused configuration." + +[[config]] +owner = "MikaelFangel" +repo = "nixvim-config" +description = "An easy-setup configuration for NixVim, focused on straightforward customization" + +[[config]] +owner = "nicolas-goudry" +repo = "nixvim-config" +description = "Heavily inspired by AstroNvim" + +[[config]] +owner = "NikolayGalkin" +repo = "gnvim" +description = "Clean and simple Neovim configuration" + +[[config]] +owner = "niksingh710" +repo = "nvix" +description = "Ported from a lazy-based lua config. Contains examples of most use cases, including custom, nixpkgs, & nixvim plugins." + +[[config]] +owner = "pete3n" +repo = "nixvim-flake" + +[[config]] +owner = "redyf" +repo = "Neve" +description = "Meticulously crafted custom configuration for Nixvim" + +[[config]] +owner = "siph" +repo = "nixvim-flake" + +[[config]] +owner = "spector700" +repo = "Akari" +description = "Inspired from LazyVim with parts yoinked from other NixVim configs" + +[[config]] +owner = "Tanish2002" +repo = "neovim-config" + +[[config]] +owner = "traxys" +title = "Nixfiles" +url = "https://github.com/traxys/Nixfiles/tree/master/neovim" + +[[config]] +owner = "veeronniecaw" +title = "ronvim" +url = "https://codeberg.org/veeronniecaw/ronvim" + +[[config]] +owner = "ZainKergaye" +title = "nixosdotfiles" +url = "https://github.com/ZainKergaye/nixosdotfiles/tree/master/user/programs/nixvim" +description = "NixVim editor primarily for Java and Asciidoc" diff --git a/docs/user-configs/tests.nix b/docs/user-configs/tests.nix new file mode 100644 index 00000000..5e62cd3c --- /dev/null +++ b/docs/user-configs/tests.nix @@ -0,0 +1,146 @@ +{ + lib, + testers, + writeText, + drv, # The derivation under test +}: +let + toFile = name: v: if lib.isPath v then v else writeText name v; + + overrideSrc = + src: + drv.overrideAttrs { + inherit src; + }; + + expectEqualContent = + { + message, + expected, + input, + }: + testers.testEqualContents { + assertion = message; + actual = overrideSrc (toFile "${message}-input" input); + expected = toFile "${message}-expected" expected; + }; +in +# TODO: introduce some negative cases for input that should fail +{ + maintainers = expectEqualContent { + message = "integration test: maintainers"; + input = '' + [[config]] + owner = "GaetanLepage" + title = "nix-config" + description = "Home-manager" + url = "https://github.com/GaetanLepage/nix-config/tree/master/home/modules/tui/neovim" + + [[config]] + owner = "khaneliman" + repo = "khanelivim" + description = "Constantly tweaked jack of all trades development focused configuration." + + [[config]] + owner = "MattSturgeon" + repo = "nix-config" + + [[config]] + owner = "traxys" + title = "Nixfiles" + url = "https://github.com/traxys/Nixfiles/tree/master/neovim" + ''; + expected = '' + | Owner | Config | Comment | + |-------|--------|---------| + | [GaetanLepage](https://github.com/GaetanLepage) | [nix-config](https://github.com/GaetanLepage/nix-config/tree/master/home/modules/tui/neovim) | Home-manager | + | [khaneliman](https://github.com/khaneliman) | [khanelivim](https://github.com/khaneliman/khanelivim) | Constantly tweaked jack of all trades development focused configuration. | + | [MattSturgeon](https://github.com/MattSturgeon) | [nix-config](https://github.com/MattSturgeon/nix-config) | | + | [traxys](https://github.com/traxys) | [Nixfiles](https://github.com/traxys/Nixfiles/tree/master/neovim) | | + ''; + }; + + simple = expectEqualContent { + message = "unit test: simple"; + input = '' + [[config]] + owner = "Simon" + title = "Says" + url = "url" + ''; + expected = '' + | Owner | Config | Comment | + |-------|--------|---------| + | [Simon](https://github.com/Simon) | [Says](url) | | + ''; + }; + + simple-description = expectEqualContent { + message = "unit test: simple with description"; + input = '' + [[config]] + owner = "Simon" + title = "Says" + url = "url" + description = "desc" + ''; + expected = '' + | Owner | Config | Comment | + |-------|--------|---------| + | [Simon](https://github.com/Simon) | [Says](url) | desc | + ''; + }; + + description-with-lines = expectEqualContent { + message = "unit test: description with linebreaks"; + input = '' + [[config]] + owner = "sloppy" + title = "title" + url = "url" + description = """ + + This description + + Contains + + Many + Line + breaks + + + """ + ''; + expected = '' + | Owner | Config | Comment | + |-------|--------|---------| + | [sloppy](https://github.com/sloppy) | [title](url) | This description Contains Many Line breaks | + ''; + }; + + title-with-lines = expectEqualContent { + message = "unit test: title with linebreaks"; + input = '' + [[config]] + owner = "sloppy" + title = """ + + This title + + Contains + + Many + Line + breaks + + + """ + url = "url" + ''; + expected = '' + | Owner | Config | Comment | + |-------|--------|---------| + | [sloppy](https://github.com/sloppy) | [This title Contains Many Line breaks](url) | | + ''; + }; +} diff --git a/docs/user-guide/config-examples.md b/docs/user-guide/config-examples.md index 18744a5c..2a19d4b0 100644 --- a/docs/user-guide/config-examples.md +++ b/docs/user-guide/config-examples.md @@ -10,62 +10,20 @@ Take a look at these configuration examples below. Most of those configurations are using a [standalone build](../platforms/standalone.html), however, all of the nixvim options are accessible no matter how you are using it (flake, NixOS/HM module, nix-darwin...). -| Config | Comment | -|-|-| -| [ahwxorg/nixvim-config] | | -| [alisonjenkins/neovim-nix-flake] | | -| [bkp5190/home-manager-configs] | Home-manager | -| [dc-tec/nixvim] | NixVim config, inspired by some of the contributors in this list and LazyVIM | -| [elythh/nixvim] | | -| [fred-drake/neovim] | NixVim config, with format/lsp/debug configurations for Rust, Go, Python and more | -| [GaetanLepage/nix-config] | Home-manager | -| [gwg313/nvim-nix] | | -| [hbjydev/hvim] | | -| [JMartJonesy/kickstart.nixvim] | An implementation of kickstart.nvim using nixvim | -| [JMartJonesy/kickstart.nixvim/tree/standalone] | An implementation of kickstart.nvim using nixvim in a standalone flake | -| [khaneliman/khanelivim] | Constantly tweaked jack of all trades development focused configuration. | -| [MikaelFangel/nixvim-config] | An easy-setup configuration for NixVim, focused on straightforward customization | -| [nicolas-goudry/nixvim-config] | Heavily inspired by AstroNvim | -| [NikolayGalkin/gnvim] | Clean and simple Neovim configuration | -| [niksingh710/nvix] | Ported from a lazy-based lua config. Contains examples of most use cases, including custom, nixpkgs, & nixvim plugins. | -| [pete3n/nixvim-flake] | | -| [redyf/Neve] | Meticulously crafted custom configuration for Nixvim | -| [siph/nixvim-flake] | | -| [spector700/Akari] | Inspired from LazyVim with parts yoinked from other NixVim configs | -| [Tanish2002/neovim-config] | | -| [traxys/Nixfiles] | | -| [veeronniecaw/ronvim] | | -| [zainkergaye/nixosdotfiles] | NixVim editor primarily for Java and Asciidoc | - - - -[ahwxorg/nixvim-config]: https://github.com/ahwxorg/nixvim-config -[alisonjenkins/neovim-nix-flake]: https://github.com/alisonjenkins/neovim-nix-flake -[bkp5190/home-manager-configs]: https://github.com/bkp5190/Home-Manager-Configs -[dc-tec/nixvim]: https://github.com/dc-tec/nixvim -[elythh/nixvim]: https://github.com/elythh/nixvim -[fred-drake/neovim]: https://github.com/fred-drake/neovim -[GaetanLepage/nix-config]: https://github.com/GaetanLepage/nix-config/tree/master/home/modules/tui/neovim -[gwg313/nvim-nix]: https://github.com/gwg313/nvim-nix -[hbjydev/hvim]: https://github.com/hbjydev/hvim -[JMartJonesy/kickstart.nixvim]: https://github.com/JMartJonesy/kickstart.nixvim -[JMartJonesy/kickstart.nixvim/tree/standalone]: https://github.com/JMartJonesy/kickstart.nixvim/tree/standalone -[khaneliman/khanelivim]: https://github.com/khaneliman/khanelivim -[MikaelFangel/nixvim-config]: https://github.com/MikaelFangel/nixvim-config -[nicolas-goudry/nixvim-config]: https://github.com/nicolas-goudry/nixvim-config -[NikolayGalkin/gnvim]: https://github.com/NikolayGalkin/gnvim -[niksingh710/nvix]: https://github.com/niksingh710/nvix -[pete3n/nixvim-flake]: https://github.com/pete3n/nixvim-flake -[redyf/Neve]: https://github.com/redyf/Neve -[siph/nixvim-flake]: https://github.com/siph/nixvim-flake -[spector700/Akari]: https://github.com/spector700/Akari -[Tanish2002/neovim-config]: https://github.com/Tanish2002/neovim-config -[traxys/Nixfiles]: https://github.com/traxys/Nixfiles/tree/master/neovim -[veeronniecaw/ronvim]: https://codeberg.org/veeronniecaw/ronvim -[zainkergaye/nixosdotfiles]: https://github.com/ZainKergaye/nixosdotfiles/tree/master/user/programs/nixvim +@USER_CONFIGS@ ## Share your config ! -To add a configuration to this list, either: -- Edit [this file](https://github.com/nix-community/nixvim/blob/main/docs/user-guide/config-examples.md) and make a PR on the [nixvim repo](https://github.com/nix-community/nixvim). -- Send a message to the [matrix _Documentation_ room](https://matrix.to/#/#nixvim-documentation:matrix.org) +> [!TIP] +> You can add your config to the list by editing the [`docs/user-configs/list.toml`] file. + +Please use this format for both your commit message and PR title: \ +`user-configs: add @Username's config"` \ +(replacing `Username` with your github username) + +Alternatively, message us in the [matrix _Documentation_ room] and we'll get it added. + +[`docs/user-configs/list.toml`]: https://github.com/nix-community/nixvim/blob/main/docs/user-configs/list.toml +[matrix _Documentation_ room]: https://matrix.to/#/#nixvim-documentation:matrix.org + + diff --git a/tests/default.nix b/tests/default.nix index f24b55d5..68098088 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -3,6 +3,7 @@ pkgsUnfree, helpers, lib, + linkFarm, self, # The flake instance system ? pkgs.stdenv.hostPlatform.system, }: @@ -29,6 +30,8 @@ let callTest = lib.callPackageWith autoArgs; callTests = lib.callPackagesWith autoArgs; + + selfPackages = self.packages.${system}; in { extra-args-tests = callTest ./extra-args.nix { }; @@ -44,6 +47,11 @@ in package-options = callTest ./package-options.nix { }; lsp-all-servers = callTest ./lsp-servers.nix { }; } +# Expose some tests from the docs as flake-checks too +// lib.optionalAttrs (selfPackages ? docs) { + # Individual tests can be run using: nix build .#docs.user-configs.tests. + docs-user-configs = linkFarm "user-configs-tests" selfPackages.docs.user-configs.tests; +} # Tests generated from ./test-sources # Grouped as a number of link-farms in the form { test-1, test-2, ... test-N } // callTests ./main.nix { }