chore: reorganise common modules
Signed-off-by: Lander Van den Bulcke <landervandenbulcke@gmail.com>
This commit is contained in:
parent
eebd71f003
commit
7230527d95
13 changed files with 109 additions and 124 deletions
33
home/lander/global/default.nix
Normal file
33
home/lander/global/default.nix
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
inputs,
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
imports = [
|
||||
./git
|
||||
];
|
||||
|
||||
home = {
|
||||
username = "lander";
|
||||
homeDirectory = "/home/lander";
|
||||
};
|
||||
|
||||
programs.home-manager.enable = true;
|
||||
programs.git.enable = true;
|
||||
|
||||
programs.neovim = {
|
||||
enable = true;
|
||||
vimAlias = true;
|
||||
vimdiffAlias = true;
|
||||
defaultEditor = false;
|
||||
};
|
||||
|
||||
|
||||
# Nicely reload system units when changing configs
|
||||
systemd.user.startServices = "sd-switch";
|
||||
|
||||
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
|
||||
home.stateVersion = "23.05";
|
||||
}
|
||||
69
home/lander/global/git/default.nix
Normal file
69
home/lander/global/git/default.nix
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
# 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";
|
||||
};
|
||||
};
|
||||
}
|
||||
16
home/lander/global/git/git-identity
Normal file
16
home/lander/global/git/git-identity
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#!/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)"
|
||||
Loading…
Add table
Add a link
Reference in a new issue