Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@

inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
nvchad-starter.url = "github:NvChad/starter/main"; # people who want to use diffrent starter could override this.
nvchad-starter.flake = false;
nvchad-starter = {
url = "github:NvChad/starter/main"; # people who want to use a different starter could override this.
flake = false;
};
};

outputs =
Expand Down
84 changes: 46 additions & 38 deletions nix/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,22 @@
# █▀█ █░▀░█ ░░ █░▀░█ █▄█ █▄▀ █▄█ █▄▄ ██▄ ▄
# -- -- -- -- -- -- -- -- -- -- -- -- -- -

{
nvchad-starter,
}:
{ nvchad-starter }:
{
pkgs,
config,
lib ? pkgs.lib,
...
}:
let
inherit (lib)
mkEnableOption
types
mkOption
literalExpression
mkIf
hm
;
cfg = config.programs.nvchad;
nvchad = pkgs.callPackage ./nvchad.nix {
neovim = cfg.neovim;
Expand All @@ -24,7 +30,7 @@ let
};
in
{
options.programs.nvchad = with lib; {
options.programs.nvchad = {
enable = mkEnableOption "Enable NvChad";
extraPackages = mkOption {
type = types.listOf types.package;
Expand Down Expand Up @@ -55,7 +61,7 @@ in
defaultText = literalExpression "pkgs.neovim";
description = "neovim package for use under nvchad wrapper";
};
extraPlugins = mkOption{
extraPlugins = mkOption {
type = types.str;
default = "return {}";
description = "The extra plugins you want to install. That's a part of lazy.nvim config.";
Expand Down Expand Up @@ -105,8 +111,6 @@ in
};
};
config =
with pkgs;
with lib;
let
confDir = "${config.xdg.configHome}/nvim";
in
Expand All @@ -129,38 +133,42 @@ in
];
home = {
packages = [ nvchad ];
activation = mkIf cfg.hm-activation {
backupNvChad = hm.dag.entryBefore [ "checkLinkTargets" ] ''
if [ -d "${confDir}" ]; then
${
(
if cfg.backup then
''
backup_name="nvim_$(${coreutils}/bin/date +'%Y_%m_%d_%H_%M_%S').bak"
${coreutils}/bin/mv \
${confDir} \
${config.xdg.configHome}/$backup_name
''
else
''
${coreutils}/bin/rm -r ${confDir}
''
)
}
fi
'';
copyNvChad = hm.dag.entryAfter [ "writeBoundary" ] ''
${coreutils}/bin/mkdir ${confDir}
${coreutils}/bin/cp -r ${nvchad}/config/* ${confDir}
for file_or_dir in $(${findutils}/bin/find ${confDir}); do
if [ -d "$file_or_dir" ]; then
${coreutils}/bin/chmod 755 $file_or_dir
else
${coreutils}/bin/chmod 664 $file_or_dir
activation =
let
coreutils = pkgs.coreutils;
in
mkIf cfg.hm-activation {
backupNvChad = hm.dag.entryBefore [ "checkLinkTargets" ] ''
if [ -d "${confDir}" ]; then
${
(
if cfg.backup then
''
backup_name="nvim_$(${coreutils}/bin/date +'%Y_%m_%d_%H_%M_%S').bak"
${coreutils}/bin/mv \
${confDir} \
${config.xdg.configHome}/$backup_name
''
else
''
${coreutils}/bin/rm -r ${confDir}
''
)
}
fi
done
'';
};
'';
copyNvChad = hm.dag.entryAfter [ "writeBoundary" ] ''
${coreutils}/bin/mkdir ${confDir}
${coreutils}/bin/cp -r ${nvchad}/config/* ${confDir}
for file_or_dir in $(${pkgs.findutils}/bin/find ${confDir}); do
if [ -d "$file_or_dir" ]; then
${coreutils}/bin/chmod 755 $file_or_dir
else
${coreutils}/bin/chmod 664 $file_or_dir
fi
done
'';
};
};
};
}
15 changes: 11 additions & 4 deletions nix/nvchad.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@
extraPlugins ? "return {}",
lazy-lock ? "",
}:
with lib;
stdenvNoCC.mkDerivation rec {
let
inherit (lib)
lists
makeBinPath
licenses
maintainers
;
in
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "nvchad";
version = "2.5";
src = starterRepo;
Expand Down Expand Up @@ -78,7 +85,7 @@ stdenvNoCC.mkDerivation rec {
install -Dm777 "$extraConfigFile" $out/config/lua/extraConfig.lua;
mv $out/config/init.lua $out/config/lua/init.lua
install -Dm777 $NewInitFile $out/config/init.lua
wrapProgram $out/bin/nvim --prefix PATH : '${makeBinPath nativeBuildInputs}'
wrapProgram $out/bin/nvim --prefix PATH : '${makeBinPath finalAttrs.nativeBuildInputs}'
runHook postInstall
'';
postInstall = ''
Expand All @@ -98,4 +105,4 @@ stdenvNoCC.mkDerivation rec {
bot-wxt1221
];
};
}
})