refactor(modules/hm): tidy up the modules
Should make further additions and refactors easier.
This commit is contained in:
parent
917d131cde
commit
0df4e76404
3 changed files with 120 additions and 98 deletions
|
@ -16,6 +16,7 @@ in
|
|||
imports = [
|
||||
./options.nix
|
||||
./gui
|
||||
./dev.nix
|
||||
./users.nix
|
||||
];
|
||||
|
||||
|
@ -23,7 +24,7 @@ in
|
|||
(lib.mkIf (cfg.enable && cfg.styling.enable) {
|
||||
stylix = {
|
||||
enable = true;
|
||||
targets.nixvim.enable = false; # I prefer doing it myself
|
||||
targets.nixvim.enable = false; # I prefer styling it myself
|
||||
};
|
||||
})
|
||||
(lib.mkIf cfg.enable {
|
||||
|
@ -35,6 +36,7 @@ in
|
|||
"settings"
|
||||
"use-xdg-base-directories"
|
||||
] true;
|
||||
|
||||
programs = {
|
||||
# Better cat (bat)
|
||||
bat = {
|
||||
|
@ -84,6 +86,7 @@ in
|
|||
syntaxHighlighting.enable = true;
|
||||
};
|
||||
};
|
||||
|
||||
services = {
|
||||
# GPG Agent
|
||||
gpg-agent = {
|
||||
|
@ -103,6 +106,7 @@ in
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
home = {
|
||||
stateVersion = "22.11";
|
||||
# Extra packages
|
||||
|
@ -127,6 +131,7 @@ in
|
|||
tree = "eza --tree";
|
||||
};
|
||||
};
|
||||
|
||||
# XDG directories
|
||||
xdg = {
|
||||
enable = true;
|
||||
|
@ -136,86 +141,5 @@ in
|
|||
};
|
||||
};
|
||||
})
|
||||
(lib.mkIf (cfg.enable && devcfg.enable) {
|
||||
home = {
|
||||
sessionVariables.MANPAGER = lib.optionalString devcfg.neovimAsManPager "nvim -c 'Man!' -o -";
|
||||
packages = devcfg.extraPackages;
|
||||
};
|
||||
# Github CLI
|
||||
programs = {
|
||||
gh.enable = true;
|
||||
gh-dash.enable = true;
|
||||
# Git
|
||||
git = {
|
||||
enable = true;
|
||||
difftastic = {
|
||||
enable = true;
|
||||
background = "dark";
|
||||
};
|
||||
lfs.enable = true;
|
||||
extraConfig = {
|
||||
# Add diff to the commit message editor
|
||||
commit.verbose = true;
|
||||
# Improve submodule diff
|
||||
diff.submodule = "log";
|
||||
# Set the default branch name for new branches
|
||||
init.defaultBranch = "main";
|
||||
# Better conflicts (also shows parent commit state)
|
||||
merge.conflictStyle = "zdiff3";
|
||||
# Do not create merge commits when pulling (rebase but abort on conflict)
|
||||
pull.ff = "only";
|
||||
# Use `--set-upstream` if the remote does not have the branch
|
||||
push.autoSetupRemote = true;
|
||||
rebase = {
|
||||
# If there are uncommitted changes, stash them before rebasing
|
||||
autoStash = true;
|
||||
# If there are fixup! commits, squash them while rebasing
|
||||
autoSquash = true;
|
||||
};
|
||||
# Enable ReReRe (Reuse Recovered Resolution) auto resolve previously resolved conflicts
|
||||
rerere.enabled = true;
|
||||
# Improve submodule status
|
||||
status.submoduleSummary = true;
|
||||
};
|
||||
};
|
||||
lazygit.enable = true;
|
||||
# Jujutsu (alternative DVCS (git-compatible))
|
||||
jujutsu = {
|
||||
enable = true;
|
||||
package = pkgs.unstable.jujutsu;
|
||||
settings = {
|
||||
ui.pager = "bat";
|
||||
# mimic git commit --verbose by adding a diff
|
||||
templates.draft_commit_description = ''
|
||||
concat(
|
||||
description,
|
||||
surround(
|
||||
"\nJJ: This commit contains the following changes:\n", "",
|
||||
indent("JJ: ", diff.stat(72)),
|
||||
),
|
||||
surround(
|
||||
"\nJJ: Diff:\n", "",
|
||||
indent("JJ: ", diff.git()),
|
||||
),
|
||||
)
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
(lib.mkIf (cfg.enable && devcfg.enable && devcfg.rust.enable) {
|
||||
home.packages = [ pkgs.rustup ] ++ devcfg.rust.extraPackages;
|
||||
# Background code checker (for Rust)
|
||||
programs.bacon = {
|
||||
enable = true;
|
||||
settings = {
|
||||
export = {
|
||||
enabled = true;
|
||||
path = ".bacon-locations";
|
||||
line_format = "{kind} {path}:{line}:{column} {message}";
|
||||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
||||
|
|
101
modules/hm/dev.nix
Normal file
101
modules/hm/dev.nix
Normal file
|
@ -0,0 +1,101 @@
|
|||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
cfg = config.jhome.dev;
|
||||
in
|
||||
{
|
||||
config =
|
||||
lib.flip lib.pipe
|
||||
[
|
||||
lib.mkMerge
|
||||
(lib.mkIf (config.jhome.enable && cfg.enable))
|
||||
]
|
||||
[
|
||||
(lib.mkIf cfg.rust.enable {
|
||||
home.packages = [ pkgs.rustup ] ++ cfg.rust.extraPackages;
|
||||
# Background code checker (for Rust)
|
||||
programs.bacon = {
|
||||
enable = true;
|
||||
settings = {
|
||||
export = {
|
||||
enabled = true;
|
||||
path = ".bacon-locations";
|
||||
line_format = "{kind} {path}:{line}:{column} {message}";
|
||||
};
|
||||
};
|
||||
};
|
||||
})
|
||||
{
|
||||
home = {
|
||||
sessionVariables.MANPAGER = lib.optionalString cfg.neovimAsManPager "nvim -c 'Man!' -o -";
|
||||
packages = cfg.extraPackages;
|
||||
};
|
||||
|
||||
# Github CLI
|
||||
programs = {
|
||||
gh.enable = true;
|
||||
gh-dash.enable = true;
|
||||
# Git
|
||||
git = {
|
||||
enable = true;
|
||||
difftastic = {
|
||||
enable = true;
|
||||
background = "dark";
|
||||
};
|
||||
lfs.enable = true;
|
||||
extraConfig = {
|
||||
# Add diff to the commit message editor
|
||||
commit.verbose = true;
|
||||
# Improve submodule diff
|
||||
diff.submodule = "log";
|
||||
# Set the default branch name for new branches
|
||||
init.defaultBranch = "main";
|
||||
# Better conflicts (also shows parent commit state)
|
||||
merge.conflictStyle = "zdiff3";
|
||||
# Do not create merge commits when pulling (rebase but abort on conflict)
|
||||
pull.ff = "only";
|
||||
# Use `--set-upstream` if the remote does not have the branch
|
||||
push.autoSetupRemote = true;
|
||||
rebase = {
|
||||
# If there are uncommitted changes, stash them before rebasing
|
||||
autoStash = true;
|
||||
# If there are fixup! commits, squash them while rebasing
|
||||
autoSquash = true;
|
||||
};
|
||||
# Enable ReReRe (Reuse Recovered Resolution) auto resolve previously resolved conflicts
|
||||
rerere.enabled = true;
|
||||
# Improve submodule status
|
||||
status.submoduleSummary = true;
|
||||
};
|
||||
};
|
||||
lazygit.enable = true;
|
||||
# Jujutsu (alternative DVCS (git-compatible))
|
||||
jujutsu = {
|
||||
enable = true;
|
||||
package = pkgs.unstable.jujutsu;
|
||||
settings = {
|
||||
ui.pager = "bat";
|
||||
# mimic git commit --verbose by adding a diff
|
||||
templates.draft_commit_description = ''
|
||||
concat(
|
||||
description,
|
||||
surround(
|
||||
"\nJJ: This commit contains the following changes:\n", "",
|
||||
indent("JJ: ", diff.stat(72)),
|
||||
),
|
||||
surround(
|
||||
"\nJJ: Diff:\n", "",
|
||||
indent("JJ: ", diff.git()),
|
||||
),
|
||||
)
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
}
|
|
@ -4,15 +4,12 @@ let
|
|||
inherit (cfg.defaultIdentity) signingKey;
|
||||
|
||||
cfg = jhome.user;
|
||||
hasConfig = jhome.enable && cfg != null;
|
||||
hasKey = signingKey != null;
|
||||
gpgHome = config.programs.gpg.homedir;
|
||||
unlockKey = hasConfig && cfg.gpg.unlockKeys != [ ];
|
||||
in
|
||||
{
|
||||
config = lib.mkMerge [
|
||||
(lib.mkIf hasConfig {
|
||||
programs.git = {
|
||||
config = lib.mkIf (jhome.enable && cfg != null) {
|
||||
programs = {
|
||||
git = {
|
||||
userName = cfg.defaultIdentity.name;
|
||||
userEmail = cfg.defaultIdentity.email;
|
||||
signing = lib.mkIf hasKey {
|
||||
|
@ -20,7 +17,8 @@ in
|
|||
key = signingKey;
|
||||
};
|
||||
};
|
||||
programs.jujutsu.settings = {
|
||||
|
||||
jujutsu.settings = {
|
||||
user = lib.mkIf (cfg.defaultIdentity != null) { inherit (cfg.defaultIdentity) name email; };
|
||||
git.sign-on-push = lib.mkDefault hasKey;
|
||||
signing = lib.mkIf hasKey {
|
||||
|
@ -29,14 +27,13 @@ in
|
|||
key = signingKey;
|
||||
};
|
||||
};
|
||||
})
|
||||
(lib.mkIf unlockKey {
|
||||
xdg.configFile.pam-gnupg.text =
|
||||
''
|
||||
${gpgHome}
|
||||
};
|
||||
|
||||
''
|
||||
+ (lib.strings.concatLines cfg.gpg.unlockKeys);
|
||||
})
|
||||
];
|
||||
xdg.configFile.pam-gnupg.text =
|
||||
lib.mkIf (cfg.unlockKeys != [ ]) ''
|
||||
${config.programs.gpg.homedir}
|
||||
|
||||
''
|
||||
+ (lib.strings.concatLines cfg.gpg.unlockKeys);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue