Skip to content
Merged
26 changes: 26 additions & 0 deletions docs/cli/git-bug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
git-bug
=======

rel: 8f34a17

`git-bug` is used for issue tracking. The remote used is `origin` (git@github.com:rrvsh/tools).

Aliases:
- `gu`: runs `git push` and `git-bug push`.
- `gy`: runs `git pull` and `git-bug pull`.

A custom Starship module diffs `.git/refs/bugs/` against `.git/refs/remotes/origin/bugs/` and displays an 🐛 emoji when they are not in sync.

The `ssh-add` user service is a dependency, because git-bug requires the ssh-agent to have the private key saved and can't use the private key file as a fallback like git.

There was a bug in the nixpkgs derivation that resulted in fish shell completions being broken - fixed in [this PR](https://github.com/NixOS/nixpkgs/pull/529885).

Note that when running `git-bug pull` on an existing remote onto a new machine, you will be unable to adopt the identity of the existing user. You will have to create a new user for the bootstrap, then git-bug pull, then adopt the existing user. Here are the commands for this:

```sh
git update-ref -d refs/identities/<new-id>
rm -rf .git/git-bug/cache/identities .git/git-bug/indexes/identities
git reflog expire --expire=now --expire-unreachable=now --all
git gc --prune=now
```
See <https://github.com/git-bug/git-bug/issues/1003> for more information.
6 changes: 6 additions & 0 deletions docs/services/ssh-add.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ssh-add
=======

rel: 8f34a17

This runs as a user service to initialise the ssh-agent with my private key on login. This helps with `git-bug`, which requires the ssh agent to be configured instead of falling back to the private key file.
63 changes: 59 additions & 4 deletions nix/profiles/development.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,26 @@ in
pi-agent
yazi
];
home-manager.sharedModules = [ cfg.modules.homeManager.profile-development ];
home-manager.sharedModules = [
cfg.modules.homeManager.profile-development
(
{ config, ... }:
{
launchd.agents.ssh-add = {
enable = true;
config = {
ProgramArguments = [
"/bin/sh"
"-c"
"ssh-add ${config.home.homeDirectory}/.ssh/id_ed25519"
];
RunAtLoad = true;
KeepAlive = false;
};
};
}
)
];
};
nixos.profile-development = {
imports = with cfg.modules.nixos; [
Expand All @@ -27,18 +46,42 @@ in
yazi
];
networking.networkmanager.enable = true;
home-manager.sharedModules = [ cfg.modules.homeManager.profile-development ];
programs.ssh.startAgent = true;
home-manager.sharedModules = [
cfg.modules.homeManager.profile-development
(
{ pkgs, config, ... }:
{
systemd.user.services.ssh-add = {
Unit = {
Description = "Add SSH key to agent on login";
Wants = [ "ssh-agent.service" ];
After = [ "ssh-agent.service" ];
};
Service = {
Type = "oneshot";
Environment = "SSH_AUTH_SOCK=%t/ssh-agent";
ExecStart = "${pkgs.openssh}/bin/ssh-add ${config.home.homeDirectory}/.ssh/id_ed25519";
RemainAfterExit = true;
};
Install.WantedBy = [ "default.target" ];
};
}
)
];
};
homeManager.profile-development =
{ pkgs, ... }:
{
home.packages = with pkgs; [
git-bug
ddgr
gh
ripgrep
];
home.shellAliases = {
cd = "echo \"Please use z\"";
gb = "git-bug termui";
gc = "git commit";
gcam = "git commit -am";
gcamend = "git commit -a --amend --no-edit";
Expand All @@ -50,7 +93,8 @@ in
gds = "git diff --staged";
grc = "git rebase --continue";
gs = "git status";
gu = "git push";
gu = "git push && git-bug push";
gy = "git pull && git-bug pull";
v = "$EDITOR";
e = "fish -c 'set -e var; set var (sk); test -n \"$var\"; and $EDITOR $var'";
};
Expand All @@ -67,7 +111,7 @@ in
settings = {
add_newline = false;
format = lib.strings.concatStrings [
"$hostname$directory$git_branch$git_status$git_state"
"$hostname$directory$git_branch$git_status$git_state\${custom.git-bug}"
"$fill"
"$nix_shell"
"$time"
Expand All @@ -88,6 +132,17 @@ in
shlvl.disabled = false;
username.disabled = true;
fill.symbol = " ";
custom.git-bug = {
when = ''
git for-each-ref --count=1 refs/bugs/ > /dev/null 2>&1 || exit 1
l=$(git for-each-ref refs/bugs/ --format="%(objectname) %(refname:lstrip=2)" 2>/dev/null | sort)
r=$(git for-each-ref refs/remotes/origin/bugs/ --format="%(objectname) %(refname:lstrip=4)" 2>/dev/null | sort)
[ "$l" != "$r" ]
'';
command = "true";
format = "[ 🐛]($style)";
shell = [ "${lib.getExe pkgs.bash}" ];
};
};
};
zoxide.enable = true;
Expand Down