浏览代码

nixpkgs/neovim: redo package pinning

Thomas Dy 2 年之前
父节点
当前提交
8cbbc42b23

+ 5 - 1
.config/nixpkgs/neovim/neovim.nix

@@ -69,7 +69,11 @@ let
       vimPlugins.playground
     ];
 
-  plugins = (import ./plugins.nix { inherit buildNeovimPlugin fetchFromGitHub; })
+  pinnedPlugins = import ./plugins {
+    inherit buildNeovimPlugin fetchFromGitHub;
+  };
+
+  plugins = (lib.attrValues pinnedPlugins)
     ++ nixpkgsPlugins
     ++ [
       extra-treesitter-textobjects

+ 0 - 202
.config/nixpkgs/neovim/plugins.nix

@@ -1,202 +0,0 @@
-{ buildNeovimPlugin, fetchFromGitHub }:
-
-[
-  (buildNeovimPlugin {
-    name = "vim-sleuth";
-    src = fetchFromGitHub {
-      owner = "tpope";
-      repo = "vim-sleuth";
-      rev = "1cc4557420f215d02c4d2645a748a816c220e99b";
-      sha256 = "0l8mw3r6lb6q1p3afvf5psp6cg8vdi84b5j8whmdm83f4mynsn8a";
-    };
-
-    dontBuild = true;
-  })
-  (buildNeovimPlugin {
-    name = "vim-fugitive";
-    src = fetchFromGitHub {
-      owner = "tpope";
-      repo = "vim-fugitive";
-      rev = "2febbe1f00be04f16daa6464cb39214a8566ec4b";
-      sha256 = "0njzhsn5xlwjcgr6nkm8pds4rby46dldl0b25dwj2bj6nyydaa23";
-    };
-
-    dontBuild = true;
-  })
-  (buildNeovimPlugin {
-    name = "vim-rhubarb";
-    src = fetchFromGitHub {
-      owner = "tpope";
-      repo = "vim-rhubarb";
-      rev = "cad60fe382f3f501bbb28e113dfe8c0de6e77c75";
-      sha256 = "1c456ypxgjnmbprjl79kvg5vm26nws0csw8fbs6gmdr21m3x1p4w";
-    };
-
-    dontBuild = true;
-  })
-  (buildNeovimPlugin {
-    name = "vim-abolish";
-    src = fetchFromGitHub {
-      owner = "tpope";
-      repo = "vim-abolish";
-      rev = "aa3428b734ddbd0105615832843f619774a6871e";
-      sha256 = "0dnv1ixhzrgafd7kqpx8hp0r1snyqfxw80psnbxsr6qcwzawb2da";
-    };
-
-    dontBuild = true;
-  })
-  (buildNeovimPlugin {
-    name = "undotree";
-    src = fetchFromGitHub {
-      owner = "mbbill";
-      repo = "undotree";
-      rev = "1a23ea84bd02c34f50d8e10a8b4bfc89597ffe4e";
-      sha256 = "00r0jnsrqdfns08ndj3xhwfx3yf65dgsin9pihad64gj9fmwvbv3";
-    };
-
-    dontBuild = true;
-  })
-  (buildNeovimPlugin {
-    name = "treesj";
-    src = fetchFromGitHub {
-      owner = "Wansmer";
-      repo = "treesj";
-      rev = "15a2262dfcd7848fbafa5afea8adec3941b83c12";
-      sha256 = "1jv13wvg6jcca3cw5swirna0jq5m3mj0pq7q113cpy11hd74bzh7";
-    };
-
-    dontBuild = true;
-  })
-  (buildNeovimPlugin {
-    name = "telescope.nvim";
-    src = fetchFromGitHub {
-      owner = "nvim-telescope";
-      repo = "telescope.nvim";
-      rev = "dce1156ca103b8222e4abbfc63f9c6887abf5ec6";
-      sha256 = "194jkn7a4xh5733n8n1n8n9mwibvadkxj6vw44xvwd01w0db6zhx";
-    };
-
-    dontBuild = true;
-  })
-  (buildNeovimPlugin {
-    name = "telescope-fzf-native.nvim";
-    src = fetchFromGitHub {
-      owner = "nvim-telescope";
-      repo = "telescope-fzf-native.nvim";
-      rev = "fab3e2212e206f4f8b3bbaa656e129443c9b802e";
-      sha256 = "0paiaag3aazfv8rr0i43maq34pn3iga3lkjyllhfysqvdm8jk50f";
-    };
-
-    dontBuild = false;
-  })
-  (buildNeovimPlugin {
-    name = "plenary.nvim";
-    src = fetchFromGitHub {
-      owner = "nvim-lua";
-      repo = "plenary.nvim";
-      rev = "1c7e3e6b0f4dd5a174fcea9fda8a4d7de593b826";
-      sha256 = "12hp9a2q80hg93ynfa97v03fmxqwv4d6f1yb92bi6ih3kbjyjsji";
-    };
-
-    dontBuild = true;
-  })
-  (buildNeovimPlugin {
-    name = "mini.nvim";
-    src = fetchFromGitHub {
-      owner = "echasnovski";
-      repo = "mini.nvim";
-      rev = "91017a96693408ef96efe9a2513c6ace0a87dc8d";
-      sha256 = "0xhc2npbpz7rhlis9cchda5pg7j5qkfxqb9qjsk86cxga1ma0c8r";
-    };
-
-    dontBuild = true;
-  })
-  (buildNeovimPlugin {
-    name = "gitsigns.nvim";
-    src = fetchFromGitHub {
-      owner = "lewis6991";
-      repo = "gitsigns.nvim";
-      rev = "addd6e174a85fc1c4007ab0b65d77e6555b417bf";
-      sha256 = "09gnk8szbdxc26g46hyjw6zb41i9nswz7pxcadmx9x2f0j9sma3m";
-    };
-
-    dontBuild = true;
-  })
-  (buildNeovimPlugin {
-    name = "nvim-lspconfig";
-    src = fetchFromGitHub {
-      owner = "neovim";
-      repo = "nvim-lspconfig";
-      rev = "d228bcf7cd94611929482a09e114a42c41fe81a8";
-      sha256 = "0ad4yb1j6pizvy3fa4d9b7lzq5nv2pipb19fg6wz6xv62xymdly6";
-    };
-
-    dontBuild = true;
-  })
-  (buildNeovimPlugin {
-    name = "nvim-treesitter-textobjects";
-    src = fetchFromGitHub {
-      owner = "nvim-treesitter";
-      repo = "nvim-treesitter-textobjects";
-      rev = "2fb97bd6c53d78517d2022a0b84422c18ce5686e";
-      sha256 = "0wwzmkkdw3n2agxsclaniblwfjaqwav7vyd5w0fjcqvqjim4jd9d";
-    };
-
-    dontBuild = true;
-  })
-  (buildNeovimPlugin {
-    name = "typescript.nvim";
-    src = fetchFromGitHub {
-      owner = "jose-elias-alvarez";
-      repo = "typescript.nvim";
-      rev = "f66d4472606cb24615dfb7dbc6557e779d177624";
-      sha256 = "1hm87jpscv250x8hv3vacw0sdhkwa81x21cxyvc6nf2vsbj5hx9w";
-    };
-
-    dontBuild = true;
-  })
-  (buildNeovimPlugin {
-    name = "null-ls.nvim";
-    src = fetchFromGitHub {
-      owner = "jose-elias-alvarez";
-      repo = "null-ls.nvim";
-      rev = "7bd74a821d991057ca1c0ca569d8252c4f89f860";
-      sha256 = "0frzqsgca6lsracz1ybz1zj9150clgs2y7xj6nkgmzn2f8h20kr2";
-    };
-
-    dontBuild = true;
-  })
-  (buildNeovimPlugin {
-    name = "fidget.nvim";
-    src = fetchFromGitHub {
-      owner = "j-hui";
-      repo = "fidget.nvim";
-      rev = "44585a0c0085765195e6961c15529ba6c5a2a13b";
-      sha256 = "112mjmy2nrqwj3l9dp3gzxsygaidcdrz2l6vzn27k1a57a7jyb8l";
-    };
-
-    dontBuild = true;
-  })
-  (buildNeovimPlugin {
-    name = "sonokai";
-    src = fetchFromGitHub {
-      owner = "sainnhe";
-      repo = "sonokai";
-      rev = "e2e89497f178bec568a0a43cda651f0429ec8ec1";
-      sha256 = "0dh5dsn8znhxsdr9plxa2mchlnfbgrvalc5pnz2wdsc2adz37521";
-    };
-
-    dontBuild = true;
-  })
-  (buildNeovimPlugin {
-    name = "vim-nix";
-    src = fetchFromGitHub {
-      owner = "LnL7";
-      repo = "vim-nix";
-      rev = "7d23e97d13c40fcc6d603b291fe9b6e5f92516ee";
-      hash = "sha256-W6ExP+iDNo5T8XazxHRpUiECGv+AU5PPoM4CmU7NV+0=";
-    };
-
-    dontBuild = true;
-  })
-]

+ 27 - 0
.config/nixpkgs/neovim/plugins/default.nix

@@ -0,0 +1,27 @@
+{ fetchFromGitHub, buildNeovimPlugin }:
+let
+  plugins = builtins.fromJSON (builtins.readFile ./sources.json);
+
+  overrides = {
+    "nvim-telescope/telescope-fzf-native.nvim" = {
+      dontBuild = false;
+    };
+  };
+
+  buildPlugin = name: spec:
+    let
+      nameParts = builtins.split "/" name;
+      owner = builtins.head nameParts;
+      repo = builtins.elemAt nameParts 2;
+    in
+    buildNeovimPlugin ({
+      name = repo;
+
+      src = fetchFromGitHub (spec // {
+        inherit owner repo;
+      });
+
+      dontBuild = true;
+    } // (overrides.${name} or {}));
+in
+builtins.mapAttrs buildPlugin plugins

+ 74 - 0
.config/nixpkgs/neovim/plugins/sources.json

@@ -0,0 +1,74 @@
+{
+  "tpope/vim-sleuth": {
+    "rev": "1cc4557420f215d02c4d2645a748a816c220e99b",
+    "sha256": "0l8mw3r6lb6q1p3afvf5psp6cg8vdi84b5j8whmdm83f4mynsn8a"
+  },
+  "tpope/vim-fugitive": {
+    "rev": "2febbe1f00be04f16daa6464cb39214a8566ec4b",
+    "sha256": "0njzhsn5xlwjcgr6nkm8pds4rby46dldl0b25dwj2bj6nyydaa23"
+  },
+  "tpope/vim-rhubarb": {
+    "rev": "cad60fe382f3f501bbb28e113dfe8c0de6e77c75",
+    "sha256": "1c456ypxgjnmbprjl79kvg5vm26nws0csw8fbs6gmdr21m3x1p4w"
+  },
+  "tpope/vim-abolish": {
+    "rev": "d55c90d6c9995ccb79d2152564a4939cd84d73e9",
+    "sha256": "0vfhjv7jpx15lqd6kf7jds5x5x4x5gj9cbr5rgm0cbbcn2734gji"
+  },
+  "mbbill/undotree": {
+    "rev": "1a23ea84bd02c34f50d8e10a8b4bfc89597ffe4e",
+    "sha256": "00r0jnsrqdfns08ndj3xhwfx3yf65dgsin9pihad64gj9fmwvbv3"
+  },
+  "Wansmer/treesj": {
+    "rev": "2723d63aed0ca4564565cc2949e0d6d2bc2b8287",
+    "sha256": "1bxzww9qxb442ch3i7m4bw58hn3l9lzckr0vnqp9hh55vqh7c3xk"
+  },
+  "nvim-telescope/telescope.nvim": {
+    "rev": "203bf5609137600d73e8ed82703d6b0e320a5f36",
+    "sha256": "1h64qyvvnzv7ph49vciv2izv9ws7ds1z9cncrmxs7jwlh3vv10ig"
+  },
+  "nvim-telescope/telescope-fzf-native.nvim": {
+    "rev": "fab3e2212e206f4f8b3bbaa656e129443c9b802e",
+    "sha256": "0paiaag3aazfv8rr0i43maq34pn3iga3lkjyllhfysqvdm8jk50f"
+  },
+  "nvim-lua/plenary.nvim": {
+    "rev": "9a0d3bf7b832818c042aaf30f692b081ddd58bd9",
+    "sha256": "1xy4hs0pckzbxd249zwg2r0vi94fy9arb966nypw1dx4vxw8072z"
+  },
+  "echasnovski/mini.nvim": {
+    "rev": "4f97a8771a480bcacf1d1d0dbf82e47f682aba2c",
+    "sha256": "1pnivvwh9bfddmqvzgs4qsc3qy2m8j4zk31d5l6dgz8bfp45c7w1"
+  },
+  "lewis6991/gitsigns.nvim": {
+    "rev": "ec4742a7eebf68bec663041d359b95637242b5c3",
+    "sha256": "18bwp15m2v4mrxp9i2vz061cfpv3ah08c8il3fx24aqhfbmaq6lz"
+  },
+  "neovim/nvim-lspconfig": {
+    "rev": "902d6aa31450d26e11bedcbef8af5b6fe2e1ffe8",
+    "sha256": "1hmkm3znqm7c6fi0qai1i424qjm5b9dh9l0srzyy7cax3629yyfr"
+  },
+  "nvim-treesitter/nvim-treesitter-textobjects": {
+    "rev": "249d90a84df63f3ffff65fcc06a45d58415672de",
+    "sha256": "01wm4gnwimsxgvdhjgn15d23nq6d1304jjvkr1wdjz7xk5g0xvaz"
+  },
+  "jose-elias-alvarez/typescript.nvim": {
+    "rev": "f66d4472606cb24615dfb7dbc6557e779d177624",
+    "sha256": "1hm87jpscv250x8hv3vacw0sdhkwa81x21cxyvc6nf2vsbj5hx9w"
+  },
+  "jose-elias-alvarez/null-ls.nvim": {
+    "rev": "8f5d730021497233c39d3adbf4b8043d4be163f8",
+    "sha256": "0isrsbba9clpjjx5z37p4d0s8fasd7gxr1gxxjsvgkp2yn7blvi0"
+  },
+  "j-hui/fidget.nvim": {
+    "rev": "44585a0c0085765195e6961c15529ba6c5a2a13b",
+    "sha256": "112mjmy2nrqwj3l9dp3gzxsygaidcdrz2l6vzn27k1a57a7jyb8l"
+  },
+  "sainnhe/sonokai": {
+    "rev": "c55985d5df53751a44fc532a53bed3be9f3b0d14",
+    "sha256": "0jmwsdpmj01g78gkv4cc7l5fxxhxrzlx2lkwmj5r9klkx07fpsrg"
+  },
+  "LnL7/vim-nix": {
+    "rev": "7d23e97d13c40fcc6d603b291fe9b6e5f92516ee",
+    "sha256": "1vaprm79j0nfl37r6lw0zwd048ajd5sc9cvny59qwdl3x0zk38av"
+  }
+}

+ 47 - 0
.config/nixpkgs/neovim/plugins/update.sh

@@ -0,0 +1,47 @@
+#!/usr/bin/env bash
+# shellcheck disable=SC2016
+
+set -euo pipefail
+
+plugins=$(< sources.json)
+
+q() {
+  jq -r "$@" <<<"$plugins"
+}
+
+u() {
+  plugins=$(jq "$@" <<<"$plugins")
+}
+
+update_plugin() {
+  name=$1
+  branch=$(q --arg name "$name" '.[$name].branch // "HEAD"')
+
+  echo "Updating $name" >&2
+  revision=$(git ls-remote "https://github.com/$name" "$branch" | cut -b -40)
+  sha256=$(nix-prefetch-url --unpack "https://github.com/$name/archive/$revision.tar.gz")
+
+  u --arg name "$name" --arg rev "$revision" --arg sha256 "$sha256" '
+    .[$name] = (.[$name] // {}) * {
+      rev: $rev,
+      sha256: $sha256,
+    }
+  '
+}
+
+update_all() {
+  for plugin in $(q 'to_entries | .[] | .key'); do
+    update_plugin "$plugin"
+  done
+}
+
+if [ "$#" -eq 0 ]; then
+  update_all
+else
+  while [ "$#" -gt 0 ]; do
+    update_plugin "$1"
+    shift
+  done
+fi
+
+echo "$plugins" > sources.json

+ 0 - 52
.config/nixpkgs/neovim/update.sh

@@ -1,52 +0,0 @@
-#!/usr/bin/env bash
-
-add_plugin() {
-  owner=$1
-  repo=$2
-  branch=${3:-HEAD}
-  dont_build=${4:-true}
-
-  echo "Updating $owner/$repo" >&2
-  revision=$(git ls-remote "https://github.com/$owner/$repo" "$branch" | cut -b -40)
-  sha256=$(nix-prefetch-url --unpack "https://github.com/$owner/$repo/archive/$revision.tar.gz")
-
-  cat <<EOF
-  (buildNeovimPlugin {
-    name = "$repo";
-    src = fetchFromGitHub {
-      owner = "$owner";
-      repo = "$repo";
-      rev = "$revision";
-      sha256 = "$sha256";
-    };
-
-    dontBuild = $dont_build;
-  })
-EOF
-}
-
-echo "{ buildNeovimPlugin, fetchFromGitHub }:
-
-["
-
-add_plugin tpope vim-sleuth
-add_plugin tpope vim-fugitive
-add_plugin tpope vim-rhubarb
-add_plugin tpope vim-abolish
-add_plugin mbbill undotree
-add_plugin Wansmer treesj
-add_plugin nvim-telescope telescope.nvim
-add_plugin nvim-telescope telescope-fzf-native.nvim HEAD false
-add_plugin nvim-lua plenary.nvim
-add_plugin echasnovski mini.nvim
-add_plugin lewis6991 gitsigns.nvim
-add_plugin neovim nvim-lspconfig
-add_plugin nvim-treesitter nvim-treesitter-textobjects
-add_plugin jose-elias-alvarez typescript.nvim
-add_plugin jose-elias-alvarez null-ls.nvim
-add_plugin j-hui fidget.nvim
-add_plugin sainnhe sonokai
-# still useful for commentstring + indentation
-add_plugin LnL7 vim-nix
-
-echo "]"