From ed5e6475f84eb097a547c60c759af07144016b78 Mon Sep 17 00:00:00 2001 From: seth Date: Wed, 12 Jun 2024 04:51:04 -0400 Subject: nix: refactor derivations --- config/default.nix | 19 +++++++++++++++++++ flake.nix | 54 ++++++++++++++++++++++++++++++++++++++---------------- neovim.nix | 38 +++++++++++++++++++++----------------- 3 files changed, 78 insertions(+), 33 deletions(-) create mode 100644 config/default.nix diff --git a/config/default.nix b/config/default.nix new file mode 100644 index 0000000..ece45ef --- /dev/null +++ b/config/default.nix @@ -0,0 +1,19 @@ +{ + lib, + vimUtils, + version, +}: +vimUtils.buildVimPlugin { + pname = "neovim-config"; + inherit version; + + src = lib.fileset.toSource { + root = ./.; + fileset = lib.fileset.unions [ + ./after + ./ftdetect + ./lua + ./plugin + ]; + }; +} diff --git a/flake.nix b/flake.nix index a4ea185..168c9a6 100644 --- a/flake.nix +++ b/flake.nix @@ -18,9 +18,14 @@ "aarch64-darwin" ]; - forAllSystems = fn: nixpkgs.lib.genAttrs systems (system: fn nixpkgs.legacyPackages.${system}); + forAllSystems = fn: + nixpkgs.lib.genAttrs systems (system: + fn { + inherit system; + pkgs = nixpkgs.legacyPackages.${system}; + }); in { - checks = forAllSystems (pkgs: let + checks = forAllSystems ({pkgs, ...}: let flake-checks' = flake-checks.lib.mkChecks { root = ./.; inherit pkgs; @@ -36,30 +41,47 @@ ; }); - devShells = forAllSystems (pkgs: { + devShells = forAllSystems ({ + pkgs, + system, + }: { default = pkgs.mkShellNoCC { - packages = with pkgs; [ - actionlint + packages = [ + pkgs.actionlint # lua - lua-language-server - selene - stylua + pkgs.lua-language-server + pkgs.selene + pkgs.stylua # nix - self.formatter.${pkgs.system} - deadnix - nil - statix + self.formatter.${system} + pkgs.deadnix + pkgs.nil + pkgs.statix ]; }; }); - formatter = forAllSystems (pkgs: pkgs.alejandra); + formatter = forAllSystems ({pkgs, ...}: pkgs.alejandra); - packages = forAllSystems (pkgs: rec { - getchvim = import ./neovim.nix self pkgs; - default = getchvim; + packages = forAllSystems ({ + pkgs, + system, + }: let + packages' = self.packages.${system}; + version = self.shortRev or self.dirtyShortRev or "unknown"; + in { + getchvim = pkgs.callPackage ./neovim.nix { + inherit version; + inherit (packages') vimPlugins-getchoo-nvim; + }; + + vimPlugins-getchoo-nvim = pkgs.callPackage ./config { + inherit version; + }; + + default = packages'.getchvim; }); }; } diff --git a/neovim.nix b/neovim.nix index b42ccbd..648c58b 100644 --- a/neovim.nix +++ b/neovim.nix @@ -1,19 +1,23 @@ -self: { +{ lib, - pkgs, + neovimUtils, + vimPlugins, + wrapNeovimUnstable, + neovim-unwrapped, + actionlint, + alejandra, + beautysh, + ripgrep, + efm-langserver, + nil, + nodePackages, + shellcheck, + statix, + typos-lsp, + vimPlugins-getchoo-nvim, ... }: let - config = pkgs.vimUtils.buildVimPlugin { - pname = "neovim-config"; - version = self.shortRev or self.dirtyShortRev or "unknown-dirty"; - - src = lib.fileset.toSource { - root = ./config; - fileset = lib.fileset.gitTracked ./config; - }; - }; - - plugins = with pkgs.vimPlugins; [ + plugins = with vimPlugins; [ bufferline-nvim # dependent on > nvim-web-devicons @@ -57,7 +61,7 @@ self: { which-key-nvim ]; - extraPackages = with pkgs; [ + extraPackages = [ # cmp ripgrep @@ -76,11 +80,11 @@ self: { typos-lsp ]; - neovimConfig = pkgs.neovimUtils.makeNeovimConfig { - plugins = plugins ++ [config]; + neovimConfig = neovimUtils.makeNeovimConfig { + plugins = plugins ++ [vimPlugins-getchoo-nvim]; }; in - pkgs.wrapNeovimUnstable pkgs.neovim-unwrapped ( + wrapNeovimUnstable neovim-unwrapped ( neovimConfig // { luaRcContent = '' -- cgit v1.2.3