refactor(lazygit): move into own module
This commit is contained in:
parent
7a0c0a77dd
commit
9d7f36dbae
2 changed files with 96 additions and 60 deletions
|
@ -187,7 +187,6 @@ in
|
||||||
rs = "sudo systemctl";
|
rs = "sudo systemctl";
|
||||||
uj = "journalctl --user";
|
uj = "journalctl --user";
|
||||||
rj = "sudo journalctl";
|
rj = "sudo journalctl";
|
||||||
lg = "lazygit";
|
|
||||||
};
|
};
|
||||||
aliases = {
|
aliases = {
|
||||||
ls = "${getExe pkgs.eza} -lh --icons --git";
|
ls = "${getExe pkgs.eza} -lh --icons --git";
|
||||||
|
@ -198,6 +197,7 @@ in
|
||||||
variables = { EDITOR = "vim"; };
|
variables = { EDITOR = "vim"; };
|
||||||
};
|
};
|
||||||
programs = {
|
programs = {
|
||||||
|
lazygit.enable = true;
|
||||||
direnv.enable = true;
|
direnv.enable = true;
|
||||||
fish.enable = true;
|
fish.enable = true;
|
||||||
git.enable = true;
|
git.enable = true;
|
||||||
|
@ -299,65 +299,6 @@ in
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
starship.enable = true;
|
starship.enable = true;
|
||||||
lazygit.enable = true;
|
|
||||||
lazygit.settings = {
|
|
||||||
customCommands = [
|
|
||||||
{
|
|
||||||
key = "<c-v>";
|
|
||||||
context = "global";
|
|
||||||
description = "Create new conventional commit";
|
|
||||||
prompts = [
|
|
||||||
{
|
|
||||||
type = "menu";
|
|
||||||
key = "Type";
|
|
||||||
title = "Type of change";
|
|
||||||
options = [
|
|
||||||
{ name = "build"; description = "Changes that affect the build system or external dependencies"; value = "build"; }
|
|
||||||
{ name = "feat"; description = "A new feature"; value = "feat"; }
|
|
||||||
{ name = "fix"; description = "A bug fix"; value = "fix"; }
|
|
||||||
{ name = "chore"; description = "Other changes that don't modify src or test files"; value = "chore"; }
|
|
||||||
{ name = "ci"; description = "Changes to CI configuration files and scripts"; value = "ci"; }
|
|
||||||
{ name = "docs"; description = "Documentation only changes"; value = "docs"; }
|
|
||||||
{ name = "perf"; description = "A code change that improves performance"; value = "perf"; }
|
|
||||||
{ name = "refactor"; description = "A code change that neither fixes a bug nor adds a feature"; value = "refactor"; }
|
|
||||||
{ name = "revert"; description = "Reverts a previous commit"; value = "revert"; }
|
|
||||||
{ name = "style"; description = "Changes that do not affect the meaning of the code"; value = "style"; }
|
|
||||||
{ name = "test"; description = "Adding missing tests or correcting existing tests"; value = "test"; }
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
type = "input";
|
|
||||||
title = "Scope";
|
|
||||||
key = "Scope";
|
|
||||||
initialValue = "";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
type = "menu";
|
|
||||||
key = "Breaking";
|
|
||||||
title = "Breaking change";
|
|
||||||
options = [
|
|
||||||
{ name = "no"; value = ""; }
|
|
||||||
{ name = "yes"; value = "!"; }
|
|
||||||
];
|
|
||||||
}
|
|
||||||
{
|
|
||||||
type = "input";
|
|
||||||
title = "message";
|
|
||||||
key = "Message";
|
|
||||||
initialValue = "";
|
|
||||||
}
|
|
||||||
{
|
|
||||||
type = "confirm";
|
|
||||||
key = "Confirm";
|
|
||||||
title = "Commit";
|
|
||||||
body = "Are you sure you want to commit?";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
command = "git commit --message '{{.Form.Type}}{{ if .Form.Scope }}({{ .Form.Scope }}){{ end }}{{.Form.Breaking}}: {{.Form.Message}}'";
|
|
||||||
loadingText = "Creating conventional commit...";
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
home = {
|
home = {
|
||||||
username = "moritz";
|
username = "moritz";
|
||||||
|
|
95
modules/programs/lazygit.nix
Normal file
95
modules/programs/lazygit.nix
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
{ config
|
||||||
|
, lib
|
||||||
|
, pkgs
|
||||||
|
, ...
|
||||||
|
}:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
cfg = config.my.programs.lazygit;
|
||||||
|
|
||||||
|
wrapper = pkgs.writeShellApplication {
|
||||||
|
name = "lg";
|
||||||
|
text = ''
|
||||||
|
export LAZYGIT_NEW_DIR_FILE="$HOME/.lazygit/newdir"
|
||||||
|
|
||||||
|
lazygit "$@"
|
||||||
|
|
||||||
|
if [ -f "$LAZYGIT_NEW_DIR_FILE" ]; then
|
||||||
|
cd "$(cat "$LAZYGIT_NEW_DIR_FILE")"
|
||||||
|
rm -f "$LAZYGIT_NEW_DIR_FILE" > /dev/null
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
runtimeInputs = [ pkgs.lazygit ];
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.my.programs.lazygit.enable = mkEnableOption "lazygit";
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
home-manager.users.moritz.home.packages = [
|
||||||
|
wrapper
|
||||||
|
];
|
||||||
|
home-manager.users.moritz.programs.lazygit = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
customCommands = [
|
||||||
|
{
|
||||||
|
key = "<c-v>";
|
||||||
|
context = "global";
|
||||||
|
description = "Create new conventional commit";
|
||||||
|
prompts = [
|
||||||
|
{
|
||||||
|
type = "menu";
|
||||||
|
key = "Type";
|
||||||
|
title = "Type of change";
|
||||||
|
options = [
|
||||||
|
{ name = "build"; description = "Changes that affect the build system or external dependencies"; value = "build"; }
|
||||||
|
{ name = "feat"; description = "A new feature"; value = "feat"; }
|
||||||
|
{ name = "fix"; description = "A bug fix"; value = "fix"; }
|
||||||
|
{ name = "chore"; description = "Other changes that don't modify src or test files"; value = "chore"; }
|
||||||
|
{ name = "ci"; description = "Changes to CI configuration files and scripts"; value = "ci"; }
|
||||||
|
{ name = "docs"; description = "Documentation only changes"; value = "docs"; }
|
||||||
|
{ name = "perf"; description = "A code change that improves performance"; value = "perf"; }
|
||||||
|
{ name = "refactor"; description = "A code change that neither fixes a bug nor adds a feature"; value = "refactor"; }
|
||||||
|
{ name = "revert"; description = "Reverts a previous commit"; value = "revert"; }
|
||||||
|
{ name = "style"; description = "Changes that do not affect the meaning of the code"; value = "style"; }
|
||||||
|
{ name = "test"; description = "Adding missing tests or correcting existing tests"; value = "test"; }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
type = "input";
|
||||||
|
title = "Scope";
|
||||||
|
key = "Scope";
|
||||||
|
initialValue = "";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
type = "menu";
|
||||||
|
key = "Breaking";
|
||||||
|
title = "Breaking change";
|
||||||
|
options = [
|
||||||
|
{ name = "no"; value = ""; }
|
||||||
|
{ name = "yes"; value = "!"; }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
{
|
||||||
|
type = "input";
|
||||||
|
title = "message";
|
||||||
|
key = "Message";
|
||||||
|
initialValue = "";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
type = "confirm";
|
||||||
|
key = "Confirm";
|
||||||
|
title = "Commit";
|
||||||
|
body = "Are you sure you want to commit?";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
command = "git commit --message '{{.Form.Type}}{{ if .Form.Scope }}({{ .Form.Scope }}){{ end }}{{.Form.Breaking}}: {{.Form.Message}}'";
|
||||||
|
loadingText = "Creating conventional commit...";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue