Skip to content

Commit 89601e0

Browse files
committed
feat: Better modularization, update better-commits
1 parent 7c7a682 commit 89601e0

File tree

13 files changed

+331
-173
lines changed

13 files changed

+331
-173
lines changed

lib/default.nix

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{lib, ...}:
2+
with lib; {
3+
enabled = {enable = true;};
4+
disabled = {enable = false;};
5+
6+
mkBoolOption = default: description:
7+
mkOption {
8+
inherit default description;
9+
type = types.bool;
10+
};
11+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}:
7+
with lib;
8+
with lib.mgnix; {
9+
options.mgnix.apps.console.git.better-commits.enable = mkBoolOption config.mgnix.apps.console.git.enable "Whether to enable better-commits";
10+
11+
config = let
12+
inherit (config.mgnix.apps.console.git.better-commits) enable;
13+
inherit (config.mgnix.apps.console) git;
14+
aliases = {
15+
gbc = "git bc";
16+
gbb = "better-branch";
17+
};
18+
in
19+
mkIf (git.enable && enable) {
20+
home.packages = with pkgs; [
21+
mgnix.better-commits
22+
];
23+
24+
programs.zsh.shellAliases = aliases;
25+
programs.bash.shellAliases = aliases;
26+
};
27+
}

modules/home/apps/console/git/default.nix

Lines changed: 51 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,10 @@
44
pkgs,
55
...
66
}:
7-
with lib; {
7+
with lib;
8+
with lib.mgnix; {
89
options.mgnix.apps.console.git = {
9-
enable = mkOption {
10-
description = "Whether to enable Git";
11-
type = types.bool;
12-
default = true;
13-
};
14-
15-
lazygit.enable = mkOption {
16-
description = "Whether to enable LazyGit";
17-
type = types.bool;
18-
default = true;
19-
};
10+
enable = mkBoolOption true "Whether to enable Git";
2011

2112
userName = mkOption {
2213
description = "Git user name";
@@ -32,34 +23,60 @@ with lib; {
3223
};
3324

3425
config = let
35-
inherit (config.mgnix.apps.console.git) enable lazygit userName email;
26+
inherit (config.mgnix.apps.console.git) enable userName email;
27+
aliases = {
28+
g = "git";
29+
gci = "git commit";
30+
gcim = "git commit --message";
31+
gcima = "git commit --all --message";
32+
gcz = "git cz";
33+
gs = "git status";
34+
gst = "git status";
35+
gstu = "git status --untracked-files=no";
36+
amend = "git commit --amend --no-edit";
37+
reword = "git commit --amend --message";
38+
gu = "git reset HEAD~1";
39+
grh = "git reset --hard";
40+
ga = "git add";
41+
gaa = "git add --all";
42+
unstage = "git reset HEAD";
43+
gco = "git checkout";
44+
gb = "git branch --sort=-committerdate | fzf --header \"Checkout Recent Branch\" --preview \"git diff --color=always {1} | delta\" --pointer=\"\" | xargs git checkout";
45+
gbr = "git branch";
46+
gbrs = "git branch --all -verbose";
47+
gp = "git push";
48+
gpush = "git push";
49+
gpushf = "git push --force-with-lease";
50+
gpull = "git pull";
51+
gpf = "git push --force-with-lease";
52+
gra = "git rebase --abort";
53+
grc = "git rebase --continue";
54+
grv = "git remote --verbose";
55+
gd = "git diff";
56+
gdc = "git diff --staged";
57+
gshow = "git diff --staged";
58+
gdt = "git difftool";
59+
gmt = "git mergetool";
60+
unresolve = "git checkout --conflict=merge";
61+
gll = "git log";
62+
gl = "git log --oneline --max-count=15";
63+
gld = "git log --oneline --max-count=15 --decorate";
64+
ggl = "git log --graph --oneline --decorate --branches --all";
65+
hsit = "git log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short";
66+
gls = "git log --graph --oneline --decorate --all --color=always | fzf --ansi +s --preview='git show --color=always {2}' --bind='ctrl-d:preview-page-down' --bind='ctrl-u:preview-page-up' --bind='enter:execute:git show --color=always {2} | less -R' --bind='ctrl-x:execute:git checkout {2} .'";
67+
wdw = "git wdw";
68+
most-changed = "git log --format=%n --name-only | grep -v '^$' | sort | uniq -c |--numeric-sort --reverse | head -n 50";
69+
gcleanf = "git cleanf -xdf";
70+
};
3671
in
3772
mkIf enable {
3873
home.packages = with pkgs; [
3974
delta
4075
less
4176
cz-cli
42-
mgnix.better-commits
43-
(mkIf lazygit.enable pkgs.lazygit)
4477
];
4578

4679
programs = {
47-
lazygit = mkIf lazygit.enable {
48-
enable = true;
49-
settings = {
50-
gui = {
51-
showIcons = true;
52-
showRandomTip = false;
53-
nerdFontsVersion = "3";
54-
};
55-
update = {
56-
method = "never";
57-
};
58-
disableStartupPopups = true;
59-
notARepository = "quit";
60-
};
61-
};
62-
6380
git = {
6481
enable = true;
6582
userName = "${userName}";
@@ -181,6 +198,9 @@ with lib; {
181198
};
182199
};
183200
};
201+
202+
zsh.shellAliases = aliases;
203+
bash.shellAliases = aliases;
184204
};
185205
};
186206
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
config,
3+
lib,
4+
pkgs,
5+
...
6+
}:
7+
with lib;
8+
with lib.mgnix; {
9+
options.mgnix.apps.console.git.lazygit.enable = mkBoolOption config.mgnix.apps.console.git.enable "Whether to enable lazygit";
10+
11+
config = let
12+
inherit (config.mgnix.apps.console.git.lazygit) enable;
13+
inherit (config.mgnix.apps.console) git;
14+
aliases = {
15+
lg = "lazygit";
16+
};
17+
in
18+
mkIf (git.enable && enable) {
19+
home.packages = with pkgs; [
20+
lazygit
21+
];
22+
23+
programs = {
24+
lazygit = {
25+
enable = true;
26+
settings = {
27+
gui = {
28+
showIcons = true;
29+
showRandomTip = false;
30+
nerdFontsVersion = "3";
31+
};
32+
update = {
33+
method = "never";
34+
};
35+
disableStartupPopups = true;
36+
notARepository = "quit";
37+
};
38+
};
39+
40+
zsh.shellAliases = aliases;
41+
bash.shellAliases = aliases;
42+
};
43+
};
44+
}

modules/home/apps/console/neovim/default.nix

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ with lib; {
2121

2222
config = let
2323
inherit (config.mgnix.apps.console.neovim) enable package;
24+
aliases = {
25+
v = "nvim";
26+
vim = "nvim";
27+
vi = "nvim";
28+
vimdiff = "nvim -d";
29+
};
2430
in
2531
mkIf enable {
2632
home = {
@@ -33,5 +39,10 @@ with lib; {
3339
VISUAL = "nvim";
3440
};
3541
};
42+
43+
programs = {
44+
zsh.shellAliases = aliases;
45+
bash.shellAliases = aliases;
46+
};
3647
};
3748
}
Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,30 @@
1-
_: {
2-
programs.bat = {
3-
enable = true;
4-
config = {
5-
theme = "base16-256";
6-
"italic-text" = "always";
1+
{
2+
config,
3+
lib,
4+
...
5+
}:
6+
with lib;
7+
with lib.mgnix; {
8+
options.mgnix.apps.console.bat.enable = mkBoolOption true "Whether to enable bat";
9+
10+
config = let
11+
inherit (config.mgnix.apps.console.bat) enable;
12+
aliases = {
13+
cat = "bat";
14+
};
15+
in
16+
mkIf enable {
17+
programs = {
18+
bat = {
19+
enable = true;
20+
config = {
21+
theme = "base16-256";
22+
"italic-text" = "always";
23+
};
24+
};
25+
26+
zsh.shellAliases = aliases;
27+
bash.shellAliases = aliases;
28+
};
729
};
8-
};
930
}

modules/home/apps/console/shell-tools/default.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{pkgs, ...}: {
22
home.packages = with pkgs; [
33
curl
4-
eza
54
fd
65
gum
76
jq
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
config,
3+
lib,
4+
...
5+
}:
6+
with lib;
7+
with lib.mgnix; {
8+
options.mgnix.apps.console.eza.enable = mkBoolOption true "Whether to enable eza";
9+
10+
config = let
11+
inherit (config.mgnix.apps.console.eza) enable;
12+
aliases = {
13+
l = "eza --git --icons -lha --color-scale";
14+
};
15+
in
16+
mkIf enable {
17+
programs = {
18+
eza = {
19+
enable = true;
20+
git = true;
21+
icons = true;
22+
enableZshIntegration = true;
23+
enableBashIntegration = true;
24+
};
25+
26+
zsh.shellAliases = aliases;
27+
bash.shellAliases = aliases;
28+
};
29+
};
30+
}
Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
1-
_: {
2-
programs = {
3-
yazi = {
4-
enable = true;
5-
enableZshIntegration = true;
6-
};
1+
{
2+
config,
3+
lib,
4+
...
5+
}:
6+
with lib;
7+
with lib.mgnix; {
8+
options.mgnix.apps.console.yazi.enable = mkBoolOption true "Whether to enable yazi";
79

8-
zsh.shellAliases = {
10+
config = let
11+
inherit (config.mgnix.apps.console.yazi) enable;
12+
aliases = {
13+
"e." = "yazi .";
14+
"r" = "yazi";
915
ranger = "yazi";
1016
};
11-
};
17+
in
18+
mkIf enable {
19+
programs = {
20+
yazi = {
21+
enable = true;
22+
enableZshIntegration = true;
23+
enableBashIntegration = true;
24+
};
25+
26+
zsh.shellAliases = aliases;
27+
bash.shellAliases = aliases;
28+
};
29+
};
1230
}
Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,27 @@
1-
_: {
2-
programs.zoxide = {
3-
enable = true;
4-
enableZshIntegration = true;
5-
};
1+
{
2+
config,
3+
lib,
4+
...
5+
}:
6+
with lib;
7+
with lib.mgnix; {
8+
options.mgnix.apps.console.zoxide.enable = mkBoolOption true "Whether to enable zoxide";
9+
10+
config = let
11+
inherit (config.mgnix.apps.console.zoxide) enable;
12+
aliases = {
13+
zz = "z -"; # Toggle last directory via zoxide
14+
};
15+
in
16+
mkIf enable {
17+
programs = {
18+
zoxide = {
19+
enable = true;
20+
enableZshIntegration = true;
21+
};
22+
23+
zsh.shellAliases = aliases;
24+
bash.shellAliases = aliases;
25+
};
26+
};
627
}

0 commit comments

Comments
 (0)