Skip to content

Commit

Permalink
Merge pull request #62 from TheColorman/main
Browse files Browse the repository at this point in the history
Make `chadrc.lua` configurable
  • Loading branch information
Bot-wxt1221 authored Oct 28, 2024
2 parents eb0b540 + c2430bf commit 087461e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,12 @@ Overriding the option will expand this list.

The config written in lua. It will be loaded after nvchad loaded.

#### chadrcConfig (optional)

`string`

Configuration that replaces chadrc.lua. Make sure to include `local M = {}` at the top, and `return M` at the bottom.

##### gcc (optional)

`pkg.gcc`
Expand Down
6 changes: 6 additions & 0 deletions nix/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ let
gcc_new = cfg.gcc;
starterRepo = nvchad-starter;
extraConfig = cfg.extraConfig;
chadrcConfig = cfg.chadrcConfig;
lazy-lock = cfg.lazy-lock;
extraPlugins = cfg.extraPlugins;
};
Expand Down Expand Up @@ -71,6 +72,11 @@ in
default = "";
description = "These config are loaded after nvchad in the end of init.lua in starter";
};
chadrcConfig = mkOption {
type = types.str;
default = "";
description = "This config replaces the chadrc.lua file. Make sure to include `local M = {}` at the top, and `return M` at the bottom.";
};
gcc = mkOption {
type = types.package;
default = pkgs.gcc;
Expand Down
4 changes: 4 additions & 0 deletions nix/nvchad.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
tree-sitter,
extraPackages ? [ ], # the default value is for import from flake.nix
extraConfig ? "",
chadrcConfig ? "",
starterRepo,
extraPlugins ? "return {}",
lazy-lock ? "",
Expand All @@ -30,6 +31,7 @@ let
makeBinPath
licenses
maintainers
optionalString
;
in
stdenvNoCC.mkDerivation (finalAttrs: {
Expand All @@ -53,6 +55,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {
end
return M1
'';
NewChadrcFile = writeText "chadrc.lua" chadrcConfig;
LockFile = writeText "lazy-lock.json" lazy-lock;
nativeBuildInputs =
(lists.unique (
Expand All @@ -77,6 +80,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {
chmod 777 $out/config
chmod 777 $out/config/lua # cp make it unwritable
chmod 777 $out/config/lua/plugins
${optionalString (chadrcConfig != "") "install -Dm777 $NewChadrcFile $out/config/lua/chadrc.lua"}
mv $out/config/lua/plugins/init.lua $out/config/lua/plugins/init-1.lua
install -Dm777 $extraPluginsFile $out/config/lua/plugins/init-2.lua
install -Dm777 $NewPluginsFile $out/config/lua/plugins/init.lua
Expand Down

0 comments on commit 087461e

Please sign in to comment.