refactor!: switch to dendritic pattern
BREAKING CHANGE: complete reorganization of the repository
This commit is contained in:
@@ -0,0 +1,287 @@
|
||||
{
|
||||
flake.modules.homeManager.git = {
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.home.dev.vcs.git;
|
||||
in {
|
||||
options.home.dev.vcs.git = {
|
||||
enable = mkEnableOption "enables git";
|
||||
email = mkOption {
|
||||
type = types.str;
|
||||
default = "lucien@phundrak.com";
|
||||
};
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
default = "Lucien Cartier-Tilet";
|
||||
};
|
||||
cliff = mkEnableOption "enables git-cliff support";
|
||||
sendmail = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
server = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = "mail.phundrak.com";
|
||||
};
|
||||
user = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
};
|
||||
encryption = mkOption {
|
||||
type = types.enum ["tls" "ssl" "none"];
|
||||
default = "none";
|
||||
};
|
||||
port = mkOption {
|
||||
type = types.nullOr types.int;
|
||||
default = 587;
|
||||
};
|
||||
passwordFile = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
description = ''
|
||||
Path to a file containing the password necessary for authenticating
|
||||
against the mailserver.
|
||||
|
||||
This file should contain the password only, with no newline.
|
||||
'';
|
||||
};
|
||||
};
|
||||
browser = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
example = "${pkgs.firefox}/bin/firefox";
|
||||
default = null;
|
||||
};
|
||||
completeConfig = mkEnableOption "Complete configuration for workstations";
|
||||
emacs = {
|
||||
integration = mkOption {
|
||||
description = "enables Emacs integration";
|
||||
type = types.bool;
|
||||
default = config.home.dev.editors.emacs.enable;
|
||||
};
|
||||
pkg = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.emacs;
|
||||
};
|
||||
};
|
||||
mergeTool = mkOption {
|
||||
type = types.str;
|
||||
default = "ediff";
|
||||
};
|
||||
editor = mkOption {
|
||||
type = types.str;
|
||||
default = "${pkgs.emacs}/bin/emacsclient -c -a ${pkgs.emacs}/bin/emacs";
|
||||
};
|
||||
publicKeyFile = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
programs.git-cliff.enable = cfg.cliff;
|
||||
programs.git = let
|
||||
smtpEmail =
|
||||
if (cfg.sendmail.user == null)
|
||||
then cfg.email
|
||||
else cfg.sendmail.user;
|
||||
in {
|
||||
enable = true;
|
||||
ignores = [
|
||||
".env"
|
||||
".direnv/"
|
||||
|
||||
"*~"
|
||||
"\#*\#"
|
||||
"*.elc"
|
||||
"auto-save-list"
|
||||
".\#*"
|
||||
"*_flymake.*"
|
||||
"/auto/"
|
||||
".projectile"
|
||||
".dir-locals.el"
|
||||
|
||||
"# Org mode files"
|
||||
".org-id-locations"
|
||||
"*_archive"
|
||||
|
||||
"*.out"
|
||||
"*.o"
|
||||
"*.so"
|
||||
|
||||
"# Archives"
|
||||
"*.7zz"
|
||||
"*.dmg"
|
||||
"*.gz"
|
||||
"*.iso"
|
||||
"*.jar"
|
||||
"*.rar"
|
||||
"*.tar"
|
||||
"*.zip"
|
||||
|
||||
"*.log"
|
||||
"*.sqlite"
|
||||
|
||||
"dist/"
|
||||
];
|
||||
signing = {
|
||||
format =
|
||||
if cfg.publicKeyFile != null
|
||||
then "ssh"
|
||||
else "openpgp";
|
||||
key = cfg.publicKeyFile;
|
||||
signByDefault = true;
|
||||
};
|
||||
settings = {
|
||||
user = {
|
||||
inherit (cfg) name email;
|
||||
};
|
||||
color.ui = "auto";
|
||||
column.ui = "auto";
|
||||
tag.sort = "version:refname";
|
||||
core = mkIf cfg.completeConfig {
|
||||
compression = 9;
|
||||
inherit (cfg) editor;
|
||||
whitespace = "fix,-indent-with-non-tab,trailing-space";
|
||||
preloadindex = true;
|
||||
};
|
||||
status = {
|
||||
branch = true;
|
||||
showStash = true;
|
||||
};
|
||||
diff = {
|
||||
algorithm = "histogram";
|
||||
colorMoved = "plain";
|
||||
mnemonicPrefix = true;
|
||||
renames = "copy";
|
||||
interHunkContext = 10;
|
||||
};
|
||||
gpg.ssh.allowedSignersFile = "${config.home.homeDirectory}/.ssh/allowed_signers";
|
||||
init.defaultBranch = "main";
|
||||
pull.rebase = true;
|
||||
push = {
|
||||
default = "simple";
|
||||
autoSetupRemote = true;
|
||||
followTags = true;
|
||||
};
|
||||
rebase = {
|
||||
autoSquash = true;
|
||||
autoStash = true;
|
||||
missingCommitsCheck = "warn";
|
||||
updateRefs = true;
|
||||
};
|
||||
help.autocorrect = "prompt";
|
||||
web.browser = mkIf (cfg.browser != null) cfg.browser;
|
||||
sendemail = mkIf cfg.sendmail.enable {
|
||||
smtpserver = cfg.sendmail.server;
|
||||
smtpuser = smtpEmail;
|
||||
smtpencryption = cfg.sendmail.encryption;
|
||||
smtpserverport = cfg.sendmail.port;
|
||||
};
|
||||
credentials = mkIf (cfg.sendmail.passwordFile != null) {
|
||||
"smtp://${smtpEmail}@${cfg.sendmail.server}:${toString cfg.sendmail.port}" = {
|
||||
helper = "cat ${cfg.sendmail.passwordFile}";
|
||||
};
|
||||
};
|
||||
magithub = mkIf cfg.emacs.integration {
|
||||
online = true;
|
||||
"status" = {
|
||||
includeStatusHeader = true;
|
||||
includePullRequestsSection = true;
|
||||
includeIssuesSection = true;
|
||||
};
|
||||
};
|
||||
merge = {
|
||||
tool = mkIf cfg.completeConfig cfg.mergeTool;
|
||||
conflictstyle = "zdiff3";
|
||||
};
|
||||
mergetool.ediff.cmd = mkIf (cfg.emacs.integration && cfg.completeConfig) "\"${cfg.emacs.pkg} --eval \" (progn (defun ediff-write-merge-buffer () (let ((file ediff-merge-store-file)) (set-buffer ediff-buffer-C) (write-region (point-min) (point-max) file) (message \\\"Merge buffer saved in: %s\\\" file) (set-buffer-modified-p nil) (sit-for 1))) (setq ediff-quit-hook 'kill-emacs ediff-quit-merge-hook 'ediff-write-merge-buffer) (ediff-merge-files-with-ancestor \\\"$LOCAL\\\" \\\"$REMOTE\\\" \\\"$BASE\\\" nil \\\"$MERGED\\\"))\"\"";
|
||||
github.user = "phundrak";
|
||||
url = {
|
||||
"https://phundrak@github.com" = {
|
||||
insteadOf = "https://github.com";
|
||||
};
|
||||
"https://phundrak@labs.phundrak.com" = {
|
||||
insteadOf = "https://labs.phundrak.com";
|
||||
};
|
||||
"https://github.com/RustSec/advisory-db" = {
|
||||
insteadOf = "https://github.com/RustSec/advisory-db";
|
||||
};
|
||||
"git@github.com:Phundrak/" = {
|
||||
insteadOf = "pg:";
|
||||
};
|
||||
"git@labs.phundrak.com/phundrak:" = {
|
||||
insteadOf = "p:";
|
||||
};
|
||||
"git@github.com" = {
|
||||
insteadOf = "gh:";
|
||||
};
|
||||
"git@labs.phundrak.com" = {
|
||||
insteadOf = "labs:";
|
||||
};
|
||||
};
|
||||
alias = {
|
||||
a = "add --all";
|
||||
aca = "!git add --all && git commit --amend";
|
||||
acan = "!git add --all && git commit --amend --no-edit";
|
||||
ap = "add --patch";
|
||||
b = "branch";
|
||||
bd = "branch -d";
|
||||
bdd = "branch -D";
|
||||
c = "commit -S";
|
||||
ca = "commit -Sa";
|
||||
can = "commit -Sa --no-edit";
|
||||
cm = "commit -Sm";
|
||||
cam = "commit -Sam";
|
||||
co = "checkout";
|
||||
cob = "checkout -b";
|
||||
cod = "checkout develop";
|
||||
cl = "clone";
|
||||
cl1 = "clone --depth 1";
|
||||
f = "fetch";
|
||||
fp = "fetch --prune";
|
||||
ps = "push";
|
||||
psf = "push --force-with-lease";
|
||||
pso = "push origin";
|
||||
psfo = "push --force-with-lease origin";
|
||||
pushall = "!git remote \vert{} xargs -L1 git push";
|
||||
psl = "!git remote \vert{} xargs -L1 git push";
|
||||
pullall = "!git remote \vert{} xargs -L1 git pull";
|
||||
pll = "!git remote \vert{} xargs -L1 git pull";
|
||||
pl = "pull";
|
||||
pb = "pull --rebase";
|
||||
r = "rebase";
|
||||
ra = "rebase --abort";
|
||||
rc = "rebase --continue";
|
||||
rd = "rebase develop";
|
||||
ri = "rebase -i";
|
||||
rmf = "rm -f";
|
||||
rmd = "rm -r";
|
||||
rmdf = "rm -rf";
|
||||
sm = "submodule";
|
||||
sms = "submodule status";
|
||||
sma = "submodule add";
|
||||
smu = "submodule update";
|
||||
smui = "submodule update --init";
|
||||
smuir = "submodule update --init --recursive";
|
||||
st = "stash";
|
||||
stc = "stash clear";
|
||||
stp = "stash pop";
|
||||
stw = "stash show";
|
||||
u = "reset --";
|
||||
d = "diff -w";
|
||||
l = "log --all --oneline --graph --decorate --pretty=format':%C(magenta)%h %C(white) %an %ar%C(auto) %D%n%s%n'";
|
||||
s = "status";
|
||||
staged = "diff --cached";
|
||||
upstream = "!git push -u origin HEAD";
|
||||
unstage = "reset --";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
{inputs, ...}: {
|
||||
flake-file.inputs.jj-cz = {
|
||||
url = "git+https://labs.phundrak.com/phundrak/jj-cz?ref=develop";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
flake.modules.homeManager.jujutsu = {
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
inherit (pkgs.stdenv.hostPlatform) system;
|
||||
cfg = config.home.dev.vcs.jj;
|
||||
jj-cz = inputs.jj-cz.packages.${system}.default;
|
||||
in {
|
||||
options.home.dev.vcs.jj = {
|
||||
enable = mkEnableOption "enables jj";
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
default = "Lucien Cartier-Tilet";
|
||||
};
|
||||
email = mkOption {
|
||||
type = types.str;
|
||||
default = "lucien@phundrak.com";
|
||||
};
|
||||
editor = mkOption {
|
||||
type = types.str;
|
||||
default =
|
||||
if config.home.dev.editors.emacs.enable
|
||||
then "${pkgs.emacs}/bin/emacsclient -c -a ${pkgs.emacs}/bin/emacs"
|
||||
else "${pkgs.nano}/bin/nano";
|
||||
};
|
||||
signing = {
|
||||
enable = mkEnableOption "enables signing jj commits";
|
||||
sshKey = mkOption {
|
||||
type = with types; nullOr (either path str);
|
||||
example = "~/.ssh/id_ed25519.pub";
|
||||
default = "${config.home.homeDirectory}/.ssh/id_ed25519.pub";
|
||||
description = "Path to the private SSH key for signing.";
|
||||
};
|
||||
};
|
||||
cz = {
|
||||
enable = mkEnableOption "Enables jj-cz";
|
||||
alias = mkEnableOption "Enable `jj cz` as an alias to `jj-cz`";
|
||||
};
|
||||
# used in my shell .nix files
|
||||
shellCompletion = mkOption {
|
||||
description = "Enable Jujutsu shell completion";
|
||||
type = types.bool;
|
||||
default = true;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = mkIf cfg.cz.enable [jj-cz];
|
||||
programs.jujutsu = {
|
||||
enable = true;
|
||||
settings = {
|
||||
user = {
|
||||
inherit (cfg) name email;
|
||||
};
|
||||
ui = {
|
||||
inherit (cfg) editor;
|
||||
default-command = "st";
|
||||
pager = ":builtin";
|
||||
show-cryptographic-signatures = true;
|
||||
diff-editor = ":builtin";
|
||||
merge-editort = ":builtin";
|
||||
# These are for vc-jj.el in Emacs
|
||||
diff-formatter = ":git";
|
||||
conflict-marker-style = "git";
|
||||
};
|
||||
signing = mkIf cfg.signing.enable {
|
||||
behavior = "own";
|
||||
backend = "ssh";
|
||||
key = cfg.signing.sshKey;
|
||||
backends.ssh.allowed-signers = "${config.home.homeDirectory}/.ssh/allowed_signers";
|
||||
backends.ssh.program = "${pkgs.openssh}/bin/ssh-keygen";
|
||||
};
|
||||
aliases = {
|
||||
blame = ["file" "annotate"];
|
||||
consume = ["squash" "--into" "@" "--from"];
|
||||
cz = mkIf cfg.cz.alias ["util" "exec" "--" "${jj-cz}/bin/jj-cz"];
|
||||
eject = ["squash" "--from" "@" "--into"];
|
||||
d = ["diff"];
|
||||
dm = ["desc" "-m"];
|
||||
gc = ["git" "clone"];
|
||||
gcc = ["git" "clone" "--colocate"];
|
||||
l = ["log"];
|
||||
la = ["log" "-r" "::"];
|
||||
lc = ["log" "-r" "(remote_bookmarks()..@)::"];
|
||||
ll = ["log" "-T" "builtin_log_detailed"];
|
||||
open = ["log" "-r" "open()"];
|
||||
n = ["new"];
|
||||
nd = ["new" "dev()"];
|
||||
nt = ["new" "trunk()"];
|
||||
revlog = ["evolog"];
|
||||
s = ["show"];
|
||||
tug = ["bookmark" "move" "--from" "heads(::@- & bookmarks())" "--to" "@-"];
|
||||
};
|
||||
colors.working_copy.underline = true;
|
||||
git = {
|
||||
private-commits = "blacklist()";
|
||||
colocate = true;
|
||||
subprocess = true;
|
||||
};
|
||||
revset-aliases = {
|
||||
"immutable_heads()" = "present(trunk()) | tags()";
|
||||
# Resolves by default to latest main/master remote bookmarks
|
||||
"trunk()" = "latest((present(main) | present(master)) & remote_bookmarks())";
|
||||
# Same as trunk() but for `dev` or `develop` bookmarks
|
||||
"dev()" = "latest((present(dev) | present(develop)) & remote_bookmarks())";
|
||||
|
||||
"user(x)" = "author(x) | committer(x)";
|
||||
"gh_pages()" = "ancestors(remote_bookmarks(exact:\"gh-pages\"))";
|
||||
|
||||
#Private and WIP commits that should never be pushed
|
||||
"wip()" = "description(glob:\"wip:*\")";
|
||||
"private()" = "description(glob:\"private:*\")";
|
||||
"blacklist()" = "wip() | private()";
|
||||
|
||||
# stack(x, n) is the set of mutable commits reachable from
|
||||
# 'x', with 'n' parents. 'n' is often useful to customize the
|
||||
# display and return set for certain operations. 'x' can be
|
||||
# used to target the set of 'roots' to traverse, e.g. @ is the
|
||||
# current stack.
|
||||
"stack()" = "ancestors(reachable(@, mutable()), 2)";
|
||||
"stack(x)" = "ancestors(reachable(x, mutable()), 2)";
|
||||
"stack(x, n)" = "ancestors(reachable(x, mutable()), n)";
|
||||
|
||||
"open()" = "stack(dev().. & mine(), 1)";
|
||||
"ready()" = "open() ~ blacklist()::";
|
||||
};
|
||||
remotes.origin.auto-track-bookmarks = "*";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
{config, ...}: let
|
||||
m = config.flake.modules.homeManager;
|
||||
in {
|
||||
flake.modules.homeManager.vcs = {
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.home.dev.vcs;
|
||||
in {
|
||||
imports = [m.git m.jujutsu];
|
||||
|
||||
options.home.dev.vcs = {
|
||||
fullDesktop = mkEnableOption "Enable all optional values";
|
||||
name = mkOption {
|
||||
type = types.str;
|
||||
default = "Lucien Cartier-Tilet";
|
||||
};
|
||||
email = mkOption {
|
||||
type = types.str;
|
||||
default = "lucien@phundrak.com";
|
||||
};
|
||||
editor = mkOption {
|
||||
type = types.str;
|
||||
default = "${pkgs.emacs}/bin/emacsclient -c -a ${pkgs.emacs}/bin/emacs";
|
||||
};
|
||||
publicKey = {
|
||||
content = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
example = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGj+J6N6SO+4P8dOZqfR1oiay2yxhhHnagH52avUqw5h";
|
||||
default = null;
|
||||
};
|
||||
file = mkOption {
|
||||
type = with types; nullOr path;
|
||||
default = "/home/phundrak/.ssh/id_ed25519.pub";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config.home.dev.vcs = {
|
||||
git = {
|
||||
enable = mkDefault true;
|
||||
inherit (cfg) name email editor;
|
||||
publicKeyFile = cfg.publicKey.file;
|
||||
cliff = mkDefault cfg.fullDesktop;
|
||||
completeConfig = mkDefault cfg.fullDesktop;
|
||||
};
|
||||
jj = {
|
||||
enable = mkDefault true;
|
||||
inherit (cfg) name email editor;
|
||||
signing.sshKey = mkDefault (cfg.publicKey.file or cfg.publicKey.content);
|
||||
cz = {
|
||||
enable = mkDefault true;
|
||||
alias = mkDefault true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user