NixOS/home/programs/neovim.nix

85 lines
2.1 KiB
Nix
Raw Normal View History

{ config, pkgs, lib, ... }:
let
cfg = config.profile.neovim;
inherit (lib) mkIf;
repository = "git@github.com:tigorlazuardi/nvim.git";
2024-06-17 17:28:32 +07:00
nvimCloneDir = "${config.home.homeDirectory}/.config/nvim";
in
2024-06-12 09:54:11 +07:00
{
config = mkIf cfg.enable {
systemd.user.services.clone-nvim = {
Unit = {
Description = "Clone neovim configuration if not exists";
Wants = [ "network-online.target" ];
After = [ "nss-lookup.target" ];
StartLimitIntervalSec = 300;
StartLimitBurst = 10;
};
Service =
let
git = "${pkgs.git}/bin/git";
bash = "${pkgs.bash}/bin/bash";
ping = "${pkgs.unixtools.ping}/bin/ping";
host = "github.com";
sleep = "${pkgs.coreutils}/bin/sleep";
2024-07-02 14:05:24 +07:00
script = pkgs.writeScriptBin "clone-nvim.sh" /*bash*/ ''
#!${bash}
2024-06-12 09:54:11 +07:00
if [ -d "${nvimCloneDir}" ]; then
exit 0;
fi
until ${ping} -c 1 ${host}; do
${sleep} 1;
done
mkdir -p ${nvimCloneDir}
${git} clone ${repository} ${nvimCloneDir}
'';
path = "${script}/bin/clone-nvim.sh";
in
{
Type = "simple";
2024-06-17 17:28:32 +07:00
ExecStart = "${bash} ${path}";
Restart = "on-failure";
RemainAfterExit = "yes";
Environment = [
''GIT_SSH_COMMAND=${pkgs.openssh}/bin/ssh -i ${config.sops.secrets."ssh/id_ed25519/private".path}''
];
};
Install = {
WantedBy = [ "default.target" ];
};
};
2024-06-12 19:19:13 +07:00
sops.secrets."copilot" = {
path = "${config.home.homeDirectory}/.config/github-copilot/hosts.json";
};
home.packages = with pkgs; [
stylua
docker-compose-language-service
emmet-ls
silicon # For code screenshots
2024-08-12 19:20:24 +07:00
lua-language-server
2024-08-13 08:03:48 +07:00
taplo
yaml-language-server
vscode-langservers-extracted
curl
cargo
nixpkgs-fmt
nil
gcc
python3
# Docker tools
dockerfile-language-server-nodejs
hadolint
];
};
2024-06-12 09:54:11 +07:00
}