Skip to content

Commit

Permalink
treewide: Use nixpkgs fetchers for npins
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerg-L committed Feb 6, 2025
1 parent b049b79 commit acb2f7b
Show file tree
Hide file tree
Showing 10 changed files with 302 additions and 319 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ trim_trailing_whitespace = unset

[*.lock]
indent_size = unset

[/npins/sources.json]
end_of_line = unset
3 changes: 3 additions & 0 deletions .github/typos.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@

default.extend-ignore-words-re = ["(?i)(noice)", "befores", "annote", "viw"]
files.extend-exclude = [
"npins/sources.json"
]
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
''
self.nixosModules.nvf;
};

pins = import ./npins;
};

perSystem = {pkgs, ...}: {
Expand All @@ -62,6 +60,8 @@
# syntax elements and results in unreadable code.
formatter = pkgs.alejandra;

legacyPackages.pins = pkgs.callPackages ./npins/sources.nix {};

# Check if codebase is properly formatted.
# This can be initiated with `nix build .#checks.<system>.nix-fmt`
# or with `nix flake check`
Expand Down
13 changes: 4 additions & 9 deletions lib/types/plugins.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
{
self,
inputs,
lib,
...
}: let
{lib, ...}: let
inherit (lib.options) mkOption;
inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair;
inherit (lib.strings) hasPrefix removePrefix replaceStrings toLower;
inherit (lib.strings) hasPrefix removePrefix;
inherit (lib.types) submodule either package enum str lines anything listOf nullOr;

# Get the names of all flake inputs that start with the given prefix.
Expand All @@ -16,8 +11,8 @@
}:
mapAttrs' (n: v: nameValuePair (removePrefix prefix n) {src = v;}) (filterAttrs (n: _: hasPrefix prefix n) inputs);

# Get the names of all flake inputs that start with the given prefix.
pluginInputNames = map (pin: replaceStrings ["." "_"] ["-" "-"] (toLower pin)) (attrNames self.pins);
# Get the names of all npins
pluginInputNames = attrNames (lib.importJSON ../../npins/sources.json).pins;

# You can either use the name of the plugin or a package.
pluginType = nullOr (
Expand Down
2 changes: 1 addition & 1 deletion modules/plugins/lsp/trouble/config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ in {
config = mkIf (cfg.enable && cfg.trouble.enable) {
vim = {
lazy.plugins.trouble = {
package = "trouble-nvim";
package = "trouble";
setupModule = "trouble";
inherit (cfg.trouble) setupOpts;

Expand Down
2 changes: 1 addition & 1 deletion modules/plugins/utility/telescope/config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ in {
startPlugins = ["plenary-nvim"];

lazy.plugins.telescope = {
package = "telescope-nvim";
package = "telescope";
setupModule = "telescope";
inherit (cfg) setupOpts;

Expand Down
8 changes: 4 additions & 4 deletions modules/wrapper/build/config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
vimOptions = config.vim;

noBuildPlug = pname: let
pin = self.pins.${pname};
pin = self.legacyPackages.${pkgs.stdenv.system}.pins.${pname};
version = pin.revision or "dirty";
in {
# vim.lazy.plugins relies on pname, so we only set that here
Expand All @@ -33,12 +33,12 @@
# if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug
# instead
buildPlug = attrs: let
input = inputs."plugin-${attrs.pname}";
pin = self.legacyPackages.${pkgs.stdenv.system}.pins.${attrs.pname};
in
pkgs.vimUtils.buildVimPlugin (
{
version = input.shortRev or input.shortDirtyRev or "dirty";
src = input.outPath;
version = pin.revision or "dirty";
src = pin.outPath;
}
// attrs
);
Expand Down
80 changes: 0 additions & 80 deletions npins/default.nix

This file was deleted.

Loading

0 comments on commit acb2f7b

Please sign in to comment.