initial commit
This commit is contained in:
commit
e887d8bc7d
13 changed files with 490 additions and 0 deletions
69
home-manager/git/default.nix
Normal file
69
home-manager/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-manager/git/git-identity
Normal file
16
home-manager/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)"
|
||||
68
home-manager/home.nix
Normal file
68
home-manager/home.nix
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
# This is your home-manager configuration file
|
||||
# Use this to configure your home environment (it replaces ~/.config/nixpkgs/home.nix)
|
||||
{
|
||||
inputs,
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
# You can import other home-manager modules here
|
||||
imports = [
|
||||
# If you want to use home-manager modules from other flakes (such as nix-colors):
|
||||
# inputs.nix-colors.homeManagerModule
|
||||
|
||||
# You can also split up your configuration and import pieces of it here:
|
||||
# ./nvim.nix
|
||||
./git
|
||||
];
|
||||
|
||||
nixpkgs = {
|
||||
# You can add overlays here
|
||||
overlays = [
|
||||
# If you want to use overlays exported from other flakes:
|
||||
# neovim-nightly-overlay.overlays.default
|
||||
|
||||
# Or define it inline, for example:
|
||||
# (final: prev: {
|
||||
# hi = final.hello.overrideAttrs (oldAttrs: {
|
||||
# patches = [ ./change-hello-to-hi.patch ];
|
||||
# });
|
||||
# })
|
||||
];
|
||||
# Configure your nixpkgs instance
|
||||
config = {
|
||||
# Disable if you don't want unfree packages
|
||||
allowUnfree = true;
|
||||
# Workaround for https://github.com/nix-community/home-manager/issues/2942
|
||||
allowUnfreePredicate = _: true;
|
||||
};
|
||||
};
|
||||
|
||||
home = {
|
||||
username = "lander";
|
||||
homeDirectory = "/home/lander";
|
||||
};
|
||||
|
||||
# Add stuff for your user as you see fit:
|
||||
# programs.neovim.enable = true;
|
||||
# home.packages = with pkgs; [ steam ];
|
||||
|
||||
# Enable home-manager and git
|
||||
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";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue