Skip to content

Commit 63032ea

Browse files
committed
treewide: Use nixpkgs fetchers for npins
1 parent b049b79 commit 63032ea

File tree

22 files changed

+480
-493
lines changed

22 files changed

+480
-493
lines changed

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,6 @@ trim_trailing_whitespace = unset
2626

2727
[*.lock]
2828
indent_size = unset
29+
30+
[npins/sources.json]
31+
insert_final_newline = unset

.github/typos.toml

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11

22
default.extend-ignore-words-re = ["(?i)(noice)", "befores", "annote", "viw"]
3+
files.extend-exclude = [
4+
"npins/sources.json"
5+
]

docs/manual/configuring.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
```{=include=} chapters
44
configuring/custom-package.md
55
configuring/custom-plugins.md
6-
configuring/custom-inputs.md
6+
configuring/overriding-plugins.md
77
configuring/languages.md
88
configuring/dags.md
99
configuring/dag-entries.md

docs/manual/configuring/custom-inputs.md

-53
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Overriding plugins {#ch-overriding-plugins}
2+
3+
The [additional plugins section](#sec-additional-plugins) details the addition
4+
of new plugins to nvf under regular circumstances, i.e. while making a pull
5+
request to the project. You may _override_ those plugins in your config
6+
to change source versions, e.g., to use newer versions of plugins
7+
that are not yet updated in **nvf**.
8+
9+
```nix
10+
vim.pluginOverrides = {
11+
lazydev-nvim = pkgs.fetchFromGitHub {
12+
owner = "folke";
13+
repo = "lazydev.nvim";
14+
rev = "";
15+
hash = "";
16+
};
17+
# It's also possible to use a flake input
18+
lazydev-nvim = inputs.lazydev-nvim;
19+
# Or a local path
20+
lazydev-nvim = ./lazydev;
21+
# Or a npins pin... etc
22+
};
23+
```
24+
25+
This will override the source for the `neodev.nvim` plugin that is used in nvf
26+
with your own plugin.
27+
28+
::: {.warning}
29+
30+
While updating plugin inputs, make sure that any configuration that has been
31+
deprecated in newer versions is changed in the plugin's `setupOpts`. If you
32+
depend on a new version, requesting a version bump in the issues section is a
33+
more reliable option.
34+
35+
:::

docs/manual/hacking/additional-plugins.md

+14-25
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,25 @@
11
# Adding Plugins {#sec-additional-plugins}
22

3-
To add a new Neovim plugin, first add the source url in the inputs section of
4-
`flake.nix` with the prefix `plugin-`
3+
To add a new Neovim plugin, use `npins`
54

6-
```nix
7-
{
8-
inputs = {
9-
# ...
10-
plugin-neodev-nvim = {
11-
url = "github:folke/neodev.nvim";
12-
flake = false;
13-
};
14-
# ...
15-
};
16-
}
17-
```
5+
Use:
6+
7+
`nix-shell -p npins` or `nix shell nixpkgs#npins`
8+
9+
Then run:
10+
11+
`npins --name <plugin name> github <owner> <repo> -b <branch>`
12+
13+
Be sure to replace any non-alphanumeric characters with `-` for `--name`
1814

19-
Prepending `plugin-` to the name of the input will allow nvf to automatically
20-
discover inputs that are marked as plugins, and make them available in
21-
`vim.startPlugins` or other areas that require a very specific plugin type as it
22-
is defined in `@NVF_REPO@/lib/types/plugins.nix`
15+
For example
2316

24-
The addition of the `plugin-` prefix will allow **nvf** to autodiscover the
25-
input from the flake inputs automatically, allowing you to refer to it in areas
26-
that require a very specific plugin type as defined in `lib/types/plugins.nix`
17+
`npins --name lazydev-nvim github folke laztdev.nvim -b main`
2718

28-
You can now reference this plugin using its string name, the plugin will be
29-
built with the name and source URL from the flake input, allowing you to refer
30-
to it as a **string**.
19+
You can now reference this plugin as a **string**.
3120

3221
```nix
33-
config.vim.startPlugins = ["neodev-nvim"];
22+
config.vim.startPlugins = ["lazydev-nvim"];
3423
```
3524

3625
## Modular setup options {#sec-modular-setup-options}

docs/manual/installation/custom-configuration.md

+15-17
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@ An example flake that exposes your custom Neovim configuration might look like
2323
nvf.url = "github:notashelf/nvf";
2424
};
2525
26-
outputs = {
27-
self,
28-
nixpkgs,
29-
...
30-
} @ inputs: {
31-
packages."x86_64-linux" = let
32-
neovimConfigured = (inputs.nvf.lib.neovimConfiguration {
33-
inherit (nixpkgs.legacyPackages."x86_64-linux") pkgs;
34-
modules = [{
26+
outputs = {nixpkgs, ...} @ inputs: {
27+
packages.x86_64-linux = {
28+
# Set the default package to the wrapped instance of Neovim.
29+
# This will allow running your Neovim configuration with
30+
# `nix run` and in addition, sharing your configuration with
31+
# other users in case your repository is public.
32+
default =
33+
(inputs.nvf.lib.neovimConfiguration {
34+
pkgs = nixpkgs.legacyPackages.x86_64-linux;
35+
modules = [
36+
{
3537
config.vim = {
3638
# Enable custom theming options
3739
theme.enable = true;
@@ -43,14 +45,10 @@ An example flake that exposes your custom Neovim configuration might look like
4345
# reference in Appendix B of the nvf manual.
4446
# ...
4547
};
46-
}];
47-
});
48-
in {
49-
# Set the default package to the wrapped instance of Neovim.
50-
# This will allow running your Neovim configuration with
51-
# `nix run` and in addition, sharing your configuration with
52-
# other users in case your repository is public.
53-
default = neovimConfigured.neovim;
48+
}
49+
];
50+
})
51+
.neovim;
5452
};
5553
};
5654
}

docs/manual/installation/modules/home-manager.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,10 @@ Followed by importing the home-manager module somewhere in your configuration.
4949
nvf.url = "github:notashelf/nvf";
5050
};
5151
52-
outputs = { nixpkgs, home-manager, nvf, ... }: let
53-
system = "x86_64-linux";
54-
pkgs = nixpkgs.legacyPackages.${system};
55-
in {
52+
outputs = { nixpkgs, home-manager, nvf, ... }: {
5653
# ↓ this is your home output in the flake schema, expected by home-manager
5754
"your-username@your-hostname" = home-manager.lib.homeManagerConfiguration {
58-
inherit pkgs;
55+
pkgs = nixpkgs.legacyPackages.x86_64-linux;
5956
modules = [
6057
nvf.homeManagerModules.default # <- this imports the home-manager module that provides the options
6158
./home.nix # <- your home entrypoint, `programs.nvf.*` may be defined here

docs/manual/installation/standalone/nixos.md

+30-22
Original file line numberDiff line numberDiff line change
@@ -16,38 +16,46 @@ the default theme enabled. You may use other options inside `config.vim` in
1616
nvf.url = "github:notashelf/nvf";
1717
};
1818
19-
outputs = {nixpkgs, nvf, ...}: let
20-
system = "x86_64-linux";
21-
pkgs = nixpkgs.legacyPackages.${system};
22-
configModule = {
23-
# Add any custom options (and do feel free to upstream them!)
24-
# options = { ... };
25-
26-
config.vim = {
27-
theme.enable = true;
28-
# and more options as you see fit...
29-
};
30-
};
31-
32-
customNeovim = nvf.lib.neovimConfiguration {
33-
inherit pkgs;
34-
modules = [configModule];
35-
};
36-
in {
19+
outputs = {
20+
nixpkgs,
21+
nvf,
22+
self,
23+
...
24+
}: {
3725
# This will make the package available as a flake output under 'packages'
38-
packages.${system}.my-neovim = customNeovim.neovim;
26+
packages.x86_64-linux.my-neovim =
27+
(nvf.lib.neovimConfiguration {
28+
pkgs = nixpkgs.legacyPackages.x86_64-linux;
29+
modules = [
30+
# Or move this to a seperate file and add it's path here instead
31+
# IE: ./nvf_module.nix
32+
(
33+
{pkgs, ...}: {
34+
# Add any custom options (and do feel free to upstream them!)
35+
# options = { ... };
36+
config.vim = {
37+
theme.enable = true;
38+
# and more options as you see fit...
39+
};
40+
}
41+
)
42+
];
43+
})
44+
.neovim;
3945
4046
# Example nixosConfiguration using the configured Neovim package
4147
nixosConfigurations = {
4248
yourHostName = nixpkgs.lib.nixosSystem {
4349
# ...
4450
modules = [
4551
# This will make wrapped neovim available in your system packages
46-
{environment.systemPackages = [customNeovim.neovim];}
52+
# Can also move this to another config file if you pass inputs/self around with specialArgs
53+
({pkgs, ...}: {
54+
environment.systemPackages = [self.packages.${pkgs.stdenv.system}.neovim];
55+
})
4756
];
4857
# ...
4958
};
5059
};
5160
};
52-
}
53-
```
61+
}```

flake.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
self.nixosModules.nvf;
5353
};
5454

55-
pins = import ./npins;
55+
inherit (lib.importJSON ./npins/sources.json) pins;
5656
};
5757

5858
perSystem = {pkgs, ...}: {

flake/develop.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
default = self'.devShells.lsp;
1010
nvim-nix = pkgs.mkShellNoCC {packages = [config.packages.nix];};
1111
lsp = pkgs.mkShellNoCC {
12-
packages = with pkgs; [nil statix deadnix alejandra];
12+
packages = with pkgs; [nil statix deadnix alejandra npins];
1313
};
1414
};
1515

lib/default.nix

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
lib,
55
...
66
}: {
7-
types = import ./types {inherit self inputs lib;};
8-
7+
types = import ./types {inherit lib;};
98
config = import ./config.nix {inherit lib;};
109
binds = import ./binds.nix {inherit lib;};
1110
dag = import ./dag.nix {inherit lib;};

lib/types/default.nix

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
{
2-
self,
3-
inputs,
4-
lib,
5-
...
6-
}: let
1+
{lib}: let
72
typesDag = import ./dag.nix {inherit lib;};
8-
typesPlugin = import ./plugins.nix {inherit self inputs lib;};
3+
typesPlugin = import ./plugins.nix {inherit lib;};
94
typesLanguage = import ./languages.nix {inherit lib;};
105
customTypes = import ./custom.nix {inherit lib;};
116
in {

lib/types/plugins.nix

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1-
{
2-
self,
3-
inputs,
4-
lib,
5-
...
6-
}: let
1+
{lib}: let
72
inherit (lib.options) mkOption;
83
inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair;
9-
inherit (lib.strings) hasPrefix removePrefix replaceStrings toLower;
4+
inherit (lib.strings) hasPrefix removePrefix;
105
inherit (lib.types) submodule either package enum str lines anything listOf nullOr;
116

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

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

2217
# You can either use the name of the plugin or a package.
2318
pluginType = nullOr (

0 commit comments

Comments
 (0)