From d2435f65cf1062a542463d03a4ae60f322c63306 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Sat, 28 Dec 2024 01:36:12 +0100 Subject: [PATCH] Add config as an overlay --- flake.nix | 38 ++++++++++++++++++++++--------------- modules/cli/zsh/default.nix | 2 +- nvim/default.nix | 8 +++++--- nvim/nix/mknvim.nix | 6 ++---- 4 files changed, 31 insertions(+), 23 deletions(-) diff --git a/flake.nix b/flake.nix index bdce7f7..6276896 100644 --- a/flake.nix +++ b/flake.nix @@ -64,12 +64,19 @@ overlays = { nixpkgs.overlays = [ (import ./overlays inputs) - neovim-nightly.overlays.default + nvim-overlay ]; }; mkSystem = import ./lib/mksystem.nix (inputs // {inherit overlays inputs;}); eachSystem = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed; + + nvim-overlay = final: prev: + import ./nvim (inputs + // { + pkgs = prev.pkgs; + lib = nixpkgs.lib; + }); in { nixosConfigurations.fuhen = mkSystem "fuhen" { env = "river"; @@ -112,32 +119,33 @@ }; packages = eachSystem (system: let - pkgs = nixpkgs.legacyPackages.${system}; - vim = import ./nvim (inputs - // { - inherit pkgs; - lib = nixpkgs.lib; - }); + pkgs = import nixpkgs { + inherit system; + overlays = [nvim-overlay]; + }; in rec { default = nvim; - nvim = vim.nvim; + nvim = pkgs.nvim; }); devShells = eachSystem (system: let - pkgs = nixpkgs.legacyPackages.${system}; - vim = import ./nvim (inputs - // { - inherit pkgs; - lib = nixpkgs.lib; - }); + pkgs = import nixpkgs { + inherit system; + overlays = [nvim-overlay]; + }; in rec { default = nvim-lua; nvim-lua = pkgs.mkShell { name = "nvim-lua"; shellHook = '' - ln -fs ${vim.luarc} .luarc.json + ln -fs ${pkgs.nvim-luarc} .luarc.json ''; }; }); + + overlays = rec { + default = nvim; + nvim = nvim-overlay; + }; }; } diff --git a/modules/cli/zsh/default.nix b/modules/cli/zsh/default.nix index 9b4297a..99ec0ed 100644 --- a/modules/cli/zsh/default.nix +++ b/modules/cli/zsh/default.nix @@ -23,9 +23,9 @@ glow gh yq - alejandra nodePackages.http-server nodePackages.live-server + nvim ] ++ lib.optionals pkgs.stdenv.isLinux [ usbutils diff --git a/nvim/default.nix b/nvim/default.nix index a4dfcda..1816614 100644 --- a/nvim/default.nix +++ b/nvim/default.nix @@ -1,11 +1,12 @@ { pkgs, + lib, neovim-nightly, lz-nvim, vim-lumen, ... }: let - mkNvim = pkgs.callPackage ./nix/mknvim.nix {inherit pkgs;}; + mkNvim = import ./nix/mknvim.nix {inherit pkgs lib;}; mkPlugin = src: pname: pkgs.vimUtils.buildVimPlugin { @@ -14,8 +15,6 @@ }; in mkNvim { - name = "nvim"; - withNodeJs = false; withRuby = false; withPython3 = false; @@ -135,6 +134,9 @@ in zls lua-language-server + # nix formatter + alejandra + # Give access to gdbus for color-scheme detection (vim-lumen). glib ]; diff --git a/nvim/nix/mknvim.nix b/nvim/nix/mknvim.nix index 55517ae..fc1bd45 100644 --- a/nvim/nix/mknvim.nix +++ b/nvim/nix/mknvim.nix @@ -1,10 +1,8 @@ { pkgs, lib, - stdenv, ... }: { - name ? "nvim", package ? pkgs.neovim, config, plugins ? { @@ -90,7 +88,7 @@ ${builtins.readFile (config + "/init.lua")} ''; in { - ${name} = pkgs.wrapNeovimUnstable nvim { + nvim = pkgs.wrapNeovimUnstable nvim { wrapRc = false; wrapperArgs = builtins.concatStringsSep " " [ (lib.optionals (extraPackages != []) ''--prefix PATH : "${lib.makeBinPath extraPackages}"'') @@ -100,5 +98,5 @@ in { inherit withPython3 withNodeJs withPerl withRuby extraPython3Packages extraLuaPackages; }; - luarc = mkLuarc { nvim = package; inherit plugins; }; + nvim-luarc = mkLuarc { nvim = package; inherit plugins; }; }