This commit is contained in:
2026-07-27 05:51:17 +09:00
parent dd40b978dd
commit 0171582307
252 changed files with 0 additions and 10356 deletions
-35
View File
@@ -1,35 +0,0 @@
{
lib,
config,
...
}:
let
cfg = config.my.applications.git;
in
{
imports = [
./home.nix
./system.nix
];
options.my.applications.git = {
enable = lib.mkEnableOption "git version control";
userName = lib.mkOption {
type = lib.types.singleLineStr;
default = "moons";
description = "Default Git user.name.";
};
userEmail = lib.mkOption {
type = lib.types.singleLineStr;
default = "moons@moons14.com";
description = "Default Git user.email.";
};
};
config = lib.mkIf cfg.enable {
my.applications.git.system.enable = lib.mkDefault true;
my.applications.git.homeManager.enable = lib.mkDefault true;
};
}
-111
View File
@@ -1,111 +0,0 @@
{
pkgs,
lib,
config,
...
}:
let
cfg = config.my.applications.git;
hmCfg = config.my.applications.git.homeManager;
signingKeyPath = ".ssh/1password-git-signing.pub";
signingKeyFile = "~/${signingKeyPath}";
gitSshSign = pkgs.writeShellScript "git-ssh-sign" ''
one_password_sock="$HOME/.1password/agent.sock"
if { [ -n "''${SSH_CONNECTION:-}" ] || [ -n "''${SSH_CLIENT:-}" ]; } \
&& [ -n "''${SSH_AUTH_SOCK:-}" ] \
&& [ -S "$SSH_AUTH_SOCK" ]; then
exec ${pkgs.openssh}/bin/ssh-keygen "$@"
fi
if [ -S "$one_password_sock" ]; then
export SSH_AUTH_SOCK="$one_password_sock"
exec ${pkgs.openssh}/bin/ssh-keygen "$@"
fi
if [ -n "''${SSH_AUTH_SOCK:-}" ] && [ -S "$SSH_AUTH_SOCK" ]; then
exec ${pkgs.openssh}/bin/ssh-keygen "$@"
fi
echo "git ssh signing failed: no forwarded SSH agent or 1Password agent socket found" >&2
echo "expected: forwarded SSH_AUTH_SOCK or $one_password_sock" >&2
exit 1
'';
in
{
options.my.applications.git.homeManager = {
enable = lib.mkEnableOption "git home-manager configuration";
signingPublicKey = lib.mkOption {
type = lib.types.nullOr lib.types.singleLineStr;
default = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPLwReAiwhXoO34S2+MrvqUhi8IWp4IzUq4OSp3niJdq 1password-git-signing";
example = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPLwReAiwhXoO34S2+MrvqUhi8IWp4IzUq4OSp3niJdq 1password-git-signing";
description = "SSH public key copied from the 1Password SSH key item used for Git signing.";
};
signingKey = lib.mkOption {
type = lib.types.str;
default = signingKeyFile;
readOnly = true;
description = "SSH public key path used for Git commit and tag signing.";
};
};
config = lib.mkIf hmCfg.enable {
assertions = [
{
assertion = hmCfg.signingPublicKey != null && hmCfg.signingPublicKey != "";
message = "my.applications.git.homeManager.signingPublicKey must be set to the public key copied from 1Password.";
}
];
home-manager.sharedModules = [
{
home.file.${signingKeyPath}.text = hmCfg.signingPublicKey + "\n";
programs.git = {
enable = true;
ignores = [
".direnv/"
".envrc"
"!.envrc.example"
];
signing = {
key = hmCfg.signingKey;
format = "ssh";
signByDefault = true;
};
settings = {
user.name = cfg.userName;
user.email = cfg.userEmail;
push.default = "simple";
credential.helper = "cache --timeout=7200";
init.defaultBranch = "main";
log.decorate = "full";
log.date = "iso";
merge.conflictStyle = "diff3";
gpg.ssh.program = "${gitSshSign}";
alias = {
br = "branch --sort=-committerdate";
co = "checkout";
df = "diff";
com = "commit -a";
gs = "stash";
gp = "pull";
lg = "log --graph --pretty=format:'%Cred%h%Creset - %C(yellow)%d%Creset %s %C(green)(%cr)%C(bold blue) <%an>%Creset' --abbrev-commit";
st = "status";
};
};
};
}
];
};
}
-21
View File
@@ -1,21 +0,0 @@
{
pkgs,
lib,
config,
...
}:
let
cfg = config.my.applications.git.system;
in
{
options.my.applications.git.system = {
enable = lib.mkEnableOption "git system configuration";
};
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [
git # Distributed version control system
gh # GitHub CLI
];
};
}