This commit is contained in:
joygnu 2024-07-04 08:07:16 +02:00
parent 88bdcca926
commit 84191dac3e
6 changed files with 7 additions and 209 deletions

View file

@ -9,7 +9,6 @@
./gtk ./gtk
./git ./git
./ags ./ags
./neovim
inputs.nix-colors.homeManagerModules.default inputs.nix-colors.homeManagerModules.default
inputs.ags.homeManagerModules.default inputs.ags.homeManagerModules.default
]; ];

View file

@ -1,7 +0,0 @@
#!/usr/bin/env bash
# Start cmus in a screen session named 'cmus_session'
screen -S cmus_session -dm cmus
echo "cmus started in screen session 'cmus_session'. Use 'screen -r cmus_session' to attach."

View file

@ -1,114 +0,0 @@
{ 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;
};
};
};
}

View file

@ -1,87 +0,0 @@
#!/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)

View file

@ -23,6 +23,11 @@ programs.gnupg.agent = {
enableSSHSupport = true; enableSSHSupport = true;
}; };
programs.neovim = {
enable = true;
defaultEditor = true;
};
programs.hyprland.enable = true; programs.hyprland.enable = true;
users.defaultUserShell = pkgs.zsh; users.defaultUserShell = pkgs.zsh;
programs.zsh.enable = true; programs.zsh.enable = true;

View file

@ -41,6 +41,8 @@
gnome-calculator gnome-calculator
gnome-disk-utility gnome-disk-utility
#random utils #random utils
gnat14
libgccjit
tree tree
rofi-wayland rofi-wayland
screen screen