default.nix
1 # Copyright (c) 2023 BirdeeHub 2 # Licensed under the MIT license 3 /* 4 # paste the inputs you don't have in this set into your main system flake.nix 5 # (lazy.nvim wrapper only works on unstable) 6 inputs = { 7 nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; 8 nixCats.url = "github:BirdeeHub/nixCats-nvim"; 9 }; 10 11 Then call this file with: 12 myNixCats = import ./path/to/this/dir { inherit inputs; }; 13 And the new variable myNixCats will contain all outputs of the normal flake format. 14 You could put myNixCats.packages.${pkgs.system}.thepackagename in your packages list. 15 You could install them with the module and reconfigure them too if you want. 16 You should definitely re export them under packages.${system}.packagenames 17 from your system flake so that you can still run it via nix run from anywhere. 18 19 The following is just the outputs function from the flake template. 20 */ 21 { inputs, ... }@attrs: 22 let 23 inherit (inputs) nixpkgs; # <-- nixpkgs = inputs.nixpkgsSomething; 24 inherit (inputs.nixCats) utils; 25 luaPath = "${./.}"; 26 forEachSystem = utils.eachSystem nixpkgs.lib.platforms.all; 27 # the following extra_pkg_config contains any values 28 # which you want to pass to the config set of nixpkgs 29 # import nixpkgs { config = extra_pkg_config; inherit system; } 30 extra_pkg_config = { 31 # allowUnfree = true; 32 }; 33 dependencyOverlays = # (import ./overlays inputs) ++ 34 [ 35 # see :help nixCats.flake.outputs.overlays 36 # This overlay grabs all the inputs named in the format 37 # `plugins-<pluginName>` 38 # Once we add this overlay to our nixpkgs, we are able to 39 # use `pkgs.neovimPlugins`, which is a set of our plugins. 40 (utils.standardPluginOverlay inputs) 41 # add any flake overlays here. 42 43 # when other people mess up their overlays by wrapping them with system, 44 # you may instead call this function on their overlay. 45 # it will check if it has the system in the set, and if so return the desired overlay 46 # (utils.fixSystemizedOverlay inputs.codeium.overlays 47 # (system: inputs.codeium.overlays.${system}.default) 48 # ) 49 ]; 50 51 categoryDefinitions = 52 { 53 pkgs, 54 settings, 55 categories, 56 extra, 57 name, 58 mkPlugin, 59 ... 60 }@packageDef: 61 { 62 63 lspsAndRuntimeDeps = { 64 general = with pkgs; [ 65 haskell-language-server 66 typescript-language-server 67 terraform-ls 68 gopls 69 gotools 70 nixd 71 efm-langserver 72 ripgrep 73 fzf 74 lua-language-server 75 eslint_d 76 prettierd 77 python3Packages.jedi-language-server 78 ]; 79 80 debug = with pkgs; [ 81 vscode-js-debug 82 ]; 83 84 latex = with pkgs; [ 85 zathura 86 ]; 87 }; 88 89 startupPlugins = { 90 general = with pkgs; [ 91 vimPlugins.lze 92 vimPlugins.litee-nvim 93 vimPlugins.nvim-web-devicons 94 vimPlugins.nvim-lspconfig 95 vimPlugins.plenary-nvim 96 vimPlugins.nvim-treesitter.withAllGrammars 97 vimPlugins.zen-mode-nvim 98 vimPlugins.vimtex 99 vimPlugins.which-key-nvim 100 vimPlugins.telescope-nvim 101 vimPlugins.telescope-ui-select-nvim 102 vimPlugins.telescope-fzf-native-nvim 103 vimPlugins.telescope-symbols-nvim 104 vimPlugins.impatient-nvim 105 vimPlugins.markdown-preview-nvim 106 vimPlugins.galaxyline-nvim 107 vimPlugins.gitsigns-nvim 108 neovimPlugins.gh-nvim 109 110 vimPlugins.tokyonight-nvim 111 neovimPlugins.nerdcommenter 112 113 vimPlugins.harpoon 114 vimPlugins.nvim-autopairs 115 116 neovimPlugins.nvim-navic 117 118 vimPlugins.rest-nvim 119 vimPlugins.cornelis 120 121 # cmp 122 vimPlugins.nvim-cmp 123 vimPlugins.cmp-buffer 124 vimPlugins.cmp-path 125 vimPlugins.luasnip 126 vimPlugins.cmp_luasnip 127 vimPlugins.cmp-nvim-lsp 128 129 # TODO: consider copilot 130 131 vimPlugins.gitlinker-nvim 132 vimPlugins.vim-dadbod 133 vimPlugins.vim-dadbod-ui 134 135 vimPlugins.neo-tree-nvim 136 vimPlugins.nvterm 137 ]; 138 139 lsp = with pkgs; [ 140 vimPlugins.lspkind-nvim 141 vimPlugins.fidget-nvim 142 vimPlugins.nvim-metals 143 ]; 144 145 debug = with pkgs; [ 146 vimPlugins.nvim-dap 147 neovimPlugins.nvim-dap-vscode-js 148 ]; 149 }; 150 151 optionalPlugins = { 152 gitPlugins = with pkgs.neovimPlugins; [ ]; 153 general = with pkgs.vimPlugins; [ ]; 154 }; 155 156 # shared libraries to be added to LD_LIBRARY_PATH 157 # variable available to nvim runtime 158 sharedLibraries = { 159 general = with pkgs; [ 160 # libgit2 161 ]; 162 }; 163 164 environmentVariables = { 165 }; 166 167 extraWrapperArgs = { 168 }; 169 }; 170 171 packageDefinitions = { 172 nvim = 173 { pkgs, name, ... }: 174 { 175 # they contain a settings set defined above 176 # see :help nixCats.flake.outputs.settings 177 settings = { 178 suffix-path = true; 179 suffix-LD = true; 180 wrapRc = "UNWRAP_NVIM"; 181 aliases = [ "vim" ]; 182 neovim-unwrapped = inputs.neovim-nightly-overlay.packages.${pkgs.system}.neovim; 183 }; 184 # and a set of categories that you want 185 # (and other information to pass to lua) 186 categories = { 187 general = true; 188 debug = true; 189 lsp = true; 190 latex = true; 191 }; 192 extra = { }; 193 }; 194 }; 195 # In this section, the main thing you will need to do is change the default package name 196 # to the name of the packageDefinitions entry you wish to use as the default. 197 defaultPackageName = "nvim"; 198 in 199 # see :help nixCats.flake.outputs.exports 200 forEachSystem ( 201 system: 202 let 203 nixCatsBuilder = utils.baseBuilder luaPath { 204 inherit 205 system 206 dependencyOverlays 207 extra_pkg_config 208 nixpkgs 209 ; 210 } categoryDefinitions packageDefinitions; 211 defaultPackage = nixCatsBuilder defaultPackageName; 212 # this is just for using utils such as pkgs.mkShell 213 # The one used to build neovim is resolved inside the builder 214 # and is passed to our categoryDefinitions and packageDefinitions 215 pkgs = import nixpkgs { inherit system; }; 216 in 217 { 218 # this will make a package out of each of the packageDefinitions defined above 219 # and set the default package to the one passed in here. 220 packages = utils.mkAllWithDefault defaultPackage; 221 222 # choose your package for devShell 223 # and add whatever else you want in it. 224 devShells = { 225 default = pkgs.mkShell { 226 name = defaultPackageName; 227 packages = [ defaultPackage ]; 228 inputsFrom = [ ]; 229 shellHook = ''''; 230 }; 231 }; 232 233 } 234 ) 235 // ( 236 let 237 # we also export a nixos module to allow reconfiguration from configuration.nix 238 nixosModule = utils.mkNixosModules { 239 moduleNamespace = [ defaultPackageName ]; 240 inherit 241 defaultPackageName 242 dependencyOverlays 243 luaPath 244 categoryDefinitions 245 packageDefinitions 246 extra_pkg_config 247 nixpkgs 248 ; 249 }; 250 # and the same for home manager 251 homeModule = utils.mkHomeModules { 252 moduleNamespace = [ defaultPackageName ]; 253 inherit 254 defaultPackageName 255 dependencyOverlays 256 luaPath 257 categoryDefinitions 258 packageDefinitions 259 extra_pkg_config 260 nixpkgs 261 ; 262 }; 263 in 264 { 265 266 # these outputs will be NOT wrapped with ${system} 267 268 # this will make an overlay out of each of the packageDefinitions defined above 269 # and set the default overlay to the one named here. 270 overlays = utils.makeOverlays luaPath { 271 # we pass in the things to make a pkgs variable to build nvim with later 272 inherit nixpkgs dependencyOverlays extra_pkg_config; 273 # and also our categoryDefinitions 274 } categoryDefinitions packageDefinitions defaultPackageName; 275 276 nixosModules.default = nixosModule; 277 homeModules.default = homeModule; 278 279 inherit utils nixosModule homeModule; 280 inherit (utils) templates; 281 } 282 )