From 368cb6b0d25db2ae23be42ad51584de059997e51 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Mon, 20 May 2024 16:10:21 +0200 Subject: refactor(sys): Modularize and move to `modules/system` or `pkgs` --- pkgs/sources/plgs-pkgs/README.md | 92 ++++++++++++++++++++++++++++ pkgs/sources/plgs-pkgs/check.nix | 37 +++++++++++ pkgs/sources/plgs-pkgs/default.nix | 15 +++++ pkgs/sources/plgs-pkgs/overrides.nix | 34 ++++++++++ pkgs/sources/plgs-pkgs/plugins/.plugins.json | 7 +++ pkgs/sources/plgs-pkgs/plugins/blacklist.txt | 1 + pkgs/sources/plgs-pkgs/plugins/default.nix | 55 +++++++++++++++++ pkgs/sources/plgs-pkgs/plugins/manifest.txt | 3 + pkgs/sources/plgs-pkgs/plugins/plugins.md | 7 +++ pkgs/sources/plgs-pkgs/plugins/whitelist.txt | 0 pkgs/sources/plgs-pkgs/update.sh | 27 ++++++++ 11 files changed, 278 insertions(+) create mode 100644 pkgs/sources/plgs-pkgs/README.md create mode 100644 pkgs/sources/plgs-pkgs/check.nix create mode 100644 pkgs/sources/plgs-pkgs/default.nix create mode 100644 pkgs/sources/plgs-pkgs/overrides.nix create mode 100644 pkgs/sources/plgs-pkgs/plugins/.plugins.json create mode 100644 pkgs/sources/plgs-pkgs/plugins/blacklist.txt create mode 100644 pkgs/sources/plgs-pkgs/plugins/default.nix create mode 100644 pkgs/sources/plgs-pkgs/plugins/manifest.txt create mode 100644 pkgs/sources/plgs-pkgs/plugins/plugins.md create mode 100644 pkgs/sources/plgs-pkgs/plugins/whitelist.txt create mode 100755 pkgs/sources/plgs-pkgs/update.sh (limited to 'pkgs/sources/plgs-pkgs') diff --git a/pkgs/sources/plgs-pkgs/README.md b/pkgs/sources/plgs-pkgs/README.md new file mode 100644 index 00000000..e8169951 --- /dev/null +++ b/pkgs/sources/plgs-pkgs/README.md @@ -0,0 +1,92 @@ +# Fork + +All files in this repository where forked form [here](https://github.com/NixNeovim/NixNeovimPlugins) on commit `5010b91eb03696574c3c293f072a090618227e87`. +Below the original README. They were licensed under the MIT license. + +# All vim plugins, ready to go + +This repo auto generates nix packages for vim/neovim plugins. +Packages are automatically updated twice per week using a GitHub Actions. +Plugins are fetched from the `manifest.txt` and [awesome-neovim][0] repo. + +This is a fork of [this repo](https://github.com/m15a/nixpkgs-vim-extra-plugins); however, we fetch all additions from the original repo, so we will never have less plugins. +Further, the original deletes plugins that are available in the nixpkgs. We, instead, try to assemble a list of all available plugins. +Therefore, to access plugins you will never have to search in two places. + +This repo can be used as a stand-alone, by adding it to your inputs. +However, we recommend to use [NixNeovim](https://github.com/NixNeovim/NixNeovim) modules instead, and use this only when you need a plugins, which does not have a module, yet. + +## Available plugins + +The [plugins.md](plugins.md) contains an auto-generated list of all available plugins. + +## Usage + +- We recommend using [NixNeovim](https://github.com/NixNeovim/NixNeovim), and only access the plugins directly when they do not have a module in NixNeovim. + +However, you can also use this repo without NixNeovim: +To access the plugins, you need to add the overlay. +The overlay adds extra Vim plugins to `pkgs.vimExtraPlugins`. +First, add this repo to your inputs: + +``` +inputs.nixneovimplugins.url = github:jooooscha/nixpkgs-vim-extra-plugins +``` + +Next, apply the provided overlay: + +``` +nixpkgs.overlays = [ + inputs.nixneovimplugins.overlays.default +]; +``` + +Finally, you can add the packages to your vim/neovim config. For example you can use [NixNeovim](https://github.com/NixNeovim/Nixneovim) or you can add the plugins directly: + +``` + programs.neovim = { + plugins = [ + pkgs.vimExtraPlugins.nvim-colorizer-lua + ]; + } +``` + +More info on using neovim with nix can be found here: [NixOS Neovim](https://nixos.wiki/wiki/Neovim) + +## Contribution + +### How to add a new plugin + +#### 1. Add the plugin to manifest.txt: + +``` +# Examples + +haringsrob/nvim_context_vt +sourcehut:henriquehbr/ataraxis.lua +gitlab:yorickpeterse/nvim-pqf +williamboman/mason.nvim:45b9a4da776d9fb017960b3ac7241161fb7bc578 +foo/bar::baz --> renamed to baz +foo/bar:dev --> using dev branch +``` + +Supported are Github (default), SourceHut, and GitLab. + +#### 2. Create a Pull Request + +- Create a pull request with the changed manifest.txt (and blacklist.txt if neccessary). +- A GitHub action will check your contribution and generate all neccessary nix code for your new plugin. It will also take care of sorting and cleaning the manifest.txt +- After all checks have passed, I will merge your change. + +I am happy for any contribution. :) + +### How to remove a new plugin + +Copy the entry from manifest.txt to blacklist.txt and create a PR. +The GitHub Actions will do the rest, including removing the entry from manifest.txt + +## Credits + +This is originally based on work by [m15a](https://github.com/m15a/nixpkgs-vim-extra-plugins) + +[0]: https://github.com/rockerBOO/awesome-neovim diff --git a/pkgs/sources/plgs-pkgs/check.nix b/pkgs/sources/plgs-pkgs/check.nix new file mode 100644 index 00000000..ad23e2c7 --- /dev/null +++ b/pkgs/sources/plgs-pkgs/check.nix @@ -0,0 +1,37 @@ +{ + pkgs, + lib, + ... +}: let + # checks if a plugin has a license + hasLicense = _: pkg: let + warn = x: lib.warn x x; + + msg = + if builtins.hasAttr "license" pkg.meta + then "${pkg.name} has license" + else warn "${pkg.name} has no license"; + + msg' = lib.replaceStrings [" "] ["-"] msg; + in + pkgs.runCommandNoCC msg' {} "echo : > $out "; + + # function to check License for all packages + check-missing-licenses = let + buildInputs = + lib.mapAttrsToList + hasLicense + pkgs.vimExtraPlugins; + in + pkgs.runCommandNoCC + "check-missing-licenses" + {inherit buildInputs;} + "echo : > $out"; +in { + checks = + pkgs.vimExtraPlugins + // { + inherit check-missing-licenses; + inherit (pkgs) update-vim-plugins; + }; +} diff --git a/pkgs/sources/plgs-pkgs/default.nix b/pkgs/sources/plgs-pkgs/default.nix new file mode 100644 index 00000000..0f7cd485 --- /dev/null +++ b/pkgs/sources/plgs-pkgs/default.nix @@ -0,0 +1,15 @@ +[ + (final: prev: + prev.lib.composeManyExtensions [ + (self: super: let + origin = import ./plugins { + inherit (super.vimUtils) buildVimPlugin; + inherit (super) lib fetchurl fetchgit; + }; + in { + vimExtraPlugins = super.lib.makeExtensible (_: super.lib.recurseIntoAttrs origin); + }) + ] + final + prev) +] diff --git a/pkgs/sources/plgs-pkgs/overrides.nix b/pkgs/sources/plgs-pkgs/overrides.nix new file mode 100644 index 00000000..e03a78b1 --- /dev/null +++ b/pkgs/sources/plgs-pkgs/overrides.nix @@ -0,0 +1,34 @@ +final: prev: let + inherit (final) lib; + + /* + * Mark broken packages here. + */ + markBrokenPackages = self: super: + lib.mapAttrs (attrName: broken: + super.${attrName}.overrideAttrs (old: { + meta = old.meta // {inherit broken;}; + })) + { + # = true; + }; + + /* + * Add licenses if missing or incorrect in generated ./pkgs/vim-plugins.nix. + */ + fixLicenses = self: super: + lib.mapAttrs (attrName: license: + super.${attrName}.overrideAttrs (old: { + meta = old.meta // {inherit license;}; + })) (with lib.licenses; { + /* + * Example: + * plugin-name = [] + */ + }); +in { + vimExtraPlugins = prev.vimExtraPlugins.extend (lib.composeManyExtensions [ + markBrokenPackages + fixLicenses + ]); +} diff --git a/pkgs/sources/plgs-pkgs/plugins/.plugins.json b/pkgs/sources/plgs-pkgs/plugins/.plugins.json new file mode 100644 index 00000000..9331bc8f --- /dev/null +++ b/pkgs/sources/plgs-pkgs/plugins/.plugins.json @@ -0,0 +1,7 @@ +{ + "ThePrimeagen/harpoon:master": "{\"description\": \"\", \"homepage\": \"https://github.com/ThePrimeagen/harpoon\", \"license\": {\"py/reduce\": [{\"py/type\": \"update_vim_plugins.nix.License\"}, {\"py/tuple\": [\"mit\"]}]}, \"name\": \"harpoon\", \"owner\": \"ThePrimeagen\", \"py/object\": \"update_vim_plugins.plugin.GitHubPlugin\", \"source\": {\"py/object\": \"update_vim_plugins.nix.UrlSource\", \"sha256\": \"1w4hi9hbdjwdhb4vwa0x08a25vbcxqg1d5cskm2qvjy5fdlqils0\", \"url\": \"https://github.com/ThePrimeagen/harpoon/archive/ccae1b9bec717ae284906b0bf83d720e59d12b91.tar.gz\"}, \"source_line\": \"ThePrimeagen/harpoon:master\", \"version\": {\"__reduce__\": [{\"py/type\": \"datetime.date\"}, [\"B+cMGg==\"]], \"py/object\": \"datetime.date\"}}", + "akinsho/toggleterm.nvim": "{\"description\": \"A neovim lua plugin to help easily manage multiple terminal windows\", \"homepage\": \"https://github.com/akinsho/toggleterm.nvim\", \"license\": {\"py/reduce\": [{\"py/type\": \"update_vim_plugins.nix.License\"}, {\"py/tuple\": [\"gpl3Only\"]}]}, \"name\": \"toggleterm-nvim\", \"owner\": \"akinsho\", \"py/object\": \"update_vim_plugins.plugin.GitHubPlugin\", \"source\": {\"py/object\": \"update_vim_plugins.nix.UrlSource\", \"sha256\": \"0nx69q9597vy7lzvvh58fnjyin23ns6apmyp532sgf547bw7mld6\", \"url\": \"https://github.com/akinsho/toggleterm.nvim/archive/cbd041d91b90cd3c02df03fe6133208888f8e008.tar.gz\"}, \"source_line\": \"akinsho/toggleterm.nvim\", \"version\": {\"__reduce__\": [{\"py/type\": \"datetime.date\"}, [\"B+cMBg==\"]], \"py/object\": \"datetime.date\"}}", + "andrewferrier/debugprint.nvim": "{\"description\": \"Debugging in NeoVim the print() way!\", \"homepage\": \"https://github.com/andrewferrier/debugprint.nvim\", \"license\": {\"py/reduce\": [{\"py/type\": \"update_vim_plugins.nix.License\"}, {\"py/tuple\": [\"mit\"]}]}, \"name\": \"debugprint-nvim\", \"owner\": \"andrewferrier\", \"py/object\": \"update_vim_plugins.plugin.GitHubPlugin\", \"source\": {\"py/object\": \"update_vim_plugins.nix.UrlSource\", \"sha256\": \"06r1jhx7jd15q8wvnw0xqwk3bkx39pm4pbv70hf9ggd6zsnmsrmn\", \"url\": \"https://github.com/andrewferrier/debugprint.nvim/archive/54297dd0a4f318b279a1cb954e7714f3942df123.tar.gz\"}, \"source_line\": \"andrewferrier/debugprint.nvim\", \"version\": {\"__reduce__\": [{\"py/type\": \"datetime.date\"}, [\"B+gDHQ==\"]], \"py/object\": \"datetime.date\"}}", + "lmburns/lf.nvim": "{\"description\": \"Lf file manager for Neovim (in Lua)\", \"homepage\": \"https://github.com/lmburns/lf.nvim\", \"license\": {\"py/reduce\": [{\"py/type\": \"update_vim_plugins.nix.License\"}, {\"py/tuple\": [\"mit\"]}]}, \"name\": \"lf-nvim\", \"owner\": \"lmburns\", \"py/object\": \"update_vim_plugins.plugin.GitHubPlugin\", \"source\": {\"py/object\": \"update_vim_plugins.nix.UrlSource\", \"sha256\": \"1nwf90bnzqhlgs007gg6xpx0vf4r1d19586nld78ipi1ch7nz4px\", \"url\": \"https://github.com/lmburns/lf.nvim/archive/69ab1efcffee6928bf68ac9bd0c016464d9b2c8b.tar.gz\"}, \"source_line\": \"lmburns/lf.nvim\", \"version\": {\"__reduce__\": [{\"py/type\": \"datetime.date\"}, [\"B+cKAw==\"]], \"py/object\": \"datetime.date\"}}", + "nvim-telescope/telescope-bibtex.nvim": "{\"description\": \"A telescope.nvim extension to search and paste bibtex entries into your TeX files.\", \"homepage\": \"https://github.com/nvim-telescope/telescope-bibtex.nvim\", \"license\": {\"py/reduce\": [{\"py/type\": \"update_vim_plugins.nix.License\"}, {\"py/tuple\": [\"mit\"]}]}, \"name\": \"telescope-bibtex-nvim\", \"owner\": \"nvim-telescope\", \"py/object\": \"update_vim_plugins.plugin.GitHubPlugin\", \"source\": {\"py/object\": \"update_vim_plugins.nix.UrlSource\", \"sha256\": \"1sd6p8cvv3dckgrhc7grlyfcibjxhxbfyh0w7p5m4mdcazhy1kqs\", \"url\": \"https://github.com/nvim-telescope/telescope-bibtex.nvim/archive/289a6f86ebec06e8ae1590533b732b9981d84900.tar.gz\"}, \"source_line\": \"nvim-telescope/telescope-bibtex.nvim\", \"version\": {\"__reduce__\": [{\"py/type\": \"datetime.date\"}, [\"B+gDHA==\"]], \"py/object\": \"datetime.date\"}}" +} \ No newline at end of file diff --git a/pkgs/sources/plgs-pkgs/plugins/blacklist.txt b/pkgs/sources/plgs-pkgs/plugins/blacklist.txt new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/pkgs/sources/plgs-pkgs/plugins/blacklist.txt @@ -0,0 +1 @@ + diff --git a/pkgs/sources/plgs-pkgs/plugins/default.nix b/pkgs/sources/plgs-pkgs/plugins/default.nix new file mode 100644 index 00000000..df09e446 --- /dev/null +++ b/pkgs/sources/plgs-pkgs/plugins/default.nix @@ -0,0 +1,55 @@ +{ + lib, + buildVimPlugin, + fetchurl, + fetchgit, +}: { + /* + Generated from: ThePrimeagen/harpoon:master + */ + harpoon = buildVimPlugin { + pname = "harpoon"; + version = "2023-12-26"; + src = fetchurl { + url = "https://github.com/ThePrimeagen/harpoon/archive/ccae1b9bec717ae284906b0bf83d720e59d12b91.tar.gz"; + sha256 = "1w4hi9hbdjwdhb4vwa0x08a25vbcxqg1d5cskm2qvjy5fdlqils0"; + }; + meta = with lib; { + description = ""; + homepage = "https://github.com/ThePrimeagen/harpoon"; + license = with licenses; [mit]; + }; + }; + /* + Generated from: lmburns/lf.nvim + */ + lf-nvim = buildVimPlugin { + pname = "lf-nvim"; + version = "2023-10-03"; + src = fetchurl { + url = "https://github.com/lmburns/lf.nvim/archive/69ab1efcffee6928bf68ac9bd0c016464d9b2c8b.tar.gz"; + sha256 = "1nwf90bnzqhlgs007gg6xpx0vf4r1d19586nld78ipi1ch7nz4px"; + }; + meta = with lib; { + description = "Lf file manager for Neovim (in Lua)"; + homepage = "https://github.com/lmburns/lf.nvim"; + license = with licenses; [mit]; + }; + }; + /* + Generated from: nvim-telescope/telescope-bibtex.nvim + */ + telescope-bibtex-nvim = buildVimPlugin { + pname = "telescope-bibtex-nvim"; + version = "2024-03-28"; + src = fetchurl { + url = "https://github.com/nvim-telescope/telescope-bibtex.nvim/archive/289a6f86ebec06e8ae1590533b732b9981d84900.tar.gz"; + sha256 = "1sd6p8cvv3dckgrhc7grlyfcibjxhxbfyh0w7p5m4mdcazhy1kqs"; + }; + meta = with lib; { + description = "A telescope.nvim extension to search and paste bibtex entries into your TeX files."; + homepage = "https://github.com/nvim-telescope/telescope-bibtex.nvim"; + license = with licenses; [mit]; + }; + }; +} diff --git a/pkgs/sources/plgs-pkgs/plugins/manifest.txt b/pkgs/sources/plgs-pkgs/plugins/manifest.txt new file mode 100644 index 00000000..615083c8 --- /dev/null +++ b/pkgs/sources/plgs-pkgs/plugins/manifest.txt @@ -0,0 +1,3 @@ +lmburns/lf.nvim +nvim-telescope/telescope-bibtex.nvim +ThePrimeagen/harpoon:master diff --git a/pkgs/sources/plgs-pkgs/plugins/plugins.md b/pkgs/sources/plgs-pkgs/plugins/plugins.md new file mode 100644 index 00000000..4f73f811 --- /dev/null +++ b/pkgs/sources/plgs-pkgs/plugins/plugins.md @@ -0,0 +1,7 @@ +- Plugin count: 3 + +| Repo | Last Update | Nix package name | Last checked | +|:---|:---|:---|:---| +| [ThePrimeagen/harpoon:master](https://github.com/ThePrimeagen/harpoon) | 2023-12-26 | `harpoon` | 2024-05-09 | +| [lmburns/lf.nvim](https://github.com/lmburns/lf.nvim) | 2023-10-03 | `lf-nvim` | 2024-05-09 | +| [nvim-telescope/telescope-bibtex.nvim](https://github.com/nvim-telescope/telescope-bibtex.nvim) | 2024-03-28 | `telescope-bibtex-nvim` | 2024-05-09 | diff --git a/pkgs/sources/plgs-pkgs/plugins/whitelist.txt b/pkgs/sources/plgs-pkgs/plugins/whitelist.txt new file mode 100644 index 00000000..e69de29b diff --git a/pkgs/sources/plgs-pkgs/update.sh b/pkgs/sources/plgs-pkgs/update.sh new file mode 100755 index 00000000..6a0d3452 --- /dev/null +++ b/pkgs/sources/plgs-pkgs/update.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env sh + +BASE_DIR="$(readlink -f "$(dirname "$0")/plugins")" + +# Fetch plugins +cd "$BASE_DIR" || (echo "BUG: No '$BASE_DIR'" && exit 1) + +# Cleanup manifest +sort -o "$BASE_DIR/manifest.txt" "$BASE_DIR/manifest.txt" +sort -o "$BASE_DIR/blacklist.txt" "$BASE_DIR/blacklist.txt" +## Remove all plugins, which are on the blacklist +# The same file is read and written to +# shellcheck disable=SC2005 +echo "$(comm -23 "$BASE_DIR/manifest.txt" "$BASE_DIR/blacklist.txt")" >"$BASE_DIR/manifest.txt" + +# Backup vim-plugins.nix +mv "$BASE_DIR/default.nix" "$BASE_DIR/default.nix.bak" +echo "{...} : {}" >"$BASE_DIR/default.nix" + +# Generate derivations for new plugins (this binary is provided by the dev-environment) +update-vim-plugins cleanup "$BASE_DIR" + +# Restore vim-plugins.nix +mv "$BASE_DIR/default.nix.bak" "$BASE_DIR/default.nix" + +# Update new plugins +update-vim-plugins update "$BASE_DIR" --all -- cgit 1.4.1