mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-10-31 11:02:37 +00:00 
			
		
		
		
	treewide: Use nixpkgs fetchers for npins
plugins: switch from neodev to lazydev
This commit is contained in:
		
					parent
					
						
							
								7510ef2c13
							
						
					
				
			
			
				commit
				
					
						8adc4c352a
					
				
			
		
					 32 changed files with 700 additions and 681 deletions
				
			
		|  | @ -26,3 +26,6 @@ trim_trailing_whitespace = unset | ||||||
| 
 | 
 | ||||||
| [*.lock] | [*.lock] | ||||||
| indent_size = unset | indent_size = unset | ||||||
|  | 
 | ||||||
|  | [npins/sources.json] | ||||||
|  | insert_final_newline = unset | ||||||
|  |  | ||||||
							
								
								
									
										3
									
								
								.github/typos.toml
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.github/typos.toml
									
										
									
									
										vendored
									
									
								
							|  | @ -1,2 +1,5 @@ | ||||||
| 
 | 
 | ||||||
| default.extend-ignore-words-re = ["(?i)(noice)", "befores", "annote", "viw"] | default.extend-ignore-words-re = ["(?i)(noice)", "befores", "annote", "viw"] | ||||||
|  | files.extend-exclude = [ | ||||||
|  | "npins/sources.json" | ||||||
|  | ] | ||||||
|  |  | ||||||
|  | @ -3,7 +3,7 @@ | ||||||
| ```{=include=} chapters | ```{=include=} chapters | ||||||
| configuring/custom-package.md | configuring/custom-package.md | ||||||
| configuring/custom-plugins.md | configuring/custom-plugins.md | ||||||
| configuring/custom-inputs.md | configuring/overriding-plugins.md | ||||||
| configuring/languages.md | configuring/languages.md | ||||||
| configuring/dags.md | configuring/dags.md | ||||||
| configuring/dag-entries.md | configuring/dag-entries.md | ||||||
|  |  | ||||||
|  | @ -1,53 +0,0 @@ | ||||||
| # Custom Inputs {#ch-custom-inputs} |  | ||||||
| 
 |  | ||||||
| One of the greatest strengths of **nvf** is its ability to get plugins from |  | ||||||
| flake inputs and build them locally from any given source. For plugins that do |  | ||||||
| not require any kind of additional building step, this is a powerful method of |  | ||||||
| adding plugins to your configuration that are not packaged in nixpkgs, or those |  | ||||||
| you want to track from source without relying on nixpkgs. |  | ||||||
| 
 |  | ||||||
| The [additional plugins section](#sec-additional-plugins) details the addition |  | ||||||
| of new plugins to nvf under regular circumstances, i.e. while making a pull |  | ||||||
| request to the project. You may _override_ those plugin inputs in your own |  | ||||||
| `flake.nix` to change source versions, e.g., to use newer versions of plugins |  | ||||||
| that are not yet updated in **nvf**. |  | ||||||
| 
 |  | ||||||
| ```nix |  | ||||||
| { |  | ||||||
| 
 |  | ||||||
|   inputs = { |  | ||||||
|     # ... |  | ||||||
| 
 |  | ||||||
|     # The name here is arbitrary, you can name it whatever. |  | ||||||
|     # This will add a plugin input called "your-neodev-input" |  | ||||||
|     # that you can reference in a `follows` line. |  | ||||||
|     your-neodev-input = { |  | ||||||
|       url = "github:folke/neodev.nvim"; |  | ||||||
|       flake = false; |  | ||||||
|     }; |  | ||||||
| 
 |  | ||||||
|     nvf = { |  | ||||||
|       url = "github:notashelf/nvf"; |  | ||||||
| 
 |  | ||||||
|       # The name of the input must match for the follows line |  | ||||||
|       # plugin-neodev-nvim is what the input is called inside nvf |  | ||||||
|       # so you must match the exact name here. |  | ||||||
|       inputs.plugin-neodev-nvim.follows = "your-neodev-input"; |  | ||||||
|     }; |  | ||||||
|     # ... |  | ||||||
|   }; |  | ||||||
| } |  | ||||||
| ``` |  | ||||||
| 
 |  | ||||||
| This will override the source for the `neodev.nvim` plugin that is used in nvf |  | ||||||
| with your own input. You can update your new input via `nix flake update` or |  | ||||||
| more specifically `nix flake update <name of your input>` to keep it up to date. |  | ||||||
| 
 |  | ||||||
| ::: {.warning} |  | ||||||
| 
 |  | ||||||
| While updating plugin inputs, make sure that any configuration that has been |  | ||||||
| deprecated in newer versions is changed in the plugin's `setupOpts`. If you |  | ||||||
| depend on a new version, requesting a version bump in the issues section is a |  | ||||||
| more reliable option. |  | ||||||
| 
 |  | ||||||
| ::: |  | ||||||
							
								
								
									
										35
									
								
								docs/manual/configuring/overriding-plugins.md
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								docs/manual/configuring/overriding-plugins.md
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,35 @@ | ||||||
|  | # Overriding plugins {#ch-overriding-plugins} | ||||||
|  | 
 | ||||||
|  | The [additional plugins section](#sec-additional-plugins) details the addition | ||||||
|  | of new plugins to nvf under regular circumstances, i.e. while making a pull | ||||||
|  | request to the project. You may _override_ those plugins in your config | ||||||
|  | to change source versions, e.g., to use newer versions of plugins | ||||||
|  | that are not yet updated in **nvf**. | ||||||
|  | 
 | ||||||
|  | ```nix | ||||||
|  | vim.pluginOverrides = { | ||||||
|  |   lazydev-nvim = pkgs.fetchFromGitHub { | ||||||
|  |     owner = "folke"; | ||||||
|  |     repo = "lazydev.nvim"; | ||||||
|  |     rev = ""; | ||||||
|  |     hash = ""; | ||||||
|  |   }; | ||||||
|  |  # It's also possible to use a flake input | ||||||
|  |  lazydev-nvim = inputs.lazydev-nvim; | ||||||
|  |  # Or a local path  | ||||||
|  |  lazydev-nvim = ./lazydev; | ||||||
|  |  # Or a npins pin... etc | ||||||
|  | }; | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | This will override the source for the `neodev.nvim` plugin that is used in nvf | ||||||
|  | with your own plugin. | ||||||
|  | 
 | ||||||
|  | ::: {.warning} | ||||||
|  | 
 | ||||||
|  | While updating plugin inputs, make sure that any configuration that has been | ||||||
|  | deprecated in newer versions is changed in the plugin's `setupOpts`. If you | ||||||
|  | depend on a new version, requesting a version bump in the issues section is a | ||||||
|  | more reliable option. | ||||||
|  | 
 | ||||||
|  | ::: | ||||||
|  | @ -1,36 +1,25 @@ | ||||||
| # Adding Plugins {#sec-additional-plugins} | # Adding Plugins {#sec-additional-plugins} | ||||||
| 
 | 
 | ||||||
| To add a new Neovim plugin, first add the source url in the inputs section of | To add a new Neovim plugin, use `npins` | ||||||
| `flake.nix` with the prefix `plugin-` | 
 | ||||||
|  | Use: | ||||||
|  | 
 | ||||||
|  | `nix-shell -p npins` or `nix shell nixpkgs#npins` | ||||||
|  | 
 | ||||||
|  | Then run: | ||||||
|  | 
 | ||||||
|  | `npins --name <plugin name> github <owner> <repo> -b <branch>` | ||||||
|  | 
 | ||||||
|  | Be sure to replace any non-alphanumeric characters with `-` for `--name` | ||||||
|  | 
 | ||||||
|  | For example  | ||||||
|  | 
 | ||||||
|  | `npins --name lazydev-nvim github folke laztdev.nvim -b main` | ||||||
|  | 
 | ||||||
|  | You can now reference this plugin as a **string**. | ||||||
| 
 | 
 | ||||||
| ```nix | ```nix | ||||||
| { | config.vim.startPlugins = ["lazydev-nvim"]; | ||||||
|   inputs = { |  | ||||||
|     # ... |  | ||||||
|     plugin-neodev-nvim = { |  | ||||||
|       url = "github:folke/neodev.nvim"; |  | ||||||
|       flake = false; |  | ||||||
|     }; |  | ||||||
|     # ... |  | ||||||
|   }; |  | ||||||
| } |  | ||||||
| ``` |  | ||||||
| 
 |  | ||||||
| Prepending `plugin-` to the name of the input will allow nvf to automatically |  | ||||||
| discover inputs that are marked as plugins, and make them available in |  | ||||||
| `vim.startPlugins` or other areas that require a very specific plugin type as it |  | ||||||
| is defined in `@NVF_REPO@/lib/types/plugins.nix` |  | ||||||
| 
 |  | ||||||
| The addition of the `plugin-` prefix will allow **nvf** to autodiscover the |  | ||||||
| input from the flake inputs automatically, allowing you to refer to it in areas |  | ||||||
| that require a very specific plugin type as defined in `lib/types/plugins.nix` |  | ||||||
| 
 |  | ||||||
| You can now reference this plugin using its string name, the plugin will be |  | ||||||
| built with the name and source URL from the flake input, allowing you to refer |  | ||||||
| to it as a **string**. |  | ||||||
| 
 |  | ||||||
| ```nix |  | ||||||
| config.vim.startPlugins = ["neodev-nvim"]; |  | ||||||
| ``` | ``` | ||||||
| 
 | 
 | ||||||
| ## Modular setup options {#sec-modular-setup-options} | ## Modular setup options {#sec-modular-setup-options} | ||||||
|  |  | ||||||
|  | @ -23,15 +23,17 @@ An example flake that exposes your custom Neovim configuration might look like | ||||||
|     nvf.url = "github:notashelf/nvf"; |     nvf.url = "github:notashelf/nvf"; | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   outputs = { |   outputs = {nixpkgs, ...} @ inputs: { | ||||||
|     self, |     packages.x86_64-linux = { | ||||||
|     nixpkgs, |       # Set the default package to the wrapped instance of Neovim. | ||||||
|     ... |       # This will allow running your Neovim configuration with | ||||||
|   } @ inputs: { |       # `nix run` and in addition, sharing your configuration with | ||||||
|     packages."x86_64-linux" = let |       # other users in case your repository is public. | ||||||
|         neovimConfigured = (inputs.nvf.lib.neovimConfiguration { |       default = | ||||||
|           inherit (nixpkgs.legacyPackages."x86_64-linux") pkgs; |         (inputs.nvf.lib.neovimConfiguration { | ||||||
|           modules = [{ |           pkgs = nixpkgs.legacyPackages.x86_64-linux; | ||||||
|  |           modules = [ | ||||||
|  |             { | ||||||
|               config.vim = { |               config.vim = { | ||||||
|                 # Enable custom theming options |                 # Enable custom theming options | ||||||
|                 theme.enable = true; |                 theme.enable = true; | ||||||
|  | @ -43,14 +45,10 @@ An example flake that exposes your custom Neovim configuration might look like | ||||||
|                 # reference in Appendix B of the nvf manual. |                 # reference in Appendix B of the nvf manual. | ||||||
|                 # ... |                 # ... | ||||||
|               }; |               }; | ||||||
|           }]; |             } | ||||||
|         }); |           ]; | ||||||
|     in { |         }) | ||||||
|       # Set the default package to the wrapped instance of Neovim. |         .neovim; | ||||||
|       # This will allow running your Neovim configuration with |  | ||||||
|       # `nix run` and in addition, sharing your configuration with |  | ||||||
|       # other users in case your repository is public. |  | ||||||
|       default = neovimConfigured.neovim; |  | ||||||
|     }; |     }; | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -49,13 +49,10 @@ Followed by importing the home-manager module somewhere in your configuration. | ||||||
|     nvf.url = "github:notashelf/nvf"; |     nvf.url = "github:notashelf/nvf"; | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   outputs = { nixpkgs, home-manager, nvf, ... }: let |   outputs = { nixpkgs, home-manager, nvf, ... }: { | ||||||
|     system = "x86_64-linux"; |  | ||||||
|     pkgs = nixpkgs.legacyPackages.${system}; |  | ||||||
|   in { |  | ||||||
|     # ↓ this is your home output in the flake schema, expected by home-manager |     # ↓ this is your home output in the flake schema, expected by home-manager | ||||||
|     "your-username@your-hostname" = home-manager.lib.homeManagerConfiguration { |     "your-username@your-hostname" = home-manager.lib.homeManagerConfiguration { | ||||||
|       inherit pkgs; |       pkgs = nixpkgs.legacyPackages.x86_64-linux; | ||||||
|       modules = [ |       modules = [ | ||||||
|         nvf.homeManagerModules.default # <- this imports the home-manager module that provides the options |         nvf.homeManagerModules.default # <- this imports the home-manager module that provides the options | ||||||
|         ./home.nix # <- your home entrypoint, `programs.nvf.*` may be defined here |         ./home.nix # <- your home entrypoint, `programs.nvf.*` may be defined here | ||||||
|  |  | ||||||
|  | @ -16,26 +16,32 @@ the default theme enabled. You may use other options inside `config.vim` in | ||||||
|     nvf.url = "github:notashelf/nvf"; |     nvf.url = "github:notashelf/nvf"; | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   outputs = {nixpkgs, nvf, ...}: let |   outputs = { | ||||||
|     system = "x86_64-linux"; |     nixpkgs, | ||||||
|     pkgs = nixpkgs.legacyPackages.${system}; |     nvf, | ||||||
|     configModule = { |     self, | ||||||
|  |     ... | ||||||
|  |   }: { | ||||||
|  |     # This will make the package available as a flake output under 'packages' | ||||||
|  |     packages.x86_64-linux.my-neovim = | ||||||
|  |       (nvf.lib.neovimConfiguration { | ||||||
|  |         pkgs = nixpkgs.legacyPackages.x86_64-linux; | ||||||
|  |         modules = [ | ||||||
|  |           # Or move this to a separate file and add it's path here instead | ||||||
|  |           # IE: ./nvf_module.nix | ||||||
|  |           ( | ||||||
|  |             {pkgs, ...}: { | ||||||
|               # Add any custom options (and do feel free to upstream them!) |               # Add any custom options (and do feel free to upstream them!) | ||||||
|               # options = { ... }; |               # options = { ... }; | ||||||
| 
 |  | ||||||
|               config.vim = { |               config.vim = { | ||||||
|                 theme.enable = true; |                 theme.enable = true; | ||||||
|                 # and more options as you see fit... |                 # and more options as you see fit... | ||||||
|               }; |               }; | ||||||
|     }; |             } | ||||||
| 
 |           ) | ||||||
|     customNeovim = nvf.lib.neovimConfiguration { |         ]; | ||||||
|       inherit pkgs; |       }) | ||||||
|       modules = [configModule]; |       .neovim; | ||||||
|     }; |  | ||||||
|   in { |  | ||||||
|     # This will make the package available as a flake output under 'packages' |  | ||||||
|     packages.${system}.my-neovim = customNeovim.neovim; |  | ||||||
| 
 | 
 | ||||||
|     # Example nixosConfiguration using the configured Neovim package |     # Example nixosConfiguration using the configured Neovim package | ||||||
|     nixosConfigurations = { |     nixosConfigurations = { | ||||||
|  | @ -43,11 +49,13 @@ the default theme enabled. You may use other options inside `config.vim` in | ||||||
|         # ... |         # ... | ||||||
|         modules = [ |         modules = [ | ||||||
|           # This will make wrapped neovim available in your system packages |           # This will make wrapped neovim available in your system packages | ||||||
|           {environment.systemPackages = [customNeovim.neovim];} |           # Can also move this to another config file if you pass inputs/self around with specialArgs | ||||||
|  |           ({pkgs, ...}: { | ||||||
|  |             environment.systemPackages = [self.packages.${pkgs.stdenv.system}.neovim]; | ||||||
|  |           }) | ||||||
|         ]; |         ]; | ||||||
|         # ... |         # ... | ||||||
|       }; |       }; | ||||||
|     }; |     }; | ||||||
|   }; |   }; | ||||||
| } | }``` | ||||||
| ``` |  | ||||||
|  |  | ||||||
							
								
								
									
										17
									
								
								flake.lock
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										17
									
								
								flake.lock
									
										
									
										generated
									
									
									
								
							|  | @ -1,5 +1,21 @@ | ||||||
| { | { | ||||||
|   "nodes": { |   "nodes": { | ||||||
|  |     "blink-cmp": { | ||||||
|  |       "flake": false, | ||||||
|  |       "locked": { | ||||||
|  |         "lastModified": 1739129359, | ||||||
|  |         "narHash": "sha256-nUrXXiJ7NRxS21H53U323lwEKdo08Y011l8XskXC/vw=", | ||||||
|  |         "owner": "saghen", | ||||||
|  |         "repo": "blink.cmp", | ||||||
|  |         "rev": "b2485c76cb7877de6fe9c8670af59ba3d72fd74d", | ||||||
|  |         "type": "github" | ||||||
|  |       }, | ||||||
|  |       "original": { | ||||||
|  |         "owner": "saghen", | ||||||
|  |         "repo": "blink.cmp", | ||||||
|  |         "type": "github" | ||||||
|  |       } | ||||||
|  |     }, | ||||||
|     "flake-parts": { |     "flake-parts": { | ||||||
|       "inputs": { |       "inputs": { | ||||||
|         "nixpkgs-lib": "nixpkgs-lib" |         "nixpkgs-lib": "nixpkgs-lib" | ||||||
|  | @ -121,6 +137,7 @@ | ||||||
|     }, |     }, | ||||||
|     "root": { |     "root": { | ||||||
|       "inputs": { |       "inputs": { | ||||||
|  |         "blink-cmp": "blink-cmp", | ||||||
|         "flake-parts": "flake-parts", |         "flake-parts": "flake-parts", | ||||||
|         "flake-utils": "flake-utils", |         "flake-utils": "flake-utils", | ||||||
|         "mnw": "mnw", |         "mnw": "mnw", | ||||||
|  |  | ||||||
|  | @ -7,7 +7,7 @@ | ||||||
|   } @ inputs: let |   } @ inputs: let | ||||||
|     # call the extended library with `inputs` |     # call the extended library with `inputs` | ||||||
|     # inputs is used to get the original standard library, and to pass inputs to the plugin autodiscovery function |     # inputs is used to get the original standard library, and to pass inputs to the plugin autodiscovery function | ||||||
|     lib = import ./lib/stdlib-extended.nix inputs; |     lib = import ./lib/stdlib-extended.nix {inherit inputs self;}; | ||||||
|   in |   in | ||||||
|     flake-parts.lib.mkFlake { |     flake-parts.lib.mkFlake { | ||||||
|       inherit inputs; |       inherit inputs; | ||||||
|  | @ -54,7 +54,7 @@ | ||||||
|             self.nixosModules.nvf; |             self.nixosModules.nvf; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         pins = import ./npins; |         inherit (lib.importJSON ./npins/sources.json) pins; | ||||||
|       }; |       }; | ||||||
| 
 | 
 | ||||||
|       perSystem = {pkgs, ...}: { |       perSystem = {pkgs, ...}: { | ||||||
|  | @ -98,5 +98,10 @@ | ||||||
|       inputs.nixpkgs.follows = "nixpkgs"; |       inputs.nixpkgs.follows = "nixpkgs"; | ||||||
|       inputs.flake-utils.follows = "flake-utils"; |       inputs.flake-utils.follows = "flake-utils"; | ||||||
|     }; |     }; | ||||||
|  | 
 | ||||||
|  |     blink-cmp = { | ||||||
|  |       url = "github:saghen/blink.cmp"; | ||||||
|  |       flake = false; | ||||||
|  |     }; | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -9,7 +9,7 @@ | ||||||
|       default = self'.devShells.lsp; |       default = self'.devShells.lsp; | ||||||
|       nvim-nix = pkgs.mkShellNoCC {packages = [config.packages.nix];}; |       nvim-nix = pkgs.mkShellNoCC {packages = [config.packages.nix];}; | ||||||
|       lsp = pkgs.mkShellNoCC { |       lsp = pkgs.mkShellNoCC { | ||||||
|         packages = with pkgs; [nil statix deadnix alejandra]; |         packages = with pkgs; [nil statix deadnix alejandra npins]; | ||||||
|       }; |       }; | ||||||
|     }; |     }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -14,8 +14,8 @@ | ||||||
|           # features as they are added. |           # features as they are added. | ||||||
|           nil = inputs'.nil.packages.default; |           nil = inputs'.nil.packages.default; | ||||||
|           blink-cmp = final.callPackage ./legacyPackages/blink-cmp.nix { |           blink-cmp = final.callPackage ./legacyPackages/blink-cmp.nix { | ||||||
|             src = inputs.plugin-blink-cmp; |             src = inputs.blink-cmp; | ||||||
|             version = inputs.plugin-blink-cmp.shortRev or inputs.plugin-blink-cmp.shortDirtyRev or "dirty"; |             version = inputs.blink-cmp.shortRev or inputs.blink-cmp.shortDirtyRev or "dirty"; | ||||||
|           }; |           }; | ||||||
|         }) |         }) | ||||||
|       ]; |       ]; | ||||||
|  |  | ||||||
|  | @ -1,10 +1,10 @@ | ||||||
| { | { | ||||||
|  |   self, | ||||||
|   inputs, |   inputs, | ||||||
|   lib, |   lib, | ||||||
|   ... |   ... | ||||||
| }: { | }: { | ||||||
|   types = import ./types {inherit inputs lib;}; |   types = import ./types {inherit lib;}; | ||||||
| 
 |  | ||||||
|   config = import ./config.nix {inherit lib;}; |   config = import ./config.nix {inherit lib;}; | ||||||
|   binds = import ./binds.nix {inherit lib;}; |   binds = import ./binds.nix {inherit lib;}; | ||||||
|   dag = import ./dag.nix {inherit lib;}; |   dag = import ./dag.nix {inherit lib;}; | ||||||
|  | @ -12,5 +12,5 @@ | ||||||
|   lists = import ./lists.nix {inherit lib;}; |   lists = import ./lists.nix {inherit lib;}; | ||||||
|   attrsets = import ./attrsets.nix {inherit lib;}; |   attrsets = import ./attrsets.nix {inherit lib;}; | ||||||
|   lua = import ./lua.nix {inherit lib;}; |   lua = import ./lua.nix {inherit lib;}; | ||||||
|   neovimConfiguration = import ../modules {inherit inputs lib;}; |   neovimConfiguration = import ../modules {inherit self inputs lib;}; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,6 +1,10 @@ | ||||||
| # Convenience function that returns the given Nixpkgs standard library | # Convenience function that returns the given Nixpkgs standard library | ||||||
| # extended with our functions using `lib.extend`. | # extended with our functions using `lib.extend`. | ||||||
| inputs: | { | ||||||
|  |   inputs, | ||||||
|  |   self, | ||||||
|  |   ... | ||||||
|  | } @ args: | ||||||
| inputs.nixpkgs.lib.extend (self: super: { | inputs.nixpkgs.lib.extend (self: super: { | ||||||
|   # WARNING: New functions should not be added here, but to files |   # WARNING: New functions should not be added here, but to files | ||||||
|   # imported by `./default.nix` under their own categories. If your |   # imported by `./default.nix` under their own categories. If your | ||||||
|  | @ -12,7 +16,7 @@ inputs.nixpkgs.lib.extend (self: super: { | ||||||
|   # E.g. for an input called `nvf`, `inputs.nvf.lib.nvim` will return the set |   # E.g. for an input called `nvf`, `inputs.nvf.lib.nvim` will return the set | ||||||
|   # below. |   # below. | ||||||
|   nvim = import ./. { |   nvim = import ./. { | ||||||
|     inherit inputs; |     inherit (args) inputs self; | ||||||
|     lib = self; |     lib = self; | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,10 +1,6 @@ | ||||||
| { | {lib}: let | ||||||
|   inputs, |  | ||||||
|   lib, |  | ||||||
|   ... |  | ||||||
| }: let |  | ||||||
|   typesDag = import ./dag.nix {inherit lib;}; |   typesDag = import ./dag.nix {inherit lib;}; | ||||||
|   typesPlugin = import ./plugins.nix {inherit inputs lib;}; |   typesPlugin = import ./plugins.nix {inherit lib;}; | ||||||
|   typesLanguage = import ./languages.nix {inherit lib;}; |   typesLanguage = import ./languages.nix {inherit lib;}; | ||||||
|   customTypes = import ./custom.nix {inherit lib;}; |   customTypes = import ./custom.nix {inherit lib;}; | ||||||
| in { | in { | ||||||
|  |  | ||||||
|  | @ -1,12 +1,8 @@ | ||||||
| { | {lib}: let | ||||||
|   inputs, |  | ||||||
|   lib, |  | ||||||
|   ... |  | ||||||
| }: let |  | ||||||
|   inherit (lib.options) mkOption; |   inherit (lib.options) mkOption; | ||||||
|   inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair; |   inherit (lib.attrsets) attrNames mapAttrs' filterAttrs nameValuePair; | ||||||
|   inherit (lib.strings) hasPrefix removePrefix; |   inherit (lib.strings) hasPrefix removePrefix; | ||||||
|   inherit (lib.types) submodule either package enum str lines attrsOf anything listOf nullOr; |   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. |   # Get the names of all flake inputs that start with the given prefix. | ||||||
|   fromInputs = { |   fromInputs = { | ||||||
|  | @ -15,11 +11,8 @@ | ||||||
|   }: |   }: | ||||||
|     mapAttrs' (n: v: nameValuePair (removePrefix prefix n) {src = v;}) (filterAttrs (n: _: hasPrefix prefix n) inputs); |     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. |   #  Get the names of all npins | ||||||
|   pluginInputNames = attrNames (fromInputs { |   pluginInputNames = attrNames (lib.importJSON ../../npins/sources.json).pins; | ||||||
|     inherit inputs; |  | ||||||
|     prefix = "plugin-"; |  | ||||||
|   }); |  | ||||||
| 
 | 
 | ||||||
|   # You can either use the name of the plugin or a package. |   # You can either use the name of the plugin or a package. | ||||||
|   pluginType = nullOr ( |   pluginType = nullOr ( | ||||||
|  |  | ||||||
|  | @ -1,4 +1,5 @@ | ||||||
| { | { | ||||||
|  |   self, | ||||||
|   inputs, |   inputs, | ||||||
|   lib, |   lib, | ||||||
| }: { | }: { | ||||||
|  | @ -23,7 +24,7 @@ | ||||||
|     specialArgs = |     specialArgs = | ||||||
|       extraSpecialArgs |       extraSpecialArgs | ||||||
|       // { |       // { | ||||||
|         inherit inputs; |         inherit self inputs; | ||||||
|         modulesPath = toString ./.; |         modulesPath = toString ./.; | ||||||
|       }; |       }; | ||||||
|     modules = concatLists [ |     modules = concatLists [ | ||||||
|  |  | ||||||
|  | @ -8,7 +8,6 @@ | ||||||
|   inherit (lib.modules) mkIf mkMerge; |   inherit (lib.modules) mkIf mkMerge; | ||||||
|   inherit (lib.meta) getExe; |   inherit (lib.meta) getExe; | ||||||
|   inherit (lib.lists) isList; |   inherit (lib.lists) isList; | ||||||
|   inherit (lib.strings) optionalString; |  | ||||||
|   inherit (lib.types) either listOf package str; |   inherit (lib.types) either listOf package str; | ||||||
|   inherit (lib.nvim.types) mkGrammarOption; |   inherit (lib.nvim.types) mkGrammarOption; | ||||||
|   inherit (lib.nvim.lua) expToLua; |   inherit (lib.nvim.lua) expToLua; | ||||||
|  | @ -16,6 +15,12 @@ | ||||||
| 
 | 
 | ||||||
|   cfg = config.vim.languages.lua; |   cfg = config.vim.languages.lua; | ||||||
| in { | in { | ||||||
|  |   imports = [ | ||||||
|  |     (lib.mkRemovedOptionModule ["vim" "languages" "lua" "lsp" "neodev"] '' | ||||||
|  |       neodev has been replaced by lazydev | ||||||
|  |     '') | ||||||
|  |   ]; | ||||||
|  | 
 | ||||||
|   options.vim.languages.lua = { |   options.vim.languages.lua = { | ||||||
|     enable = mkEnableOption "Lua language support"; |     enable = mkEnableOption "Lua language support"; | ||||||
|     treesitter = { |     treesitter = { | ||||||
|  | @ -32,7 +37,7 @@ in { | ||||||
|         default = pkgs.lua-language-server; |         default = pkgs.lua-language-server; | ||||||
|       }; |       }; | ||||||
| 
 | 
 | ||||||
|       neodev.enable = mkEnableOption "neodev.nvim integration, useful for neovim plugin developers"; |       lazydev.enable = mkEnableOption "lazydev.nvim integration, useful for neovim plugin developers"; | ||||||
|     }; |     }; | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|  | @ -49,7 +54,6 @@ in { | ||||||
|           lspconfig.lua_ls.setup { |           lspconfig.lua_ls.setup { | ||||||
|             capabilities = capabilities; |             capabilities = capabilities; | ||||||
|             on_attach = default_on_attach; |             on_attach = default_on_attach; | ||||||
|             ${optionalString cfg.lsp.neodev.enable "before_init = require('neodev.lsp').before_init;"} |  | ||||||
|             cmd = ${ |             cmd = ${ | ||||||
|             if isList cfg.lsp.package |             if isList cfg.lsp.package | ||||||
|             then expToLua cfg.lsp.package |             then expToLua cfg.lsp.package | ||||||
|  | @ -59,10 +63,15 @@ in { | ||||||
|         ''; |         ''; | ||||||
|       }) |       }) | ||||||
| 
 | 
 | ||||||
|       (mkIf cfg.lsp.neodev.enable { |       (mkIf cfg.lsp.lazydev.enable { | ||||||
|         vim.startPlugins = ["neodev-nvim"]; |         vim.startPlugins = ["lazydev-nvim"]; | ||||||
|         vim.pluginRC.neodev = entryBefore ["lua-lsp"] '' |         vim.pluginRC.lazydev = entryBefore ["lua-lsp"] '' | ||||||
|           require("neodev").setup({}) |           require("lazydev").setup({ | ||||||
|  |             enabled = function(root_dir) | ||||||
|  |               return not vim.uv.fs_stat(root_dir .. "/.luarc.json") | ||||||
|  |             end, | ||||||
|  |             library = { { path = "''${3rd}/luv/library", words = { "vim%.uv" } } }, | ||||||
|  |           }) | ||||||
|         ''; |         ''; | ||||||
|       }) |       }) | ||||||
|     ])) |     ])) | ||||||
|  |  | ||||||
|  | @ -22,7 +22,7 @@ in { | ||||||
|     ]; |     ]; | ||||||
|     vim = { |     vim = { | ||||||
|       startPlugins = [ |       startPlugins = [ | ||||||
|         "lsp-signature" |         "lsp-signature-nvim" | ||||||
|       ]; |       ]; | ||||||
| 
 | 
 | ||||||
|       lsp.lspSignature.setupOpts = { |       lsp.lspSignature.setupOpts = { | ||||||
|  |  | ||||||
|  | @ -14,7 +14,7 @@ in { | ||||||
|     { |     { | ||||||
|       vim = { |       vim = { | ||||||
|         startPlugins = [ |         startPlugins = [ | ||||||
|           "none-ls" |           "none-ls-nvim" | ||||||
|           "plenary-nvim" |           "plenary-nvim" | ||||||
|         ]; |         ]; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ in { | ||||||
|   config = mkIf cfg.enable { |   config = mkIf cfg.enable { | ||||||
|     vim = { |     vim = { | ||||||
|       startPlugins = [ |       startPlugins = [ | ||||||
|         "todo-comments" |         "todo-comments-nvim" | ||||||
|       ]; |       ]; | ||||||
| 
 | 
 | ||||||
|       maps.normal = mkMerge [ |       maps.normal = mkMerge [ | ||||||
|  |  | ||||||
|  | @ -34,7 +34,7 @@ in { | ||||||
|     }) |     }) | ||||||
|     (mkIf cfg.enable { |     (mkIf cfg.enable { | ||||||
|       vim = { |       vim = { | ||||||
|         startPlugins = ["lualine"]; |         startPlugins = ["lualine-nvim"]; | ||||||
|         pluginRC.lualine = entryAnywhere '' |         pluginRC.lualine = entryAnywhere '' | ||||||
|           local lualine = require('lualine') |           local lualine = require('lualine') | ||||||
|           lualine.setup ${toLuaObject cfg.setupOpts} |           lualine.setup ${toLuaObject cfg.setupOpts} | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ | ||||||
| in { | in { | ||||||
|   config = mkIf cfg.enable { |   config = mkIf cfg.enable { | ||||||
|     vim = { |     vim = { | ||||||
|       startPlugins = ["smartcolumn"]; |       startPlugins = ["smartcolumn-nvim"]; | ||||||
| 
 | 
 | ||||||
|       pluginRC.smartcolumn = entryAnywhere '' |       pluginRC.smartcolumn = entryAnywhere '' | ||||||
|         require("smartcolumn").setup(${toLuaObject cfg.setupOpts}) |         require("smartcolumn").setup(${toLuaObject cfg.setupOpts}) | ||||||
|  |  | ||||||
|  | @ -14,7 +14,7 @@ | ||||||
| in { | in { | ||||||
|   config = mkIf cfg.enable { |   config = mkIf cfg.enable { | ||||||
|     vim = { |     vim = { | ||||||
|       startPlugins = ["which-key"]; |       startPlugins = ["which-key-nvim"]; | ||||||
| 
 | 
 | ||||||
|       pluginRC.whichkey = entryAnywhere '' |       pluginRC.whichkey = entryAnywhere '' | ||||||
|         local wk = require("which-key") |         local wk = require("which-key") | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ | ||||||
| in { | in { | ||||||
|   config = mkIf cfg.enable { |   config = mkIf cfg.enable { | ||||||
|     vim = { |     vim = { | ||||||
|       startPlugins = ["highlight-undo"]; |       startPlugins = ["highlight-undo-nvim"]; | ||||||
| 
 | 
 | ||||||
|       pluginRC.highlight-undo = entryAnywhere '' |       pluginRC.highlight-undo = entryAnywhere '' | ||||||
|         require("highlight-undo").setup(${toLuaObject cfg.setupOpts}) |         require("highlight-undo").setup(${toLuaObject cfg.setupOpts}) | ||||||
|  |  | ||||||
|  | @ -11,7 +11,7 @@ | ||||||
| in { | in { | ||||||
|   config = mkIf cfg.enable { |   config = mkIf cfg.enable { | ||||||
|     vim = { |     vim = { | ||||||
|       startPlugins = ["indent-blankline"]; |       startPlugins = ["indent-blankline-nvim"]; | ||||||
| 
 | 
 | ||||||
|       pluginRC.indent-blankline = entryAnywhere '' |       pluginRC.indent-blankline = entryAnywhere '' | ||||||
|         require("ibl").setup(${toLuaObject cfg.setupOpts}) |         require("ibl").setup(${toLuaObject cfg.setupOpts}) | ||||||
|  |  | ||||||
|  | @ -1,29 +1,27 @@ | ||||||
| { | { | ||||||
|   inputs, |   inputs, | ||||||
|   lib, |  | ||||||
|   config, |   config, | ||||||
|   pkgs, |   pkgs, | ||||||
|  |   lib, | ||||||
|   ... |   ... | ||||||
| } | }: let | ||||||
| : let |  | ||||||
|   inherit (pkgs) vimPlugins; |   inherit (pkgs) vimPlugins; | ||||||
|   inherit (lib.strings) isString; |   inherit (lib.strings) isString; | ||||||
|   inherit (lib.lists) filter map; |   inherit (lib.lists) filter map; | ||||||
|   inherit (builtins) path; |   inherit (builtins) path; | ||||||
| 
 | 
 | ||||||
|   # alias to the internal configuration |   getPin = name: ((pkgs.callPackages ../../../npins/sources.nix {}) // config.vim.pluginOverrides).${name}; | ||||||
|   vimOptions = config.vim; |  | ||||||
| 
 | 
 | ||||||
|   noBuildPlug = pname: let |   noBuildPlug = pname: let | ||||||
|     input = inputs."plugin-${pname}"; |     pin = getPin pname; | ||||||
|     version = input.shortRev or input.shortDirtyRev or "dirty"; |     version = pin.revision or "dirty"; | ||||||
|   in { |   in { | ||||||
|     # vim.lazy.plugins relies on pname, so we only set that here |     # vim.lazy.plugins relies on pname, so we only set that here | ||||||
|     # version isn't needed for anything, but inherit it anyway for correctness |     # version isn't needed for anything, but inherit it anyway for correctness | ||||||
|     inherit pname version; |     inherit pname version; | ||||||
|     outPath = path { |     outPath = path { | ||||||
|       name = "${pname}-0-unstable-${version}"; |       name = "${pname}-0-unstable-${version}"; | ||||||
|       path = input.outPath; |       path = pin.outPath; | ||||||
|     }; |     }; | ||||||
|     passthru.vimPlugin = false; |     passthru.vimPlugin = false; | ||||||
|   }; |   }; | ||||||
|  | @ -32,12 +30,12 @@ | ||||||
|   # if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug |   # if the plugin is nvim-treesitter, warn the user to use buildTreesitterPlug | ||||||
|   # instead |   # instead | ||||||
|   buildPlug = attrs: let |   buildPlug = attrs: let | ||||||
|     input = inputs."plugin-${attrs.pname}"; |     pin = getPin attrs.pname; | ||||||
|   in |   in | ||||||
|     pkgs.vimUtils.buildVimPlugin ( |     pkgs.vimUtils.buildVimPlugin ( | ||||||
|       { |       { | ||||||
|         version = input.shortRev or input.shortDirtyRev or "dirty"; |         version = pin.revision or "dirty"; | ||||||
|         src = input.outPath; |         src = pin.outPath; | ||||||
|       } |       } | ||||||
|       // attrs |       // attrs | ||||||
|     ); |     ); | ||||||
|  | @ -45,7 +43,7 @@ | ||||||
|   buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars); |   buildTreesitterPlug = grammars: vimPlugins.nvim-treesitter.withPlugins (_: grammars); | ||||||
| 
 | 
 | ||||||
|   pluginBuilders = { |   pluginBuilders = { | ||||||
|     nvim-treesitter = buildTreesitterPlug vimOptions.treesitter.grammars; |     nvim-treesitter = buildTreesitterPlug config.vim.treesitter.grammars; | ||||||
|     flutter-tools-patched = buildPlug { |     flutter-tools-patched = buildPlug { | ||||||
|       pname = "flutter-tools"; |       pname = "flutter-tools"; | ||||||
|       patches = [./patches/flutter-tools.patch]; |       patches = [./patches/flutter-tools.patch]; | ||||||
|  | @ -65,39 +63,41 @@ | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   buildConfigPlugins = plugins: |   buildConfigPlugins = plugins: | ||||||
|     map ( |     map (plug: | ||||||
|       plug: |  | ||||||
|       if (isString plug) |       if (isString plug) | ||||||
|       then pluginBuilders.${plug} or (noBuildPlug plug) |       then pluginBuilders.${plug} or (noBuildPlug plug) | ||||||
|         else plug |       else plug) ( | ||||||
|     ) (filter (f: f != null) plugins); |       filter (f: f != null) plugins | ||||||
|  |     ); | ||||||
| 
 | 
 | ||||||
|   # built (or "normalized") plugins that are modified |   # built (or "normalized") plugins that are modified | ||||||
|   builtStartPlugins = buildConfigPlugins vimOptions.startPlugins; |   builtStartPlugins = buildConfigPlugins config.vim.startPlugins; | ||||||
|   builtOptPlugins = map (package: package // {optional = true;}) (buildConfigPlugins vimOptions.optPlugins); |   builtOptPlugins = map (package: package // {optional = true;}) ( | ||||||
|  |     buildConfigPlugins config.vim.optPlugins | ||||||
|  |   ); | ||||||
| 
 | 
 | ||||||
|   # additional Lua and Python3 packages, mapped to their respective functions |   # additional Lua and Python3 packages, mapped to their respective functions | ||||||
|   # to conform to the format mnw expects. end user should |   # to conform to the format mnw expects. end user should | ||||||
|   # only ever need to pass a list of packages, which are modified |   # only ever need to pass a list of packages, which are modified | ||||||
|   # here |   # here | ||||||
|   extraLuaPackages = ps: map (x: ps.${x}) vimOptions.luaPackages; |   extraLuaPackages = ps: map (x: ps.${x}) config.vim.luaPackages; | ||||||
|   extraPython3Packages = ps: map (x: ps.${x}) vimOptions.python3Packages; |   extraPython3Packages = ps: map (x: ps.${x}) config.vim.python3Packages; | ||||||
| 
 | 
 | ||||||
|   # Wrap the user's desired (unwrapped) Neovim package with arguments that'll be used to |   # Wrap the user's desired (unwrapped) Neovim package with arguments that'll be used to | ||||||
|   # generate a wrapped Neovim package. |   # generate a wrapped Neovim package. | ||||||
|   neovim-wrapped = inputs.mnw.lib.wrap pkgs { |   neovim-wrapped = inputs.mnw.lib.wrap pkgs { | ||||||
|     neovim = vimOptions.package; |     neovim = config.vim.package; | ||||||
|     plugins = builtStartPlugins ++ builtOptPlugins; |     plugins = builtStartPlugins ++ builtOptPlugins; | ||||||
|     appName = "nvf"; |     appName = "nvf"; | ||||||
|     extraBinPath = vimOptions.extraPackages; |     extraBinPath = config.vim.extraPackages; | ||||||
|     initLua = vimOptions.builtLuaConfigRC; |     initLua = config.vim.builtLuaConfigRC; | ||||||
|     luaFiles = vimOptions.extraLuaFiles; |     luaFiles = config.vim.extraLuaFiles; | ||||||
| 
 | 
 | ||||||
|     inherit (vimOptions) viAlias vimAlias withRuby withNodeJs withPython3; |     inherit (config.vim) viAlias vimAlias withRuby withNodeJs withPython3; | ||||||
|     inherit extraLuaPackages extraPython3Packages; |     inherit extraLuaPackages extraPython3Packages; | ||||||
|   }; |   }; | ||||||
| 
 | 
 | ||||||
|   dummyInit = pkgs.writeText "nvf-init.lua" vimOptions.builtLuaConfigRC; |   dummyInit = pkgs.writeText "nvf-init.lua" config.vim.builtLuaConfigRC; | ||||||
|   # Additional helper scripts for printing and displaying nvf configuration |   # Additional helper scripts for printing and displaying nvf configuration | ||||||
|   # in your commandline. |   # in your commandline. | ||||||
|   printConfig = pkgs.writers.writeDashBin "nvf-print-config" "cat ${dummyInit}"; |   printConfig = pkgs.writers.writeDashBin "nvf-print-config" "cat ${dummyInit}"; | ||||||
|  | @ -110,10 +110,10 @@ | ||||||
|     paths = [neovim-wrapped printConfig printConfigPath]; |     paths = [neovim-wrapped printConfig printConfigPath]; | ||||||
|     postBuild = "echo Helpers added"; |     postBuild = "echo Helpers added"; | ||||||
| 
 | 
 | ||||||
|     # Allow evaluating vimOptions, i.e., config.vim from the packages' passthru |     # Allow evaluating config.vim, i.e., config.vim from the packages' passthru | ||||||
|     # attribute. For example, packages.x86_64-linux.neovim.passthru.neovimConfig |     # attribute. For example, packages.x86_64-linux.neovim.passthru.neovimConfig | ||||||
|     # will return the configuration in full. |     # will return the configuration in full. | ||||||
|     passthru.neovimConfig = vimOptions; |     passthru.neovimConfig = config.vim; | ||||||
| 
 | 
 | ||||||
|     meta = |     meta = | ||||||
|       neovim-wrapped.meta |       neovim-wrapped.meta | ||||||
|  |  | ||||||
|  | @ -140,5 +140,21 @@ in { | ||||||
|       example = ''["pynvim"]''; |       example = ''["pynvim"]''; | ||||||
|       description = "List of python packages to install"; |       description = "List of python packages to install"; | ||||||
|     }; |     }; | ||||||
|  | 
 | ||||||
|  |     pluginOverrides = mkOption { | ||||||
|  |       type = attrsOf package; | ||||||
|  |       default = {}; | ||||||
|  |       example = '' | ||||||
|  |         { | ||||||
|  |           lazydev-nvim = pkgs.fetchFromGitHub { | ||||||
|  |             owner = "folke"; | ||||||
|  |             repo = "lazydev.nvim"; | ||||||
|  |             rev = ""; | ||||||
|  |             hash = ""; | ||||||
|  |           }; | ||||||
|  |         } | ||||||
|  |       ''; | ||||||
|  |       description = "Attribute set of plugins to override default values"; | ||||||
|  |     }; | ||||||
|   }; |   }; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -1,80 +0,0 @@ | ||||||
| # Generated by npins. Do not modify; will be overwritten regularly |  | ||||||
| let |  | ||||||
|   data = builtins.fromJSON (builtins.readFile ./sources.json); |  | ||||||
|   version = data.version; |  | ||||||
| 
 |  | ||||||
|   mkSource = |  | ||||||
|     spec: |  | ||||||
|     assert spec ? type; |  | ||||||
|     let |  | ||||||
|       path = |  | ||||||
|         if spec.type == "Git" then |  | ||||||
|           mkGitSource spec |  | ||||||
|         else if spec.type == "GitRelease" then |  | ||||||
|           mkGitSource spec |  | ||||||
|         else if spec.type == "PyPi" then |  | ||||||
|           mkPyPiSource spec |  | ||||||
|         else if spec.type == "Channel" then |  | ||||||
|           mkChannelSource spec |  | ||||||
|         else |  | ||||||
|           builtins.throw "Unknown source type ${spec.type}"; |  | ||||||
|     in |  | ||||||
|     spec // { outPath = path; }; |  | ||||||
| 
 |  | ||||||
|   mkGitSource = |  | ||||||
|     { |  | ||||||
|       repository, |  | ||||||
|       revision, |  | ||||||
|       url ? null, |  | ||||||
|       hash, |  | ||||||
|       branch ? null, |  | ||||||
|       ... |  | ||||||
|     }: |  | ||||||
|     assert repository ? type; |  | ||||||
|     # At the moment, either it is a plain git repository (which has an url), or it is a GitHub/GitLab repository |  | ||||||
|     # In the latter case, there we will always be an url to the tarball |  | ||||||
|     if url != null then |  | ||||||
|       (builtins.fetchTarball { |  | ||||||
|         inherit url; |  | ||||||
|         sha256 = hash; # FIXME: check nix version & use SRI hashes |  | ||||||
|       }) |  | ||||||
|     else |  | ||||||
|       assert repository.type == "Git"; |  | ||||||
|       let |  | ||||||
|         urlToName = |  | ||||||
|           url: rev: |  | ||||||
|           let |  | ||||||
|             matched = builtins.match "^.*/([^/]*)(\\.git)?$" repository.url; |  | ||||||
| 
 |  | ||||||
|             short = builtins.substring 0 7 rev; |  | ||||||
| 
 |  | ||||||
|             appendShort = if (builtins.match "[a-f0-9]*" rev) != null then "-${short}" else ""; |  | ||||||
|           in |  | ||||||
|           "${if matched == null then "source" else builtins.head matched}${appendShort}"; |  | ||||||
|         name = urlToName repository.url revision; |  | ||||||
|       in |  | ||||||
|       builtins.fetchGit { |  | ||||||
|         url = repository.url; |  | ||||||
|         rev = revision; |  | ||||||
|         inherit name; |  | ||||||
|         # hash = hash; |  | ||||||
|       }; |  | ||||||
| 
 |  | ||||||
|   mkPyPiSource = |  | ||||||
|     { url, hash, ... }: |  | ||||||
|     builtins.fetchurl { |  | ||||||
|       inherit url; |  | ||||||
|       sha256 = hash; |  | ||||||
|     }; |  | ||||||
| 
 |  | ||||||
|   mkChannelSource = |  | ||||||
|     { url, hash, ... }: |  | ||||||
|     builtins.fetchTarball { |  | ||||||
|       inherit url; |  | ||||||
|       sha256 = hash; |  | ||||||
|     }; |  | ||||||
| in |  | ||||||
| if version == 3 then |  | ||||||
|   builtins.mapAttrs (_: mkSource) data.pins |  | ||||||
| else |  | ||||||
|   throw "Unsupported format version ${toString version} in sources.json. Try running `npins upgrade`" |  | ||||||
										
											
												File diff suppressed because it is too large
												Load diff
											
										
									
								
							
							
								
								
									
										85
									
								
								npins/sources.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								npins/sources.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,85 @@ | ||||||
|  | # Based off of: | ||||||
|  | # https://github.com/NixOS/nixpkgs/blob/776c3bee4769c616479393aeefceefeda16b6fcb/pkgs/tools/nix/npins/source.nix | ||||||
|  | { | ||||||
|  |   lib, | ||||||
|  |   fetchurl, | ||||||
|  |   fetchgit, | ||||||
|  |   fetchzip, | ||||||
|  | }: | ||||||
|  | builtins.mapAttrs | ||||||
|  | ( | ||||||
|  |   _: let | ||||||
|  |     getZip = { | ||||||
|  |       url, | ||||||
|  |       hash, | ||||||
|  |       ... | ||||||
|  |     }: | ||||||
|  |       fetchzip { | ||||||
|  |         inherit url; | ||||||
|  |         sha256 = hash; | ||||||
|  |         extension = "tar"; | ||||||
|  |       }; | ||||||
|  |     mkGitSource = { | ||||||
|  |       repository, | ||||||
|  |       revision, | ||||||
|  |       url ? null, | ||||||
|  |       hash, | ||||||
|  |       ... | ||||||
|  |     } @ attrs: | ||||||
|  |       assert repository ? type; | ||||||
|  |         if url != null | ||||||
|  |         then getZip attrs | ||||||
|  |         else | ||||||
|  |           assert repository.type == "Git"; let | ||||||
|  |             urlToName = url: rev: let | ||||||
|  |               matched = builtins.match "^.*/([^/]*)(\\.git)?$" repository.url; | ||||||
|  |               short = builtins.substring 0 7 rev; | ||||||
|  |               appendShort = | ||||||
|  |                 if (builtins.match "[a-f0-9]*" rev) != null | ||||||
|  |                 then "-${short}" | ||||||
|  |                 else ""; | ||||||
|  |             in "${ | ||||||
|  |               if matched == null | ||||||
|  |               then "source" | ||||||
|  |               else builtins.head matched | ||||||
|  |             }${appendShort}"; | ||||||
|  |             name = urlToName repository.url revision; | ||||||
|  |           in | ||||||
|  |             fetchgit { | ||||||
|  |               inherit name; | ||||||
|  |               inherit (repository) url; | ||||||
|  |               rev = revision; | ||||||
|  |               sha256 = hash; | ||||||
|  |             }; | ||||||
|  | 
 | ||||||
|  |     mkPyPiSource = { | ||||||
|  |       url, | ||||||
|  |       hash, | ||||||
|  |       ... | ||||||
|  |     }: | ||||||
|  |       fetchurl { | ||||||
|  |         inherit url; | ||||||
|  |         sha256 = hash; | ||||||
|  |       }; | ||||||
|  |   in | ||||||
|  |     spec: | ||||||
|  |       assert spec ? type; let | ||||||
|  |         func = | ||||||
|  |           { | ||||||
|  |             Git = mkGitSource; | ||||||
|  |             GitRelease = mkGitSource; | ||||||
|  |             PyPi = mkPyPiSource; | ||||||
|  |             Channel = getZip; | ||||||
|  |           } | ||||||
|  |           .${spec.type} | ||||||
|  |           or (builtins.throw "Unknown source type ${spec.type}"); | ||||||
|  |       in | ||||||
|  |         spec // {outPath = func spec;} | ||||||
|  | ) | ||||||
|  | ( | ||||||
|  |   let | ||||||
|  |     json = lib.importJSON ./sources.json; | ||||||
|  |   in | ||||||
|  |     assert lib.assertMsg (json.version == 3) "Npins version mismatch!"; | ||||||
|  |       json.pins | ||||||
|  | ) | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Gerg-L
					Gerg-L