diff --git a/flake.nix b/flake.nix index 2135076..ed17fca 100644 --- a/flake.nix +++ b/flake.nix @@ -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 = diff --git a/nix/module.nix b/nix/module.nix index 6aa09a5..4638965 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -2,9 +2,7 @@ # █▀█ █░▀░█ ░░ █░▀░█ █▄█ █▄▀ █▄█ █▄▄ ██▄ ▄ # -- -- -- -- -- -- -- -- -- -- -- -- -- - -{ - nvchad-starter, -}: +{ nvchad-starter }: { pkgs, config, @@ -12,6 +10,14 @@ ... }: let + inherit (lib) + mkEnableOption + types + mkOption + literalExpression + mkIf + hm + ; cfg = config.programs.nvchad; nvchad = pkgs.callPackage ./nvchad.nix { neovim = cfg.neovim; @@ -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; @@ -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."; @@ -105,8 +111,6 @@ in }; }; config = - with pkgs; - with lib; let confDir = "${config.xdg.configHome}/nvim"; in @@ -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 + ''; + }; }; }; } diff --git a/nix/nvchad.nix b/nix/nvchad.nix index bb67b30..2b653ad 100644 --- a/nix/nvchad.nix +++ b/nix/nvchad.nix @@ -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; @@ -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 = '' @@ -98,4 +105,4 @@ stdenvNoCC.mkDerivation rec { bot-wxt1221 ]; }; -} +})