more organization for componentizing home-manager conifg

nix-rearch
pegasust 2022-12-10 18:46:05 -07:00
parent b8d7024b93
commit ca42be3f5f
6 changed files with 92 additions and 41 deletions

View File

@ -1,3 +1,9 @@
{ {
mkModuleArgs = import ./mkModuleArgs.nix;
modules = [
./alacritty.nix
./git.nix
./ssh.nix
./shells.nix
];
} }

View File

@ -1,3 +1,80 @@
{ { config
, myLib
, ...
}: }:
let
cfg = config.base.git;
baseAliases = {
a = "add";
c = "commit";
ca = "commit --amend";
cm = "commit -m";
lol = "log --graph --decorate --pretty=oneline --abbrev-commit";
lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all";
sts = "status";
co = "checkout";
b = "branch";
};
in
{
options.base.git = {
aliases = myLib.mkOption {
type = myLib.types.attrs;
default = { };
example = baseAliases;
description = ''
Additional git aliases. This settings comes with base configuration.
Redeclaring the base config will override the values.
''; # TODO: Add baseAliases as string here (builtins.toString doesn't work)
};
name = myLib.mkOption {
type = myLib.types.str;
default = "Pegasust";
description = "Git username that appears on commits";
example = "Pegasust";
};
email = myLib.mkOption {
type = myLib.types.str;
default = "pegasucksgg@gmail.com";
example = "peagsucksgg@gmail.com";
description = "Git email that appears on commits";
};
ignores = myLib.mkOption {
type = myLib.types.listOf myLib.types.str;
default = [
".vscode" # vscode settings
".direnv" # .envrc cached outputs
];
description = ''
.gitignore patterns that are applied in every repository.
This is useful for IDE-specific settings.
'';
example = [ ".direnv" "node_modules" ];
};
enable = myLib.mkOption {
type = myLib.types.bool;
default = true;
description = ''
Enables git
'';
example = false;
};
credentialCacheTimeoutSeconds = myLib.mkOption {
type = myLib.types.int;
default = 3000;
description = "Credential cache (in-memory store) for Git in seconds.";
example = 3000;
};
};
# TODO : anyway to override configuration?
config.programs.git = {
inherit (cfg) enable ignores;
userName = cfg.name;
userEmail = cfg.email;
aliases = baseAliases // cfg.aliases;
extraConfig = {
credential.helper = "cache --timeout=${builtins.toString cfg.credentialCacheTimeoutSeconds}";
};
lfs.enable = true;
};
}

View File

@ -0,0 +1 @@
{}

View File

@ -0,0 +1 @@
{}

View File

@ -28,7 +28,8 @@
config = { allowUnfree = true; }; config = { allowUnfree = true; };
}; };
# lib = (import ../lib { inherit pkgs; lib = pkgs.lib; }); # lib = (import ../lib { inherit pkgs; lib = pkgs.lib; });
mkModuleArgs = import ./base/mkModuleArgs.nix; base = import ./base;
inherit (base) mkModuleArgs;
in in
{ {
homeConfigurations = homeConfigurations =
@ -41,7 +42,7 @@
rec { rec {
"hungtr" = home-manager.lib.homeManagerConfiguration { "hungtr" = home-manager.lib.homeManagerConfiguration {
inherit pkgs; inherit pkgs;
modules = [ modules = base.modules ++ [
./home.nix ./home.nix
]; ];
# optionally pass inarguments to module # optionally pass inarguments to module
@ -93,9 +94,8 @@
# Personal laptop # Personal laptop
hwtr = home-manager.lib.homeManagerConfiguration { hwtr = home-manager.lib.homeManagerConfiguration {
inherit pkgs; inherit pkgs;
modules = [ modules = base.modules ++ [
./home.nix ./home.nix
./base/alacritty.nix
{ {
base.alacritty.font.family = "BitstreamVeraSansMono Nerd Font"; base.alacritty.font.family = "BitstreamVeraSansMono Nerd Font";
} }

View File

@ -139,40 +139,6 @@ in
}; };
initExtra = myHome.shellInitExtra or ""; initExtra = myHome.shellInitExtra or "";
}; };
programs.git = {
enable = true;
lfs.enable = true;
aliases = {
a = "add";
c = "commit";
ca = "commit --amend";
cm = "commit -m";
lol = "log --graph --decorate --pretty=oneline --abbrev-commit";
lola = "log --graph --decorate --pretty=oneline --abbrev-commit --all";
sts = "status";
co = "checkout";
b = "branch";
};
# No idea why this is not appearing in home-manager search
# It's in source code, though
userName = "pegasust";
userEmail = "pegasucksgg@gmail.com";
extraConfig = {
merge = { tool = "vimdiff"; conflictstyle = "diff3"; };
};
ignores = [
# vscode-related settings
".vscode"
# envrc cached outputs
".direnv"
];
extraConfig = {
# cache credential for 50 minutes (a pomodoro session)
credential.helper = "cache --timeout=3000";
};
# why is this no longer valid?
# pull = { rebase=true; };
};
programs.ssh = { programs.ssh = {
enable = true; enable = true;
forwardAgent = true; forwardAgent = true;