modularize git
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
./home/programs/foot
|
./home/programs/foot
|
||||||
./home/programs/fuzzel
|
./home/programs/fuzzel
|
||||||
./home/programs/ghostty
|
./home/programs/ghostty
|
||||||
|
./home/programs/git
|
||||||
./home/programs/helix
|
./home/programs/helix
|
||||||
./home/programs/hyprlock
|
./home/programs/hyprlock
|
||||||
./home/programs/jujutsu
|
./home/programs/jujutsu
|
||||||
|
|||||||
59
modules/home/programs/git/default.nix
Normal file
59
modules/home/programs/git/default.nix
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (lib) mkIf mkEnableOption;
|
||||||
|
cfg = config.home.programs.git;
|
||||||
|
in {
|
||||||
|
options = {
|
||||||
|
home.programs.git.enable = mkEnableOption "Enables git";
|
||||||
|
};
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
home.packages = [pkgs.gh];
|
||||||
|
programs.git = {
|
||||||
|
enable = true;
|
||||||
|
userName = config.accounts.username;
|
||||||
|
userEmail = config.accounts.mail;
|
||||||
|
delta = {
|
||||||
|
enable = true;
|
||||||
|
options.dark = true;
|
||||||
|
};
|
||||||
|
extraConfig = {
|
||||||
|
# user.signingkey = "${config.home.homeDirectory}/.ssh/id_ed25519.pub";
|
||||||
|
user.signingkey = "${config.home.homeDirectory}/.config/git/allowed_signers";
|
||||||
|
signing = {
|
||||||
|
format = lib.mkDefault "ssh";
|
||||||
|
key = "${config.home.homeDirectory}/.ssh/id_ed25519";
|
||||||
|
signByDefault = true;
|
||||||
|
};
|
||||||
|
gpg = {
|
||||||
|
# format = lib.mkDefault "ssh";
|
||||||
|
ssh.allowedSignersFile = config.home.homeDirectory + "/" + config.xdg.configFile."git/allowed_signers".target;
|
||||||
|
};
|
||||||
|
commit = {
|
||||||
|
verbose = true;
|
||||||
|
gpgSign = false;
|
||||||
|
};
|
||||||
|
init.defaultBranch = "main";
|
||||||
|
merge.conflictStyle = "diff3";
|
||||||
|
diff.algorithm = "histogram";
|
||||||
|
log.date = "iso";
|
||||||
|
column.ui = "auto";
|
||||||
|
branch.sort = "committerdate";
|
||||||
|
push.autoSetupRemote = true;
|
||||||
|
rerere.enabled = true;
|
||||||
|
};
|
||||||
|
lfs.enable = true;
|
||||||
|
ignores = [
|
||||||
|
".direnv"
|
||||||
|
"result"
|
||||||
|
".jj"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
xdg.configFile."git/allowed_signers".text = ''
|
||||||
|
${config.accounts.mail} namespaces="git" ${config.accounts.sshKey}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -4,6 +4,24 @@
|
|||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) mkOption types;
|
inherit (lib) mkOption types;
|
||||||
|
|
||||||
|
sshKeys = {
|
||||||
|
cnixpad = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIXCjkKouZrsMoswMIeueO8X/c3kuY3Gb0E9emvkqwUv cnst@cnixpad";
|
||||||
|
cnixlab = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICiNcNex+/hrEQJYJJTj89uPXocSfChU38E5TujWdxaM cnstlab@cnixlab";
|
||||||
|
cnixtop = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEUub8vbzUn2f39ILhAJ2QeH8xxLSjiyUuo8xvHGx/VB adam@cnst.dev";
|
||||||
|
toothpc = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGu5vZbb5ExampleKeyHereGfDF9c5 toothpick@toothpc";
|
||||||
|
};
|
||||||
|
|
||||||
|
keyName = config.accounts.sshUser or null;
|
||||||
|
|
||||||
|
selectedKey =
|
||||||
|
if keyName != null
|
||||||
|
then
|
||||||
|
lib.attrByPath [keyName] (
|
||||||
|
builtins.abort "No SSH key defined for hostname/key '${toString keyName}'"
|
||||||
|
)
|
||||||
|
sshKeys
|
||||||
|
else builtins.abort "No accounts.sshUser provided, cannot select SSH key.";
|
||||||
in {
|
in {
|
||||||
options.accounts = {
|
options.accounts = {
|
||||||
username = mkOption {
|
username = mkOption {
|
||||||
@@ -11,10 +29,21 @@ in {
|
|||||||
default = "cnst";
|
default = "cnst";
|
||||||
description = "Set the desired username";
|
description = "Set the desired username";
|
||||||
};
|
};
|
||||||
hostname = mkOption {
|
mail = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = "cnix";
|
default = "adam@cnst.dev";
|
||||||
description = "Set the desired hostname";
|
description = "Set the desired email";
|
||||||
|
};
|
||||||
|
sshKey = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = selectedKey;
|
||||||
|
description = "Host-specific SSH key";
|
||||||
|
readOnly = true;
|
||||||
|
};
|
||||||
|
sshUser = lib.mkOption {
|
||||||
|
type = lib.types.nullOr lib.types.str;
|
||||||
|
default = null;
|
||||||
|
description = "Optional override for selecting an SSH key by name";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./modules
|
./modules
|
||||||
./git.nix
|
|
||||||
];
|
];
|
||||||
# ++ lib.optionals isCnixpad [./cpmodules.nix];
|
# ++ lib.optionals isCnixpad [./cpmodules.nix];
|
||||||
|
|
||||||
|
|||||||
@@ -1,25 +1,14 @@
|
|||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
osConfig,
|
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: {
|
||||||
email = config.programs.git.userEmail;
|
|
||||||
isCnixpad = osConfig.networking.hostName == "cnixpad";
|
|
||||||
isCnixlab = osConfig.networking.hostName == "cnixlab";
|
|
||||||
sshKey =
|
|
||||||
if isCnixpad
|
|
||||||
then "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIXCjkKouZrsMoswMIeueO8X/c3kuY3Gb0E9emvkqwUv cnst@cnixpad"
|
|
||||||
else if isCnixlab
|
|
||||||
then "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICiNcNex+/hrEQJYJJTj89uPXocSfChU38E5TujWdxaM cnstlab@cnixlab"
|
|
||||||
else "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEUub8vbzUn2f39ILhAJ2QeH8xxLSjiyUuo8xvHGx/VB adam@cnst.dev";
|
|
||||||
in {
|
|
||||||
home.packages = [pkgs.gh];
|
home.packages = [pkgs.gh];
|
||||||
programs.git = {
|
programs.git = {
|
||||||
enable = true;
|
enable = true;
|
||||||
userName = "cnst";
|
userName = config.accounts.username;
|
||||||
userEmail = "adam@cnst.dev";
|
userEmail = config.accounts.mail;
|
||||||
delta = {
|
delta = {
|
||||||
enable = true;
|
enable = true;
|
||||||
options.dark = true;
|
options.dark = true;
|
||||||
@@ -57,6 +46,6 @@ in {
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
xdg.configFile."git/allowed_signers".text = ''
|
xdg.configFile."git/allowed_signers".text = ''
|
||||||
${email} namespaces="git" ${sshKey}
|
${config.accounts.mail} namespaces="git" ${config.accounts.sshKey}
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,9 @@
|
|||||||
fuzzel = {
|
fuzzel = {
|
||||||
enable = true;
|
enable = true;
|
||||||
};
|
};
|
||||||
|
git = {
|
||||||
|
enable = true;
|
||||||
|
};
|
||||||
ghostty = {
|
ghostty = {
|
||||||
enable = true;
|
enable = true;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
accounts = {
|
accounts = {
|
||||||
username = "cnst";
|
username = "cnst";
|
||||||
hostname = "cnixtop";
|
mail = "adam@cnst.dev";
|
||||||
|
sshUser = "cnixtop";
|
||||||
};
|
};
|
||||||
monitors = [
|
monitors = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./modules
|
./modules
|
||||||
./git.nix
|
|
||||||
];
|
];
|
||||||
# ++ lib.optionals isCnixpad [./cpmodules.nix];
|
# ++ lib.optionals isCnixpad [./cpmodules.nix];
|
||||||
|
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
{
|
|
||||||
config,
|
|
||||||
pkgs,
|
|
||||||
osConfig,
|
|
||||||
lib,
|
|
||||||
...
|
|
||||||
}: let
|
|
||||||
email = config.programs.git.userEmail;
|
|
||||||
isCnixpad = osConfig.networking.hostName == "cnixpad";
|
|
||||||
isCnixlab = osConfig.networking.hostName == "cnixlab";
|
|
||||||
sshKey =
|
|
||||||
if isCnixpad
|
|
||||||
then "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIXCjkKouZrsMoswMIeueO8X/c3kuY3Gb0E9emvkqwUv cnst@cnixpad"
|
|
||||||
else if isCnixlab
|
|
||||||
then "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICiNcNex+/hrEQJYJJTj89uPXocSfChU38E5TujWdxaM cnstlab@cnixlab"
|
|
||||||
else "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEUub8vbzUn2f39ILhAJ2QeH8xxLSjiyUuo8xvHGx/VB adam@cnst.dev";
|
|
||||||
in {
|
|
||||||
home.packages = [pkgs.gh];
|
|
||||||
programs.git = {
|
|
||||||
enable = true;
|
|
||||||
userName = "cnst";
|
|
||||||
userEmail = "adam@cnst.dev";
|
|
||||||
delta = {
|
|
||||||
enable = true;
|
|
||||||
options.dark = true;
|
|
||||||
};
|
|
||||||
extraConfig = {
|
|
||||||
# user.signingkey = "${config.home.homeDirectory}/.ssh/id_ed25519.pub";
|
|
||||||
user.signingkey = "${config.home.homeDirectory}/.config/git/allowed_signers";
|
|
||||||
signing = {
|
|
||||||
format = lib.mkDefault "ssh";
|
|
||||||
key = "${config.home.homeDirectory}/.ssh/id_ed25519";
|
|
||||||
signByDefault = true;
|
|
||||||
};
|
|
||||||
gpg = {
|
|
||||||
# format = lib.mkDefault "ssh";
|
|
||||||
ssh.allowedSignersFile = config.home.homeDirectory + "/" + config.xdg.configFile."git/allowed_signers".target;
|
|
||||||
};
|
|
||||||
commit = {
|
|
||||||
verbose = true;
|
|
||||||
gpgSign = false;
|
|
||||||
};
|
|
||||||
init.defaultBranch = "main";
|
|
||||||
merge.conflictStyle = "diff3";
|
|
||||||
diff.algorithm = "histogram";
|
|
||||||
log.date = "iso";
|
|
||||||
column.ui = "auto";
|
|
||||||
branch.sort = "committerdate";
|
|
||||||
push.autoSetupRemote = true;
|
|
||||||
rerere.enabled = true;
|
|
||||||
};
|
|
||||||
lfs.enable = true;
|
|
||||||
ignores = [
|
|
||||||
".direnv"
|
|
||||||
"result"
|
|
||||||
".jj"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
xdg.configFile."git/allowed_signers".text = ''
|
|
||||||
${email} namespaces="git" ${sshKey}
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
{
|
{
|
||||||
accounts = {
|
accounts = {
|
||||||
username = "cnstlab";
|
username = "cnstlab";
|
||||||
hostname = "cnixlab";
|
mail = "adam@cnst.dev";
|
||||||
|
sshUser = "cnixlab";
|
||||||
};
|
};
|
||||||
monitors = [
|
monitors = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
{pkgs, ...}: {
|
{pkgs, ...}: {
|
||||||
imports = [
|
imports = [
|
||||||
./modules
|
./modules
|
||||||
./git.nix
|
|
||||||
];
|
];
|
||||||
home = {
|
home = {
|
||||||
username = "toothpick";
|
username = "toothpick";
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
{
|
|
||||||
programs.git = {
|
|
||||||
enable = true;
|
|
||||||
userName = "toothpick";
|
|
||||||
userEmail = "fredrik@libellux.com";
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user