rb
This commit is contained in:
parent
2dae5069e3
commit
d3e40bca54
|
@ -9,27 +9,11 @@
|
|||
./gtk
|
||||
./git
|
||||
./ags
|
||||
./neovim
|
||||
inputs.nix-colors.homeManagerModules.default
|
||||
inputs.ags.homeManagerModules.default
|
||||
];
|
||||
|
||||
programs.neovim.enable = true;
|
||||
|
||||
xdg.configFile."nvim".source = pkgs.stdenv.mkDerivation {
|
||||
name = "NvChad";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "NvChad";
|
||||
repo = "NvChad";
|
||||
rev = "f17e83010f25784b58dea175c6480b3a8225a3e9";
|
||||
hash = "sha256-P5TRjg603/7kOVNFC8nXfyciNRLsIeFvKsoRCIwFP3I=";
|
||||
};
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cp -r ./* $out/
|
||||
cd $out/
|
||||
cp -r ${./my_nvchad_config} $out/lua/custom
|
||||
'';
|
||||
};
|
||||
|
||||
home.username = "joy";
|
||||
home.homeDirectory = "/home/joy";
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 82c9711f62025c16d138c0bc6e8b7cf46ca6ccc5
|
114
home/neovim/default.nix
Normal file
114
home/neovim/default.nix
Normal file
|
@ -0,0 +1,114 @@
|
|||
{ flake
|
||||
, config
|
||||
, pkgs
|
||||
, lib
|
||||
, ...
|
||||
}:
|
||||
|
||||
|
||||
let
|
||||
inherit (lib) concatStringsSep optional;
|
||||
inherit (config.lib.file) mkOutOfStoreSymlink;
|
||||
|
||||
cfg = config.programs.neovim;
|
||||
|
||||
home = config.home.homeDirectory;
|
||||
populateEnv = ./populate-nvim-env.py;
|
||||
|
||||
populateEnvScript = openapi_path: ''
|
||||
mkdir -p ${config.xdg.dataHome}/nvim/site/plugin
|
||||
${pkgs.python39}/bin/python ${populateEnv} -o ${config.xdg.dataHome}/nvim/site/plugin --openapi_path "${openapi_path}"
|
||||
'';
|
||||
in
|
||||
{
|
||||
# Neovim
|
||||
|
||||
# https://rycee.gitlab.io/home-manager/options.html#opt-programs.neovim.enable
|
||||
programs.neovim = {
|
||||
enable = true;
|
||||
viAlias = true;
|
||||
vimAlias = true;
|
||||
defaultEditor = true;
|
||||
package = pkgs.neovim-nightly;
|
||||
extraLuaPackages = ps: [ ps.magick ];
|
||||
};
|
||||
|
||||
# xdg.configFile."nvim" = {
|
||||
# source = config.lib.file.mkOutOfStoreSymlink "${home}/.config/nvim";
|
||||
# recursive = true;
|
||||
# };
|
||||
|
||||
home.packages = with pkgs.unstable; [
|
||||
tree-sitter
|
||||
lua-language-server
|
||||
stylua
|
||||
shfmt
|
||||
|
||||
# python
|
||||
python311Packages.flake8
|
||||
python311Packages.black
|
||||
python311Packages.python-lsp-server
|
||||
|
||||
# web stuff
|
||||
nodePackages_latest.prettier
|
||||
nodePackages_latest.eslint_d
|
||||
nodePackages_latest.vscode-langservers-extracted
|
||||
nodePackages_latest.typescript-language-server
|
||||
|
||||
# rust
|
||||
rust-analyzer
|
||||
rustfmt
|
||||
|
||||
# config
|
||||
taplo
|
||||
|
||||
# nix
|
||||
nixpkgs-fmt
|
||||
rnix-lsp
|
||||
|
||||
(pkgs.writeShellScriptBin "update-nvim-env" ''
|
||||
#
|
||||
# update-nvim-env
|
||||
#
|
||||
# Update neovim env such that it can be used in neovide or other GUIs.
|
||||
|
||||
${populateEnvScript config.sops.secrets.openapi-key.path}
|
||||
'')
|
||||
(pkgs.writeShellScriptBin "clean-nvim-all" ''
|
||||
rm -rf ${config.xdg.dataHome}/nvim
|
||||
rm -rf ${config.xdg.cacheHome}/nvim
|
||||
rm -rf ${config.xdg.stateHome}/nvim
|
||||
rm -rf ${config.xdg.configHome}/nvim
|
||||
'')
|
||||
(pkgs.writeShellScriptBin "clean-nvim" ''
|
||||
rm -rf ${config.xdg.dataHome}/nvim
|
||||
rm -rf ${config.xdg.stateHome}/nvim
|
||||
rm -rf ${config.xdg.cacheHome}/nvim
|
||||
'')
|
||||
];
|
||||
|
||||
home.activation.neovim = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
|
||||
echo "Populating neovim env..."
|
||||
${populateEnvScript config.sops.secrets.openapi-key.path}
|
||||
'';
|
||||
|
||||
programs.zsh.initExtra = lib.mkIf cfg.enable (lib.mkAfter ''
|
||||
# alias n="${pkgs.neovim}/bin/nvim"
|
||||
'');
|
||||
|
||||
|
||||
sops = {
|
||||
age.keyFile = "${home}/.config/sops/age/keys.txt";
|
||||
age.generateKey = true;
|
||||
secrets = {
|
||||
openapi-key = {
|
||||
# owner = "rayandrew";
|
||||
mode = "0440";
|
||||
sopsFile = ../../secrets.yaml;
|
||||
# path = "%r/openapi-key.txt";
|
||||
path = "${config.home.homeDirectory}/.openai_api_key";
|
||||
# neededForUsers = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
87
home/neovim/populate-nvim-env.py
Normal file
87
home/neovim/populate-nvim-env.py
Normal file
|
@ -0,0 +1,87 @@
|
|||
#!/bin/env python3
|
||||
|
||||
import os
|
||||
from collections import OrderedDict
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
KEYS = [
|
||||
# PATH
|
||||
"PATH",
|
||||
"CS154_ADMIN",
|
||||
"BREW_PREFIX",
|
||||
"CONDA_PYTHON_EXE",
|
||||
"SPACESHIP_ROOT",
|
||||
"COLORFGBG",
|
||||
"XPC_SERVICE_NAME",
|
||||
"_CE_M",
|
||||
"XPC_FLAGS",
|
||||
"LANG",
|
||||
# terminal
|
||||
"VISUAL",
|
||||
"LESS",
|
||||
"LOGNAME",
|
||||
"COLORTERM",
|
||||
"HISTFILE",
|
||||
"LC_TERMINAL",
|
||||
"LC_TERMINAL_VERSION",
|
||||
"ITERM_SESSION_ID",
|
||||
"ITERM_PROFILE",
|
||||
"TERM_SESSION_ID",
|
||||
"TERM_PROGRAM",
|
||||
"STARSHIP_SESSION_KEY",
|
||||
"STARSHIP_CONFIG",
|
||||
"VI_MODE_SET_CURSOR",
|
||||
"_",
|
||||
"LSCOLORS",
|
||||
"ZSH",
|
||||
"EDITOR",
|
||||
# XDG
|
||||
"XDG_DATA_HOME",
|
||||
"XDG_STATE_HOME",
|
||||
"XDG_CACHE_HOME",
|
||||
"XDG_CONFIG_HOME",
|
||||
]
|
||||
|
||||
|
||||
def main(args):
|
||||
env = os.environ.copy()
|
||||
env = OrderedDict(sorted(env.items()))
|
||||
dst_file = "{}/env.lua".format(args.output_path)
|
||||
|
||||
openapi_key = None
|
||||
|
||||
if args.openapi_path != "":
|
||||
openapi_path = Path(args.openapi_path)
|
||||
if openapi_path.exists():
|
||||
with open(openapi_path, "r") as f:
|
||||
openapi_key = f.readline().strip("\n")
|
||||
|
||||
with open(dst_file, "w") as f:
|
||||
for key, value in env.items():
|
||||
if key in KEYS:
|
||||
if key == "PATH":
|
||||
f.write('vim.env.PATH = vim.env.PATH .. ":{}"\n'.format(value))
|
||||
continue
|
||||
f.write('vim.fn.setenv("{}", "{}")\n'.format(key, value))
|
||||
|
||||
if openapi_key is not None:
|
||||
f.write('vim.fn.setenv("OPENAI_API_KEY", "{}")\n'.format(openapi_key))
|
||||
|
||||
f.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
home_directory = os.path.expanduser("~")
|
||||
parser = argparse.ArgumentParser("Neovim Populate Env")
|
||||
parser.add_argument("--openapi_path", required=False, type=str, default="")
|
||||
parser.add_argument(
|
||||
"-o",
|
||||
"--output_path",
|
||||
required=False,
|
||||
help="Output Path",
|
||||
type=str,
|
||||
default="{}/.config/nvim/lua/rayandrew".format(home_directory),
|
||||
)
|
||||
args = parser.parse_args()
|
||||
main(args)
|
|
@ -55,6 +55,7 @@
|
|||
boxbuddy
|
||||
distrobox
|
||||
neovim
|
||||
python3
|
||||
cl
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue