modularized config.

This commit is contained in:
Gabe Venberg 2024-03-18 23:12:35 -05:00
parent 54d8dcbe11
commit ba9c1a5c09
8 changed files with 249 additions and 221 deletions

View file

@ -4,8 +4,8 @@ all of my dotfiles, managed with (https://www.gnu.org/software/stow/manual/stow.
I am working on migrating my dotfiles to nix, to allow configuration and installation in a single step.
In order to use the nix setup, you need to install nix and enable flakes,
then run `nix run --extra-experimental-features "nix-command flakes" --no-write-lock-file github:nix-community/home-manager/ -- --extra-experimental-features "nix-command flakes" --impure --flake . switch`, while in the nix directory.
from then on, you can update your configuration after making a change with `home-manager --impure --flake . switch`.
then run `nix run --extra-experimental-features "nix-command flakes" --no-write-lock-file github:nix-community/home-manager/ -- --extra-experimental-features "nix-command flakes" --flake . switch`, while in the nix directory.
from then on, you can update your configuration after making a change with `home-manager --flake . switch`.
Alternatively, if you have `just` installed, you can use `just boostrap` and `just switch`, instead.
## Dependencies:

View file

@ -24,7 +24,9 @@
# Specify your home configuration modules here, for example,
# the path to your home.nix.
modules = [./home.nix];
modules = [
./home.nix
];
# Optionally use extraSpecialArgs
# to pass through arguments to home.nix

58
nix/git.nix Normal file
View file

@ -0,0 +1,58 @@
{
config,
pgks,
lib,
...
}: {
programs.git = {
enable = true;
aliases = {
hist = "log --graph --date-order --date=short --pretty=format:'%C(auto)%h%d %C(reset)%s %C(bold blue)%ce %C(reset)%C(green)%cr (%cd)'";
graph = "log --graph --topo-order --all --pretty=format:'%C(auto)%h %C(cyan)%an %C(blue)%ar %C(auto)%d %s'";
recent = "branch --sort=-committerdate --format='%(committerdate:relative)%09%(refname:short)'";
};
delta.enable = true;
# difftastic.enable=true;
# difftastic.background="dark";
userEmail = "gabevenberg@gmail.com";
userName = "Gabe Venberg";
extraConfig = {
init = {
defaultBranch = "main";
};
push = {
autoSetupRemote = true;
default = "current";
};
pull = {
ff = true;
};
merge = {
conflictstyle = "zdiff3";
};
rebase = {
autosquash = true;
};
help = {
autocorrect = "prompt";
};
branch = {
sort = "-committerdate";
};
status = {
submodulesummary = true;
};
};
includes = [
{
condition = "gitdir:~/work/";
contents = {
user = {
email = "venberggabe@johndeere.com";
};
};
}
];
};
programs.lazygit.enable = true;
}

View file

@ -3,9 +3,7 @@
pkgs,
lib,
...
}: let
dotfilesDirectory = ~/dotfiles/nix;
in {
}: {
# Home Manager needs a bit of information about you and the paths it should
# manage.
home.username = "gabe";
@ -13,17 +11,15 @@ in {
home.stateVersion = "23.11"; # Please read the comment before changing.
home.packages = [
pkgs.zellij
pkgs.sshfs
home.packages = with pkgs; [
zellij
sshfs
];
# Home Manager is pretty good at managing dotfiles. The primary way to manage
# plain files is through 'home.file'.
home.file = {
".config/zellij/config.kdl".source = lib.path.append dotfilesDirectory "zellij/config.kdl";
".config/nushell/scripts".source = lib.path.append dotfilesDirectory "nushell/scripts";
".config/zellij/config.kdl".source = ./zellij/config.kdl;
};
home.sessionVariables = {
@ -46,215 +42,18 @@ in {
sshmnt = "sshfs -o idmap=user,compression=no,reconnect,follow_symlinks,dir_cache=yes,ServerAliveInterval=15";
};
programs.git = {
enable = true;
aliases = {
hist = "log --graph --date-order --date=short --pretty=format:'%C(auto)%h%d %C(reset)%s %C(bold blue)%ce %C(reset)%C(green)%cr (%cd)'";
graph = "log --graph --topo-order --all --pretty=format:'%C(auto)%h %C(cyan)%an %C(blue)%ar %C(auto)%d %s'";
recent = "branch --sort=-committerdate --format='%(committerdate:relative)%09%(refname:short)'";
};
delta.enable = true;
# difftastic.enable=true;
# difftastic.background="dark";
userEmail = "gabevenberg@gmail.com";
userName = "Gabe Venberg";
extraConfig = {
init = {
defaultBranch = "main";
};
push = {
autoSetupRemote = true;
default = "current";
};
pull = {
ff = true;
};
merge = {
conflictstyle = "zdiff3";
};
rebase = {
autosquash = true;
};
help = {
autocorrect = "prompt";
};
branch = {
sort = "-committerdate";
};
status = {
submodulesummary = true;
};
};
includes = [
{
condition = "gitdir:~/work/";
contents = {
user = {
email = "venberggabe@johndeere.com";
};
};
}
];
};
programs.lazygit.enable = true;
imports = [
./nushell/nushell.nix
./zsh.nix
./git.nix
./starship.nix
];
programs.yazi = {
enable = true;
enableNushellIntegration = true;
enableZshIntegration = true;
};
programs.yazi.enable = true;
programs.zoxide = {
enable = true;
enableNushellIntegration = true;
enableZshIntegration = true;
};
programs.zoxide.enable = true;
programs.fzf = {
enable = true;
enableZshIntegration = true;
};
programs.starship = {
enable = true;
enableNushellIntegration = true;
enableZshIntegration = true;
settings = {
format = lib.concatStrings [
"[](color_orange)"
"$shell"
"$hostname"
"[@](bg:color_orange)"
"$username"
"[ ](bg:color_orange)"
"[](bg:color_yellow fg:color_orange)"
"$directory"
"[](fg:color_yellow bg:color_aqua)"
"$git_branch"
"$git_status"
"[](fg:color_aqua bg:color_blue)"
"$git_metrics"
"[](fg:color_blue bg:color_bg3)"
"$git_commit"
"$fill"
"[](fg:color_bg1 bg:color_bg3)"
"$time"
"[ ](fg:color_bg1)"
"$line_break"
"$character"
];
add_newline = false;
palette = "gruvbox_dark";
palettes.gruvbox_dark = {
color_fg0 = "#fbf1c7";
color_bg1 = "#3c3836";
color_bg3 = "#665c54";
color_blue = "#458588";
color_aqua = "#689d6a";
color_green = "#98971a";
color_orange = "#d65d0e";
color_purple = "#b16286";
color_red = "#cc241d";
color_yellow = "#d79921";
};
hostname = {
ssh_only = false;
format = "[$ssh_symbol$hostname]($style)";
style = "bg:color_orange";
};
shell = {
disabled = false;
bash_indicator = "$";
fish_indicator = "<><";
zsh_indicator = "%";
nu_indicator = ">";
format = "[$indicator ]($style)";
style = "bg:color_orange";
};
fill = {
symbol = " ";
style = "bg:color_bg3";
};
username = {
show_always = true;
style_user = "bg:color_orange fg:color_fg0";
style_root = "bg:color_orange fg:color_fg0";
format = "[$user]($style)";
};
directory = {
style = "fg:color_fg0 bg:color_yellow";
format = "[ $path ]($style)";
fish_style_pwd_dir_length = 3;
truncation_length = 4;
truncation_symbol = "/";
};
git_branch = {
symbol = "";
style = "bg:color_aqua";
format = "[[ $symbol $branch ](fg:color_fg0 bg:color_aqua)]($style)";
};
git_status = {
style = "bg:color_aqua";
format = "[[($all_status$ahead_behind )](fg:color_fg0 bg:color_aqua)]($style)";
};
git_metrics = {
disabled = false;
added_style = "bg:color_blue fg:bold green";
deleted_style = "bg:color_blue fg:bold red";
format = "([ +$added ]($added_style))([-$deleted ]($deleted_style))";
};
git_commit = {
only_detached = false;
tag_disabled = false;
format = "[($hash$tag)]($style)";
style = "bg:color_bg3";
};
time = {
disabled = false;
time_format = "%R";
style = "bg:color_bg1";
format = "[[ $time ](fg:color_fg0 bg:color_bg1)]($style)";
};
line_break.disabled = false;
character.disabled = false;
};
};
#sessionVariables, sessionPath and shellAliases are not applied to nushell.
programs.nushell = {
enable = true;
configFile.source = lib.path.append dotfilesDirectory "nushell/config.nu";
envFile.source = lib.path.append dotfilesDirectory "nushell/env.nu";
};
programs.zsh = {
enable = true;
enableCompletion = true;
autocd = true;
history = {
ignoreAllDups = true;
extended = true;
};
shellAliases = {
ll = "ls -lh";
la = "-lha";
please = "sudo $(fc -ln -1)";
slideshow = "feh --full-screen --randomize --auto-zoom --recursive --slideshow-delay";
pyactivate = "source ./.venv/bin/activate";
};
syntaxHighlighting = {
enable = true;
highlighters = [
"main"
"brackets"
"pattern"
"regexp"
"cursor"
"root"
"line"
];
};
};
programs.fzf.enable = true;
services.ssh-agent.enable = true;
@ -264,6 +63,6 @@ in {
# enable flakes
nix = {
package = pkgs.nix;
settings.experimental-features = [ "nix-command" "flakes" ];
settings.experimental-features = ["nix-command" "flakes"];
};
}

View file

@ -1,5 +1,5 @@
switch:
home-manager --impure --flake . switch
home-manager --flake . switch
bootstrap:
nix run --extra-experimental-features "nix-command flakes" --no-write-lock-file github:nix-community/home-manager/ -- --extra-experimental-features "nix-command flakes" --impure --flake . switch
nix run --extra-experimental-features "nix-command flakes" --no-write-lock-file github:nix-community/home-manager/ -- --extra-experimental-features "nix-command flakes" --flake . switch

21
nix/nushell/nushell.nix Normal file
View file

@ -0,0 +1,21 @@
{
config,
pkgs,
lib,
...
}: {
#sessionVariables, sessionPath and shellAliases are not applied to nushell.
programs.nushell = {
enable = true;
configFile.source = ./config.nu;
envFile.source = ./env.nu;
};
home.file = {
".config/nushell/scripts".source = ./scripts;
};
programs.yazi.enableNushellIntegration = true;
programs.zoxide.enableNushellIntegration = true;
programs.starship.enableNushellIntegration = true;
}

109
nix/starship.nix Normal file
View file

@ -0,0 +1,109 @@
{
config,
pkgs,
lib,
...
}: {
programs.starship = {
enable = true;
settings = {
format = lib.concatStrings [
"[](color_orange)"
"$shell"
"$hostname"
"[@](bg:color_orange)"
"$username"
"[ ](bg:color_orange)"
"[](bg:color_yellow fg:color_orange)"
"$directory"
"[](fg:color_yellow bg:color_aqua)"
"$git_branch"
"$git_status"
"[](fg:color_aqua bg:color_blue)"
"$git_metrics"
"[](fg:color_blue bg:color_bg3)"
"$git_commit"
"$fill"
"[](fg:color_bg1 bg:color_bg3)"
"$time"
"[ ](fg:color_bg1)"
"$line_break"
"$character"
];
add_newline = false;
palette = "gruvbox_dark";
palettes.gruvbox_dark = {
color_fg0 = "#fbf1c7";
color_bg1 = "#3c3836";
color_bg3 = "#665c54";
color_blue = "#458588";
color_aqua = "#689d6a";
color_green = "#98971a";
color_orange = "#d65d0e";
color_purple = "#b16286";
color_red = "#cc241d";
color_yellow = "#d79921";
};
hostname = {
ssh_only = false;
format = "[$ssh_symbol$hostname]($style)";
style = "bg:color_orange";
};
shell = {
disabled = false;
bash_indicator = "$";
fish_indicator = "<><";
zsh_indicator = "%";
nu_indicator = ">";
format = "[$indicator ]($style)";
style = "bg:color_orange";
};
fill = {
symbol = " ";
style = "bg:color_bg3";
};
username = {
show_always = true;
style_user = "bg:color_orange fg:color_fg0";
style_root = "bg:color_orange fg:color_fg0";
format = "[$user]($style)";
};
directory = {
style = "fg:color_fg0 bg:color_yellow";
format = "[ $path ]($style)";
fish_style_pwd_dir_length = 3;
truncation_length = 4;
truncation_symbol = "/";
};
git_branch = {
symbol = "";
style = "bg:color_aqua";
format = "[[ $symbol $branch ](fg:color_fg0 bg:color_aqua)]($style)";
};
git_status = {
style = "bg:color_aqua";
format = "[[($all_status$ahead_behind )](fg:color_fg0 bg:color_aqua)]($style)";
};
git_metrics = {
disabled = false;
added_style = "bg:color_blue fg:bold green";
deleted_style = "bg:color_blue fg:bold red";
format = "([ +$added ]($added_style))([-$deleted ]($deleted_style))";
};
git_commit = {
only_detached = false;
tag_disabled = false;
format = "[($hash$tag)]($style)";
style = "bg:color_bg3";
};
time = {
disabled = false;
time_format = "%R";
style = "bg:color_bg1";
format = "[[ $time ](fg:color_fg0 bg:color_bg1)]($style)";
};
line_break.disabled = false;
character.disabled = false;
};
};
}

39
nix/zsh.nix Normal file
View file

@ -0,0 +1,39 @@
{
config,
pkgs,
lib,
...
}: {
programs.starship.enableZshIntegration = true;
programs.fzf.enableZshIntegration = true;
programs.zoxide.enableZshIntegration = true;
programs.yazi.enableZshIntegration = true;
programs.zsh = {
enable = true;
enableCompletion = true;
autocd = true;
history = {
ignoreAllDups = true;
extended = true;
};
shellAliases = {
ll = "ls -lh";
la = "-lha";
please = "sudo $(fc -ln -1)";
slideshow = "feh --full-screen --randomize --auto-zoom --recursive --slideshow-delay";
pyactivate = "source ./.venv/bin/activate";
};
syntaxHighlighting = {
enable = true;
highlighters = [
"main"
"brackets"
"pattern"
"regexp"
"cursor"
"root"
"line"
];
};
};
}