From ba9c1a5c098e5c3f676071a1c28158cd860bc8ff Mon Sep 17 00:00:00 2001 From: Gabe Venberg Date: Mon, 18 Mar 2024 23:12:35 -0500 Subject: [PATCH] modularized config. --- README.md | 4 +- nix/flake.nix | 4 +- nix/git.nix | 58 ++++++++++ nix/home.nix | 231 +++------------------------------------- nix/justfile | 4 +- nix/nushell/nushell.nix | 21 ++++ nix/starship.nix | 109 +++++++++++++++++++ nix/zsh.nix | 39 +++++++ 8 files changed, 249 insertions(+), 221 deletions(-) create mode 100644 nix/git.nix create mode 100644 nix/nushell/nushell.nix create mode 100644 nix/starship.nix create mode 100644 nix/zsh.nix diff --git a/README.md b/README.md index 8621edf..bcac8e6 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/nix/flake.nix b/nix/flake.nix index b746a82..73f2471 100644 --- a/nix/flake.nix +++ b/nix/flake.nix @@ -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 diff --git a/nix/git.nix b/nix/git.nix new file mode 100644 index 0000000..721bb59 --- /dev/null +++ b/nix/git.nix @@ -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; +} diff --git a/nix/home.nix b/nix/home.nix index 23ada25..53c8d52 100644 --- a/nix/home.nix +++ b/nix/home.nix @@ -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"]; }; } diff --git a/nix/justfile b/nix/justfile index 42e4959..e932fba 100644 --- a/nix/justfile +++ b/nix/justfile @@ -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 diff --git a/nix/nushell/nushell.nix b/nix/nushell/nushell.nix new file mode 100644 index 0000000..3b7997a --- /dev/null +++ b/nix/nushell/nushell.nix @@ -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; +} diff --git a/nix/starship.nix b/nix/starship.nix new file mode 100644 index 0000000..e54af36 --- /dev/null +++ b/nix/starship.nix @@ -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; + }; + }; +} diff --git a/nix/zsh.nix b/nix/zsh.nix new file mode 100644 index 0000000..0c816e7 --- /dev/null +++ b/nix/zsh.nix @@ -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" + ]; + }; + }; +}