From 87f375dea46afd579ba76fe2ac900418ad26706f Mon Sep 17 00:00:00 2001 From: Arthur Wambst Date: Fri, 21 Feb 2025 22:01:12 +0100 Subject: [PATCH] trying to add option to nvim module --- flake.lock | 25 +++++++++++++++++++++---- flake.nix | 27 +++++---------------------- modules/nvim/theme.nix | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 26 deletions(-) create mode 100644 modules/nvim/theme.nix diff --git a/flake.lock b/flake.lock index 1cbf157..eff62f1 100644 --- a/flake.lock +++ b/flake.lock @@ -185,11 +185,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1740162094, - "narHash": "sha256-QpD9XNR6tPPsYTavZw1o99Tcn3ILrp1SXr669Ru6vuY=", + "lastModified": 1740170230, + "narHash": "sha256-Clnn2Y+bx4LI2caUqtCxaYKKRLC4ifXVSgVZKJIskFA=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5525603a0c65072af1cd24cd2750fa33749e4943", + "rev": "f1c5d6d23fd57011b78cb2424f5c73e68c9e8879", "type": "github" }, "original": { @@ -214,11 +214,28 @@ "type": "github" } }, + "plugin-gruvbox": { + "flake": false, + "locked": { + "lastModified": 1738710709, + "narHash": "sha256-BBMDCIhwTvZQyeWug8zzUwV8uuqQIkpXtEpoErvAKFc=", + "owner": "ellisonleao", + "repo": "gruvbox.nvim", + "rev": "089b60e92aa0a1c6fa76ff527837cd35b6f5ac81", + "type": "github" + }, + "original": { + "owner": "ellisonleao", + "repo": "gruvbox.nvim", + "type": "github" + } + }, "root": { "inputs": { "neovim": "neovim", "nixpkgs": "nixpkgs", - "plugin-dracula": "plugin-dracula" + "plugin-dracula": "plugin-dracula", + "plugin-gruvbox": "plugin-gruvbox" } }, "treefmt-nix": { diff --git a/flake.nix b/flake.nix index 27aec44..c9eb3d4 100644 --- a/flake.nix +++ b/flake.nix @@ -13,30 +13,13 @@ url = "github:Mofiqul/dracula.nvim"; flake = false; }; + plugin-gruvbox = { + url = "github:ellisonleao/gruvbox.nvim"; + flake = false; + }; }; outputs = { self, nixpkgs, neovim, ... }@inputs: { - nixosModules.neovim = { config, pkgs, ...}: { - # Installation de Neovim en tant que package système - environment.systemPackages = [ neovim.packages.${pkgs.system}.neovim ]; - - - - # Activer nvim - programs.neovim = { - enable = true; - - # Native way to configure Neovim - configure = { - customRC = '' - " Add Dracula to runtimepath - set runtimepath+=${inputs.plugin-dracula} - - " Enable Dracula colorscheme - colorscheme dracula - ''; - }; + neovim = import ./modules/nvim.nix; }; - }; - }; } diff --git a/modules/nvim/theme.nix b/modules/nvim/theme.nix new file mode 100644 index 0000000..c1ce801 --- /dev/null +++ b/modules/nvim/theme.nix @@ -0,0 +1,32 @@ +{ config, pkgs, lib, inputs, ... }: +with lib; { + options.programs.neovim.theme = mkOption { + type = types.enum [ "dracula" "gruvbox" "tokyonight" ]; + default = "dracula"; + description = "Choose the Neovim theme."; + }; + + config = let + themePackage = { + "dracula" = inputs.plugin-dracula; + "gruvbox" = inputs.plugin-gruvbox; + "tokyonight" = null; # No flake input, assumes user manages it manually + }.${config.programs.neovim.theme} or null; + in { + environment.systemPackages = [ inputs.neovim.packages.${pkgs.system}.neovim ]; + + programs.neovim = { + enable = true; + configure = { + customRC = '' + " Add Dracula to runtimepath + set runtimepath+=${config.programs.neovim.theme} + + " Enable Dracula colorscheme + colorscheme dracula + ''; + }; + }; + }; +} +