chore: restructure home manager config

Signed-off-by: Lander Van den Bulcke <landervandenbulcke@gmail.com>
This commit is contained in:
Lander Van den Bulcke 2024-08-29 08:47:24 +02:00
parent 8bf002c44e
commit fe0e45b873
Signed by: lander
GPG key ID: 0142722B4B0C536F
10 changed files with 32 additions and 11 deletions

View file

@ -12,10 +12,7 @@ in
imports = [
inputs.catppuccin.homeManagerModules.catppuccin
./git
./starship.nix
./vim.nix
./zsh.nix
../features/cli
];
home = {
@ -32,11 +29,7 @@ in
};
programs = {
eza.enable = true;
git.enable = true;
gpg.enable = true;
home-manager.enable = true;
jq.enable = true;
};
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion

View file

@ -1,69 +0,0 @@
# adapted from https://pickard.cc/posts/git-identity-home-manager/
{ config, lib, pkgs, ...}:
let
# put a shell script into the nix store
gitIdentity =
pkgs.writeShellScriptBin "git-identity" (builtins.readFile ./git-identity);
in {
# we will use the excellent fzf in our `git-identity` script, so let's make sure it's available
# let's add the gitIdentity script to the path as well
home.packages = with pkgs; [
gitIdentity
fzf
];
programs.git = {
enable = true;
package = pkgs.gitAndTools.gitFull;
extraConfig = {
# extremely important, otherwise git will attempt to guess a default user identity. see `man git-config` for more details
user.useConfigOnly = true;
# the `inuits` identity
user.inuits.name = "Lander Van den Bulcke";
user.inuits.email = "landervdb@inuits.eu";
# the `olly` identity
user.olly.name = "Lander Van den Bulcke";
user.olly.email = "landervdb@o11y.eu";
# the `paynovate` identity
user.paynovate.name = "Lander Van den Bulcke";
user.paynovate.email = "lander.vandenbulcke@paynovate.com";
# the `personal` identity
user.personal.name = "Lander Van den Bulcke";
user.personal.email = "landervandenbulcke@gmail.com";
# editor
core.editor = "vim";
# line up default branch with github/codeberg/forgejo
init.defaultBranch = "main";
# always rebase xx
pull.rebase = true;
push.autoSetupRemote = true;
rebase.autosquash = true;
commit.verbose = true;
diff.algorithm = "histogram";
transfer.fsckobjects = true;
fetch.fsckobjects = true;
receive.fsckObjects = true;
rerere.enabled = true;
# sign your commits!
commit.gpgsign = true;
};
# This is optional, as `git identity` will call the `git-identity` script by itself, however
# setting it up explicitly as an alias gives you autocomplete
aliases = {
identity = "! git-identity";
id = "! git-identity";
};
};
}

View file

@ -1,16 +0,0 @@
#!/usr/bin/env bash
# get each set of usernames from the git config
IDENTITIES=$(git config --global --name-only --get-regexp "user.*..name" | sed -e 's/^user.//' -e 's/.name$//')
# filter them with fzf
ID=$(echo "${IDENTITIES}" | fzf -e -1 +m -q "$1")
if ! git config --global --get-regexp "user.${ID}.name" > /dev/null; then
echo "Please use a valid git identity
Options:"
git config --global --name-only --get-regexp "user.*..name" | sed -e 's/^user.//' -e 's/.name$//' -e 's/^/\t/'
exit 1
fi
# set the id locally in each repo (eg in the repo's .git/config)
git config user.name "$(git config user.${ID}.name)"
git config user.email "$(git config user.${ID}.email)"

View file

@ -1,89 +0,0 @@
{ lib, ... }:
{
programs = {
starship = {
enable = true;
enableZshIntegration = true;
settings = lib.mkDefault {
format = lib.concatStrings [
"$username"
"$hostname"
"$directory"
"$git_branch"
"$git_state"
"$git_status"
"$nix_shell"
"$fill"
"$python"
"$golang"
"$status"
"$line_break"
"$character"
];
fill.symbol = " ";
hostname.ssh_symbol = "";
python.format = "([ $virtualenv]($style)) ";
rust.symbol = " ";
status.disabled = false;
username.format = "[$user]($style)@";
character = {
success_symbol = "[](purple)";
error_symbol = "[](red)";
vicmd_symbol = "[](green)";
};
directory = {
read_only = " ";
home_symbol = " ~";
style = "blue";
truncate_to_repo = false;
truncation_length = 5;
truncation_symbol = ".../";
};
docker_context.symbol = " ";
git_branch = {
symbol = " ";
format = "[ $branch]($style)";
style = "green";
};
git_status = {
format = "[[( $conflicted$untracked$modified$staged$renamed$deleted)](218) ($ahead_behind$stashed)]($style)";
style = "cyan";
conflicted = "=$count ";
untracked = "?$count ";
modified = "!$count ";
staged = "+$count ";
renamed = "»$count ";
deleted = "$count ";
stashed = "";
};
git_state = {
format = "\([$state( $progress_current/$progress_total)]($style)\) ";
style = "bright-black";
};
golang = {
symbol = " ";
format = "[$symbol$version](cyan bold) ";
};
kubernetes = {
disabled = false;
format = "[$symbol$context](cyan bold) ";
};
nix_shell = {
disabled = false;
symbol = " ";
format = "via [$symbol\($name\)]($style)";
};
};
};
};
}

View file

@ -1,87 +0,0 @@
{ pkgs, ... }:
{
programs.neovim = {
enable = true;
package = pkgs.neovim-unwrapped;
catppuccin.enable = true;
viAlias = true;
vimAlias = true;
vimdiffAlias = true;
extraLuaConfig = ''
vim.opt.autochdir = true
vim.opt.backup = false
vim.opt.autoindent = true
vim.opt.cindent = true
vim.opt.smartindent = true
vim.opt.expandtab = true
vim.opt.shiftwidth = 2
vim.opt.smarttab = true
vim.opt.softtabstop = 2
vim.opt.tabstop = 2
vim.opt.backspace = "indent,eol,start"
vim.g.mapleader = ';'
vim.g.maplocalleader = ';'
vim.opt.hlsearch = true
vim.opt.ignorecase = true
vim.opt.showmatch = true
vim.opt.number = true
vim.opt.background = dark
vim.opt.termguicolors = true
function map(mode, lhs, rhs, opts)
local options = {noremap = true, silent = true}
if opts then
options = vim.tbl_extend("force", options, opts)
end
vim.keymap.set(mode, lhs, rhs, options)
end
map('n', '<leader>t', ':ToggleTerm<CR>' )
map('i', '<leader><leader>', '<Esc>' )
map('t', '<Esc>', '<C-\\><C-n>' )
map('n', '<leader>p', ':NvimTreeToggle<CR>' )
map('n', '<leader><Space>', ':NvimTreeToggle<CR>' )
map('n', '<leader>ff', ':Telescope find_files<CR>')
map('n', '<leader>fg', ':Telescope live_grep<CR>' )
map('n', '<leader>fb', ':Telescope buffers<CR>' )
map('n', '<leader>fh', ':Telescope help_tags<CR>' )
map('n', '<leader>fo', ':Telescope vim_options<CR>' )
vim.cmd.colorscheme "catppuccin"
'';
plugins = with pkgs.vimPlugins; [
nvim-web-devicons
telescope-nvim
vim-nix
vim-visual-multi
{
plugin = nvim-comment;
type = "lua";
config = ''
require('nvim_comment').setup()
'';
}
{
plugin = nvim-tree-lua;
type = "lua";
config = ''
require('nvim-tree').setup({ update_cwd = true })
'';
}
{
plugin = lightline-vim;
type = "viml";
config = ''
let g:lightline = {'colorscheme': 'catppuccin'}
'';
}
];
};
}

View file

@ -1,98 +0,0 @@
{
programs = {
zsh = {
enable = true;
dotDir = ".config/zsh";
enableCompletion = true;
autosuggestion.enable = true;
syntaxHighlighting = {
enable = true;
catppuccin.enable = true;
};
history = {
save = 10000;
size = 10000;
path = "$HOME/.cache/zsh_history";
};
initExtra = ''
bindkey '^[[1;5C' forward-word # Ctrl+RightArrow
bindkey '^[[1;5D' backward-word # Ctrl+LeftArrow
zstyle ':completion:*' completer _complete _match _approximate
zstyle ':completion:*:match:*' original only
zstyle ':completion:*:approximate:*' max-errors 1 numeric
zstyle ':completion:*' menu select
zstyle ':completion:*' list-colors "''${(s.:.)LS_COLORS}"
# HACK! Simple shell function to patch ruff bins downloaded by tox from PyPI to use
# the ruff included in NixOS - needs to be run each time the tox enviroment is
# recreated
patch_tox_ruff() {
for x in $(find .tox -name ruff -type f -print); do
rm $x;
ln -sf $(which ruff) $x;
done
}
clean-crafts-lxc() {
for CRAFT in snapcraft rockcraft charmcraft; do
lxc --project $CRAFT list -fcsv -cn | xargs lxc --project $CRAFT delete -f >/dev/null
done
}
export EDITOR=vim
'';
shellAliases = {
ls = "eza -gl --git --color=automatic";
tree = "eza --tree";
cat = "bat";
ip = "ip --color";
ipb = "ip --color --brief";
gac = "git add -A && git commit -a";
gp = "git push";
gst = "git status -sb";
htop = "btm -b";
neofetch = "fastfetch";
tf = "terraform";
tfi = "terraform init";
tfp = "terraform plan";
tfa = "terraform apply -auto-approve";
tfd = "terraform destroy -auto-approve";
tfo = "terraform output -json";
wgu = "sudo wg-quick up";
wgd = "sudo wg-quick down";
ts = "tailscale";
tst = "tailscale status";
tsu = "tailscale up --ssh --operator=$USER";
tsd = "tailscale down";
js = "juju status";
jsw = "juju status --watch 1s --color";
jsrw = "juju status --watch 1s --color --relations";
jdl = "juju debug-log";
open = "xdg-open";
k = "kubectl";
opget = "op item get \"$(op item list --format=json | jq -r '.[].title' | fzf)\"";
speedtest = "curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python -";
cleanup-nix = "nh clean all --keep-since 10d --keep 3";
rln = "nh os switch /home/lander/git/nix-config";
rlh = "nh home switch /home/lander/git/nix-config";
rlb = "rln;rlh";
};
};
};
}