diff options
style: format all `.nix` files with `nixfmt`
Diffstat (limited to '')
-rw-r--r-- | flake.nix | 558 |
1 files changed, 317 insertions, 241 deletions
@@ -50,260 +50,336 @@ }; # see :help nixCats.flake.outputs - outputs = { self, nixpkgs, nixCats, ... }@inputs: let - inherit (nixCats) utils; - luaPath = "${./.}"; - forEachSystem = utils.eachSystem nixpkgs.lib.platforms.all; - # the following extra_pkg_config contains any values - # which you want to pass to the config set of nixpkgs - # import nixpkgs { config = extra_pkg_config; inherit system; } - # will not apply to module imports - # as that will have your system values - extra_pkg_config = { - # allowUnfree = true; - }; - # management of the system variable is one of the harder parts of using flakes. - - # so I have done it here in an interesting way to keep it out of the way. - # It gets resolved within the builder itself, and then passed to your - # categoryDefinitions and packageDefinitions. - - # this allows you to use ${pkgs.system} whenever you want in those sections - # without fear. - - # sometimes our overlays require a ${system} to access the overlay. - # Your dependencyOverlays can either be lists - # in a set of ${system}, or simply a list. - # the nixCats builder function will accept either. - # see :help nixCats.flake.outputs.overlays - dependencyOverlays = /* (import ./overlays inputs) ++ */ [ - # This overlay grabs all the inputs named in the format - # `plugins-<pluginName>` - # Once we add this overlay to our nixpkgs, we are able to - # use `pkgs.neovimPlugins`, which is a set of our plugins. - (utils.standardPluginOverlay inputs) - # add any other flake overlays here. - - # when other people mess up their overlays by wrapping them with system, - # you may instead call this function on their overlay. - # it will check if it has the system in the set, and if so return the desired overlay - # (utils.fixSystemizedOverlay inputs.codeium.overlays - # (system: inputs.codeium.overlays.${system}.default) - # ) - ]; - - # see :help nixCats.flake.outputs.categories - # and - # :help nixCats.flake.outputs.categoryDefinitions.scheme - categoryDefinitions = { pkgs, settings, categories, extra, name, mkNvimPlugin, ... }@packageDef: { - # to define and use a new category, simply add a new list to a set here, - # and later, you will include categoryname = true; in the set you - # provide when you build the package using this builder function. - # see :help nixCats.flake.outputs.packageDefinitions for info on that section. - - # lspsAndRuntimeDeps: - # this section is for dependencies that should be available - # at RUN TIME for plugins. Will be available to PATH within neovim terminal - # this includes LSPs - lspsAndRuntimeDeps = { - general = with pkgs; { - lua = [ lua-language-server stylua ]; - nix = [ nix-doc nixd nixfmt-rfc-style ]; - }; - }; - - # This is for plugins that will load at startup without using packadd: - startupPlugins = { - gitPlugins = with pkgs.neovimPlugins; { }; - - general = with pkgs.vimPlugins; { - always = [ lze lzextras ]; - libraries = [ plenary-nvim ]; - editor = [ vim-repeat ]; - ui = [ nvim-notify snacks-nvim ]; - extra = [ nvim-web-devicons ]; - }; - - theme = with pkgs.vimPlugins; (builtins.getAttr (categories.colorscheme or "catppuccin-mocha") { - "catppuccin-mocha" = catppuccin-nvim; - }); - }; - - # not loaded automatically at startup. - # use with packadd and an autocommand in config to achieve lazy loading - optionalPlugins = { - gitPlugins = with pkgs.neovimPlugins; { - leap = [ leap-spooky-nvim telepath-nvim ]; - }; - - general = with pkgs.vimPlugins; { - leap = [ leap-nvim flit-nvim ]; - telescope = [ telescope-nvim ]; - treesitter = [ nvim-treesitter.withAllGrammars nvim-treesitter-textobjects ]; - - completion = [ blink-cmp ]; - # NOTE: On NeoVim 0.11+ nvim-lspconfig is not required due to native API - lsp = []; - - mini = [ mini-ai mini-align mini-diff mini-move mini-pairs mini-surround ]; - - formatting = [ conform-nvim ]; - - git = [ gitsigns-nvim ]; - - ui = [ - noice-nvim - todo-comments-nvim - ]; - - extra = [ which-key-nvim ]; - }; + outputs = + { + self, + nixpkgs, + nixCats, + ... + }@inputs: + let + inherit (nixCats) utils; + luaPath = "${./.}"; + forEachSystem = utils.eachSystem nixpkgs.lib.platforms.all; + # the following extra_pkg_config contains any values + # which you want to pass to the config set of nixpkgs + # import nixpkgs { config = extra_pkg_config; inherit system; } + # will not apply to module imports + # as that will have your system values + extra_pkg_config = { + # allowUnfree = true; }; - - # shared libraries to be added to LD_LIBRARY_PATH - # variable available to nvim runtime - sharedLibraries = { - general = with pkgs; [ - # libgit2 + # management of the system variable is one of the harder parts of using flakes. + + # so I have done it here in an interesting way to keep it out of the way. + # It gets resolved within the builder itself, and then passed to your + # categoryDefinitions and packageDefinitions. + + # this allows you to use ${pkgs.system} whenever you want in those sections + # without fear. + + # sometimes our overlays require a ${system} to access the overlay. + # Your dependencyOverlays can either be lists + # in a set of ${system}, or simply a list. + # the nixCats builder function will accept either. + # see :help nixCats.flake.outputs.overlays + dependencyOverlays = # (import ./overlays inputs) ++ + [ + # This overlay grabs all the inputs named in the format + # `plugins-<pluginName>` + # Once we add this overlay to our nixpkgs, we are able to + # use `pkgs.neovimPlugins`, which is a set of our plugins. + (utils.standardPluginOverlay inputs) + # add any other flake overlays here. + + # when other people mess up their overlays by wrapping them with system, + # you may instead call this function on their overlay. + # it will check if it has the system in the set, and if so return the desired overlay + # (utils.fixSystemizedOverlay inputs.codeium.overlays + # (system: inputs.codeium.overlays.${system}.default) + # ) ]; - }; - # environmentVariables: - # this section is for environmentVariables that should be available - # at RUN TIME for plugins. Will be available to path within neovim terminal - environmentVariables = { - test = { - CATTESTVAR = "It worked!"; + # see :help nixCats.flake.outputs.categories + # and + # :help nixCats.flake.outputs.categoryDefinitions.scheme + categoryDefinitions = + { + pkgs, + settings, + categories, + extra, + name, + mkNvimPlugin, + ... + }@packageDef: + { + # to define and use a new category, simply add a new list to a set here, + # and later, you will include categoryname = true; in the set you + # provide when you build the package using this builder function. + # see :help nixCats.flake.outputs.packageDefinitions for info on that section. + + # lspsAndRuntimeDeps: + # this section is for dependencies that should be available + # at RUN TIME for plugins. Will be available to PATH within neovim terminal + # this includes LSPs + lspsAndRuntimeDeps = { + general = with pkgs; { + lua = [ + lua-language-server + stylua + ]; + nix = [ + nix-doc + nixd + nixfmt-rfc-style + ]; + }; + }; + + # This is for plugins that will load at startup without using packadd: + startupPlugins = { + gitPlugins = with pkgs.neovimPlugins; { }; + + general = with pkgs.vimPlugins; { + always = [ + lze + lzextras + ]; + libraries = [ plenary-nvim ]; + editor = [ vim-repeat ]; + ui = [ + nvim-notify + snacks-nvim + ]; + extra = [ nvim-web-devicons ]; + }; + + theme = + with pkgs.vimPlugins; + (builtins.getAttr (categories.colorscheme or "catppuccin-mocha") { + "catppuccin-mocha" = catppuccin-nvim; + }); + }; + + # not loaded automatically at startup. + # use with packadd and an autocommand in config to achieve lazy loading + optionalPlugins = { + gitPlugins = with pkgs.neovimPlugins; { + leap = [ + leap-spooky-nvim + telepath-nvim + ]; + }; + + general = with pkgs.vimPlugins; { + leap = [ + leap-nvim + flit-nvim + ]; + telescope = [ telescope-nvim ]; + treesitter = [ + nvim-treesitter.withAllGrammars + nvim-treesitter-textobjects + ]; + + completion = [ blink-cmp ]; + # NOTE: On NeoVim 0.11+ nvim-lspconfig is not required due to native API + lsp = [ ]; + + mini = [ + mini-ai + mini-align + mini-diff + mini-move + mini-pairs + mini-surround + ]; + + formatting = [ conform-nvim ]; + + git = [ gitsigns-nvim ]; + + ui = [ + noice-nvim + todo-comments-nvim + ]; + + extra = [ which-key-nvim ]; + }; + }; + + # shared libraries to be added to LD_LIBRARY_PATH + # variable available to nvim runtime + sharedLibraries = { + general = with pkgs; [ + # libgit2 + ]; + }; + + # environmentVariables: + # this section is for environmentVariables that should be available + # at RUN TIME for plugins. Will be available to path within neovim terminal + environmentVariables = { + test = { + CATTESTVAR = "It worked!"; + }; + }; + + # If you know what these are, you can provide custom ones by category here. + # If you dont, check this link out: + # https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/setup-hooks/make-wrapper.sh + extraWrapperArgs = { + test = [ + ''--set CATTESTVAR2 "It worked again!"'' + ]; + }; + + # lists of the functions you would have passed to + # python.withPackages or lua.withPackages + + # get the path to this python environment + # in your lua config via + # vim.g.python3_host_prog + # or run from nvim terminal via :!<packagename>-python3 + extraPython3Packages = { + test = (_: [ ]); + }; + # populates $LUA_PATH and $LUA_CPATH + extraLuaPackages = { + test = [ (_: [ ]) ]; + }; }; - }; - - # If you know what these are, you can provide custom ones by category here. - # If you dont, check this link out: - # https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/setup-hooks/make-wrapper.sh - extraWrapperArgs = { - test = [ - '' --set CATTESTVAR2 "It worked again!"'' - ]; - }; - - # lists of the functions you would have passed to - # python.withPackages or lua.withPackages - # get the path to this python environment - # in your lua config via - # vim.g.python3_host_prog - # or run from nvim terminal via :!<packagename>-python3 - extraPython3Packages = { - test = (_:[]); + # And then build a package with specific categories from above here: + # All categories you wish to include must be marked true, + # but false may be omitted. + # This entire set is also passed to nixCats for querying within the lua. + + # see :help nixCats.flake.outputs.packageDefinitions + packageDefinitions = { + # These are the names of your packages + # you can include as many as you wish. + nvim = + { pkgs, ... }: + { + # they contain a settings set defined above + # see :help nixCats.flake.outputs.settings + settings = { + wrapRc = true; + # IMPORTANT: + # your alias may not conflict with your other packages. + aliases = [ + "vi" + "vim" + ]; + neovim-unwrapped = inputs.neovim-nightly-overlay.packages.${pkgs.system}.neovim; + }; + + # and a set of categories that you want + # (and other information to pass to lua) + categories = { + theme = true; + colorscheme = "catppuccin-mocha"; + + general = true; + gitPlugins = true; + customPlugins = true; + }; + + extra = { + nixdExtras = { inherit nixpkgs; }; + }; + }; }; - # populates $LUA_PATH and $LUA_CPATH - extraLuaPackages = { - test = [ (_:[]) ]; - }; - }; - - - - # And then build a package with specific categories from above here: - # All categories you wish to include must be marked true, - # but false may be omitted. - # This entire set is also passed to nixCats for querying within the lua. - - # see :help nixCats.flake.outputs.packageDefinitions - packageDefinitions = { - # These are the names of your packages - # you can include as many as you wish. - nvim = {pkgs , ... }: { - # they contain a settings set defined above - # see :help nixCats.flake.outputs.settings - settings = { - wrapRc = true; - # IMPORTANT: - # your alias may not conflict with your other packages. - aliases = [ "vi" "vim" ]; - neovim-unwrapped = inputs.neovim-nightly-overlay.packages.${pkgs.system}.neovim; + # In this section, the main thing you will need to do is change the default package name + # to the name of the packageDefinitions entry you wish to use as the default. + defaultPackageName = "nvim"; + in + + # see :help nixCats.flake.outputs.exports + forEachSystem ( + system: + let + nixCatsBuilder = utils.baseBuilder luaPath { + inherit + nixpkgs + system + dependencyOverlays + extra_pkg_config + ; + } categoryDefinitions packageDefinitions; + defaultPackage = nixCatsBuilder defaultPackageName; + # this is just for using utils such as pkgs.mkShell + # The one used to build neovim is resolved inside the builder + # and is passed to our categoryDefinitions and packageDefinitions + pkgs = import nixpkgs { inherit system; }; + in + { + # these outputs will be wrapped with ${system} by utils.eachSystem + + # this will make a package out of each of the packageDefinitions defined above + # and set the default package to the one passed in here. + packages = utils.mkAllWithDefault defaultPackage; + + # choose your package for devShell + # and add whatever else you want in it. + devShells = { + default = pkgs.mkShell { + name = defaultPackageName; + packages = [ defaultPackage ]; + inputsFrom = [ ]; + shellHook = ''''; + }; }; - # and a set of categories that you want - # (and other information to pass to lua) - categories = { - theme = true; - colorscheme = "catppuccin-mocha"; - - general = true; - gitPlugins = true; - customPlugins = true; + } + ) + // ( + let + # we also export a nixos module to allow reconfiguration from configuration.nix + nixosModule = utils.mkNixosModules { + moduleNamespace = [ defaultPackageName ]; + inherit + defaultPackageName + dependencyOverlays + luaPath + categoryDefinitions + packageDefinitions + extra_pkg_config + nixpkgs + ; }; - - extra = { - nixdExtras = { inherit nixpkgs; }; + # and the same for home manager + homeModule = utils.mkHomeModules { + moduleNamespace = [ defaultPackageName ]; + inherit + defaultPackageName + dependencyOverlays + luaPath + categoryDefinitions + packageDefinitions + extra_pkg_config + nixpkgs + ; }; - }; - }; - # In this section, the main thing you will need to do is change the default package name - # to the name of the packageDefinitions entry you wish to use as the default. - defaultPackageName = "nvim"; - in - - - # see :help nixCats.flake.outputs.exports - forEachSystem (system: let - nixCatsBuilder = utils.baseBuilder luaPath { - inherit nixpkgs system dependencyOverlays extra_pkg_config; - } categoryDefinitions packageDefinitions; - defaultPackage = nixCatsBuilder defaultPackageName; - # this is just for using utils such as pkgs.mkShell - # The one used to build neovim is resolved inside the builder - # and is passed to our categoryDefinitions and packageDefinitions - pkgs = import nixpkgs { inherit system; }; - in - { - # these outputs will be wrapped with ${system} by utils.eachSystem - - # this will make a package out of each of the packageDefinitions defined above - # and set the default package to the one passed in here. - packages = utils.mkAllWithDefault defaultPackage; - - # choose your package for devShell - # and add whatever else you want in it. - devShells = { - default = pkgs.mkShell { - name = defaultPackageName; - packages = [ defaultPackage ]; - inputsFrom = [ ]; - shellHook = '' - ''; - }; - }; - - }) // (let - # we also export a nixos module to allow reconfiguration from configuration.nix - nixosModule = utils.mkNixosModules { - moduleNamespace = [ defaultPackageName ]; - inherit defaultPackageName dependencyOverlays luaPath - categoryDefinitions packageDefinitions extra_pkg_config nixpkgs; - }; - # and the same for home manager - homeModule = utils.mkHomeModules { - moduleNamespace = [ defaultPackageName ]; - inherit defaultPackageName dependencyOverlays luaPath - categoryDefinitions packageDefinitions extra_pkg_config nixpkgs; - }; - in { + in + { - # these outputs will be NOT wrapped with ${system} + # these outputs will be NOT wrapped with ${system} - # this will make an overlay out of each of the packageDefinitions defined above - # and set the default overlay to the one named here. - overlays = utils.makeOverlays luaPath { - inherit nixpkgs dependencyOverlays extra_pkg_config; - } categoryDefinitions packageDefinitions defaultPackageName; + # this will make an overlay out of each of the packageDefinitions defined above + # and set the default overlay to the one named here. + overlays = utils.makeOverlays luaPath { + inherit nixpkgs dependencyOverlays extra_pkg_config; + } categoryDefinitions packageDefinitions defaultPackageName; - nixosModules.default = nixosModule; - homeModules.default = homeModule; + nixosModules.default = nixosModule; + homeModules.default = homeModule; - inherit utils nixosModule homeModule; - inherit (utils) templates; - }); + inherit utils nixosModule homeModule; + inherit (utils) templates; + } + ); } |