Organise NixOS and Home Manager modules

This commit is contained in:
Oliver Davies 2024-11-05 18:55:05 +00:00
parent 501b5cd011
commit 3c7aa3f03e
31 changed files with 26 additions and 25 deletions

View file

@ -16,19 +16,19 @@
programs.home-manager.enable = true;
imports = [
(import ./modules/git.nix { inherit inputs pkgs; })
(import ./modules/neovim.nix { inherit inputs pkgs; })
./modules/bat.nix
./modules/bin.nix
./modules/direnv.nix
./modules/fzf.nix
./modules/lsd.nix
./modules/pet.nix
./modules/phpactor.nix
./modules/ripgrep.nix
./modules/syncthing.nix
./modules/tmux.nix
./modules/zellij.nix
./modules/zsh.nix
(import ../../modules/home-manager/git.nix { inherit inputs pkgs; })
(import ../../modules/home-manager/neovim.nix { inherit inputs pkgs; })
../../modules/home-manager/bat.nix
../../modules/home-manager/bin.nix
../../modules/home-manager/direnv.nix
../../modules/home-manager/fzf.nix
../../modules/home-manager/lsd.nix
../../modules/home-manager/pet.nix
../../modules/home-manager/phpactor.nix
../../modules/home-manager/ripgrep.nix
../../modules/home-manager/syncthing.nix
../../modules/home-manager/tmux.nix
../../modules/home-manager/zellij.nix
../../modules/home-manager/zsh.nix
];
}

View file

@ -1 +0,0 @@
{ programs.bat.enable = true; }

View file

@ -1,9 +0,0 @@
{ self, ... }:
{
home.sessionPath = [ "$HOME/.local/bin" ];
home.file.".local/bin" = {
source = "${self}/bin";
recursive = true;
};
}

View file

@ -1,7 +0,0 @@
{
programs.direnv = {
enable = true;
enableZshIntegration = true;
nix-direnv.enable = true;
};
}

View file

@ -1,6 +0,0 @@
{
programs.fzf = {
enable = true;
enableZshIntegration = true;
};
}

View file

@ -1,154 +0,0 @@
{ pkgs, ... }:
{
home.file.".gitmessage".text = ''
# Description
#
# - Why is this change necessary?
# - How does it address the issue?
# - What side effects does this change have?
#
# For breaking changes, uncomment the following line and describe the change:
#
# BREAKING CHANGE:
#
#
# Add any issue IDs or commit SHAs that this commit references:
#
# Refs:
'';
programs = {
git = {
enable = true;
userName = "Oliver Davies";
userEmail = "oliver@oliverdavies.dev";
includes = [
{
condition = "gitdir:~/Code/tfw";
contents.user.email = "oliver.davies@tfw.wales";
}
];
aliases = {
aa = "add --all";
assume = "update-index --assume-unchanged";
assumed = "!git ls-files -v | grep '^[hsmrck?]' | cut -c 3-";
b = "branch";
blame = "blame -w -C -C -C";
browse = "!gh repo view --web";
ca = "commit --amend --verbose";
car = "commit --amend --no-edit";
cl = "!hub clone";
co = "checkout";
compare = "!hub compare";
current-branch = "rev-parse --abbrev-ref HEAD";
dc = "diff --color --word-diff --cached";
df = "diff --color --word-diff";
dup = "!git checkout develop && git fetch origin && echo && git sl develop..origin/develop && echo && git pull --quiet && git checkout -";
fixup = "commit --fixup";
issues = "!gh issue list --web";
mup = "!git master-to-main-wrapper checkout %BRANCH% && git fetch origin && echo && git sl %BRANCH%..origin/%BRANCH% && echo && git pull --quiet && git checkout -";
no-ff = "merge --no-ff";
pl = "pull";
prune = "remote prune origin";
ps = "push";
pulls = "!gh pr list --web";
rbc = "rebase --continue";
rdup = "!git dup && git rebase develop";
remotes = "remote -v";
repush = "!git pull --rebase && git push";
ri = "rebase --interactive";
rid = "!git rebase -i $(git merge-base develop HEAD)";
rim = "!git rebase -i $(git master-to-main-wrapper merge-base %BRANCH% HEAD)";
rip = "!git rebase -i $(git merge-base production HEAD)";
ris = "!git rebase -i $(git merge-base staging HEAD)";
riu = "!git rebase -i $(git rev-parse --abbrev-ref --symbolic-full-name @{u})";
rmup = "!git mup && git master-to-main-wrapper rebase %BRANCH%";
sl = "log --oneline --decorate -20";
sla = "log --oneline --decorate --graph --all -20";
slap = "log --oneline --decorate --graph --all";
slp = "log --oneline --decorate";
stash = "stash --included-untracked";
unassume = "update-index --no-assume-unchanged";
uncommit = "reset --soft HEAD^";
unstage = "reset";
update = "!git fetch --all --jobs=4 --prune --progress && git rebase --autostash --stat";
upstream = "rev-parse --abbrev-ref --symbolic-full-name @{u}";
ureset = "!git reset --hard $(git upstream)";
worktrees = "worktree list";
};
ignores = [
"/.ddev/providers/"
"/.direnv/"
"/.ignored/"
"/.issue-id"
"/.phpactor.json"
"/notes"
"/todo"
];
extraConfig = {
branch = {
autosetupmerge = true;
autosetuprebase = "always";
sort = "-committerdate";
};
checkout.defaultRemote = "origin";
color.ui = true;
column.ui = "auto";
commit.template = "~/.gitmessage";
core = {
editor = "nvim";
excludesFile = "~/.config/git/ignore";
pager = "delta";
};
delta.line-numbers = true;
diff.tool = "vimdiff";
fetch.prune = true;
gpg.format = "ssh";
grep.lineNumber = true;
help.autocorrect = "1";
init.defaultBranch = "main";
maintenance = {
auto = false;
strategy = "incremental";
};
merge.ff = "only";
push = {
autoSetupRemote = true;
default = "upstream";
};
pull = {
ff = "only";
rebase = true;
};
rebase = {
autosquash = true;
autostash = true;
};
user.signingkey = "~/.ssh/id_rsa.pub";
};
};
};
home.packages = with pkgs.unstable; [ git-instafix ];
home.sessionVariables = {
GIT_INSTAFIX_UPSTREAM = "origin/main";
};
}

View file

@ -1,10 +0,0 @@
{
programs.lsd = {
enable = true;
enableAliases = false;
settings = {
icons.when = "never";
};
};
}

View file

@ -1,205 +0,0 @@
{ inputs, pkgs, ... }:
{
programs.neovim = {
enable = true;
package = pkgs.unstable.neovim-unwrapped;
plugins = with pkgs.vimPlugins; [
comment-nvim
dial-nvim
fidget-nvim
gitsigns-nvim
harpoon
impatient-nvim
mini-nvim
neodev-nvim
nvim-spectre
nvim-web-devicons
oil-nvim
refactoring-nvim
sort-nvim
treesj
undotree
vim-abolish
vim-eunuch
vim-highlightedyank
vim-just
vim-nix
vim-obsession
vim-pasta
vim-repeat
vim-sleuth
vim-sort-motion
vim-terraform
vim-textobj-user
vim-unimpaired
conf-vim
edit-alternate-vim
nvim-tmux-navigation
standard-vim
tabline-vim
vim-autoread
vim-textobj-indent
vim-textobj-xmlattr
vim-zoom
# Testing
vim-test
# Git
committia-vim
diffview-nvim
vim-fugitive
# Debugging
nvim-dap
nvim-dap-ui
nvim-dap-virtual-text
# Treesitter
(pkgs.vimPlugins.nvim-treesitter.withPlugins (
plugins: with plugins; [
bash
comment
css
csv
dockerfile
gitattributes
gitignore
go
html
javascript
json
kdl
lua
luadoc
make
markdown
markdown_inline
nix
php
phpdoc
query
rst
scss
sql
terraform
twig
typescript
vim
vimdoc
vue
xml
yaml
]
))
nvim-treesitter-context
nvim-treesitter-textobjects
# LSP, linting and formatting
conform-nvim
lsp-status-nvim
nvim-lint
nvim-lspconfig
# Completion
cmp-buffer
cmp-calc
cmp-cmdline
cmp-nvim-lsp
cmp-path
cmp-treesitter
cmp_luasnip
lspkind-nvim
nvim-cmp
# Snippets
friendly-snippets
luasnip
# Telescope
plenary-nvim
popup-nvim
telescope-frecency-nvim
telescope-fzf-native-nvim
telescope-live-grep-args-nvim
telescope-nvim
telescope-ui-select-nvim
# Databases
vim-dadbod
vim-dadbod-ui
vim-dadbod-completion
# Themes
catppuccin-nvim
# Configuration.
inputs.self.packages.${pkgs.system}.opdavies-nvim
];
extraLuaConfig = ''
if vim.loader then
vim.loader.enable()
end
require "opdavies"
'';
extraPackages = with pkgs; [
# Languages
nodePackages.typescript
nodejs-slim
php81
# Language servers
gopls
lua-language-server
lua54Packages.luacheck
marksman
nixd
nodePackages."@tailwindcss/language-server"
nodePackages.bash-language-server
nodePackages.dockerfile-language-server-nodejs
nodePackages.intelephense
nodePackages.typescript-language-server
nodePackages.vls
nodePackages.vscode-langservers-extracted
nodePackages.vue-language-server
nodePackages.yaml-language-server
phpactor
terraform-ls
# Formatters
black
eslint_d
nixfmt-rfc-style
nodePackages.prettier
stylua
yamlfmt
# Tools
hadolint
html-tidy
nodePackages.jsonlint
nodePackages.markdownlint-cli
php82Packages.php-codesniffer
php82Packages.phpstan
proselint
shellcheck
yamllint
];
};
home.file.".markdownlint.yaml".text = ''
default: true
line-length: false
no-duplicate-heading:
siblings_only: true
'';
}

View file

@ -1,24 +0,0 @@
{
programs.pet = {
enable = true;
snippets = [
{
command = "nix flake lock --update-input <input-name>";
description = "Display a log of a Git repository, showing each commit on its own line.";
output = "";
tag = [ "git" ];
}
{
command = "nix flake lock --update-input opdavies-nvim";
description = "Update a single input within a Nix flake.";
output = "";
tag = [
"nix"
"nix-flake"
];
}
];
};
}

View file

@ -1,7 +0,0 @@
{ self, ... }:
{
xdg.configFile.phpactor = {
source = "${self}/config/phpactor";
recursive = true;
};
}

View file

@ -1,9 +0,0 @@
{ pkgs, ... }:
{
home.packages = with pkgs; [ ripgrep ];
xdg.configFile."ripgrep/config".text = ''
--follow
--smart-case
'';
}

View file

@ -1 +0,0 @@
{ services.syncthing.enable = true; }

View file

@ -1,82 +0,0 @@
{ pkgs, ... }:
let
inherit (pkgs) tmuxPlugins;
in
{
programs.tmux = {
enable = true;
terminal = "tmux-256color";
extraConfig = ''
set-option -g status-keys "vi"
set-option -sa terminal-features "''${TERM}:RGB"
bind -n S-Left resize-pane -L 2
bind -n S-Right resize-pane -R 2
bind -n S-Down resize-pane -D 1
bind -n S-Up resize-pane -U 1
bind -n C-Left resize-pane -L 10
bind -n C-Right resize-pane -R 10
bind -n C-Down resize-pane -D 5
bind -n C-Up resize-pane -U 5
# Status line customisation
set-option -g status-left ""
set-option -g status-right " #{session_name}"
set-option -g status-right-length 100
set-option -g status-style "fg=#7C7D83 bg=default"
set-option -g window-status-activity-style none
set-option -g window-status-current-format "#{window_index}:#{pane_current_command}#{window_flags} "
set-option -g window-status-current-style "fg=#E9E9EA"
set-option -g window-status-format "#{window_index}:#{pane_current_command}#{window_flags} "
bind c new-window -c "#{pane_current_path}"
set -g base-index 1
set -g pane-base-index 1
set -g renumber-windows on
# Break a pane into a new window.
bind-key b break-pane -d
bind-key J command-prompt -p "join pane from: " "join-pane -h -s '%%'"
bind-key C-j choose-tree
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Setup 'v' to begin selection as in Vim
bind-key -T copy-mode-vi 'v' send -X begin-selection
bind-key -T copy-mode-vi 'y' send -X copy-pipe wl-copy
bind C-j split-window -v "tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^$(tmux display-message -p '#S')\$\" | fzf --reverse | xargs tmux switch-client -t"
bind-key K run-shell 'tmux switch-client -n \; kill-session -t "$(tmux display-message -p "#S")" || tmux kill-session'
# Allow clearing screen with ctrl-l by using <prefix> C-l
bind C-l send-keys "C-l"
bind C-k send-keys "C-k"
# Enable mouse support.
setw -g mouse on
# Remove delay when switching Vim modes.
set -sg escape-time 0
set-option -g pane-active-border-style "fg=#1f2335"
set-option -g pane-border-style "fg=#1f2335"
bind-key -r f run-shell "tmux new-window t"
set -g @resurrect-strategy-nvim 'session'
'';
plugins = [
tmuxPlugins.resurrect
tmuxPlugins.vim-tmux-navigator
tmuxPlugins.yank
];
};
}

View file

@ -1,11 +0,0 @@
{ self, ... }:
{
programs.zellij = {
enable = true;
};
xdg.configFile."zellij" = {
source = "${self}/config/zellij";
recursive = true;
};
}

View file

@ -1,132 +0,0 @@
{ pkgs, ... }:
{
programs.zsh = {
dotDir = ".config/zsh";
enable = true;
enableCompletion = true;
cdpath = [ "~/Code" ];
shellAliases = (import ./zsh/aliases.nix);
localVariables = {
ABBR_SET_EXPANSION_CURSOR = 1;
};
initExtra = ''
# suffix
alias -s gz="tar -tf"
alias -s {html,HTML}="background firefox"
alias -s {jpg,JPG,png,PNG}="background okular"
alias -s {pdf,PDF}="background okular"
alias -s {zip,ZIP}="unzip -l"
background() {
for ((i=2;i<=$#;i++)); do
''${@[1]} ''${@[$i]} &> /dev/null &
done
}
git() {
if [[ "''${1}" == "root" ]]; then
shift
local ROOT="$(${pkgs.git}/bin/git rev-parse --show-toplevel 2> /dev/null || echo -n .)"
if [[ $# == 0 ]]; then
cd "''${ROOT}"
else
(cd "''${ROOT}" && eval "''${@}")
fi
else
${pkgs.git}/bin/git "''${@}"
fi
}
ttyper() {
command ${pkgs.ttyper}/bin/ttyper --language english1000 --words 50 "''${@}"
}
yt-dlp() {
command yt-dlp --paths ~/Videos "$@"
}
# Case insensitive autocompletion.
zstyle ":completion:*" matcher-list "" "m:{a-zA-Z}={A-Za-z}" "r:|=*" "l:|=* r:|=*"
autoload -Uz compinit && compinit
bindkey -s ^f "t\n"
bindkey -s ^v "nvim\n"
clear-ls-all() {
clear
ls -al
zle reset-prompt
}
zle -N clear-ls-all
clear-git-status() {
clear
git status
zle reset-prompt
}
zle -N clear-git-status
clear-tree-2() {
clear
tree -L 2
zle reset-prompt
}
zle -N clear-tree-2
clear-tree-3() {
clear
tree -L 3
zle reset-prompt
}
zle -N clear-tree-3
bindkey '^G' clear-git-status
# bindkey '^H' clear-tree-3
# bindkey '^J' clear-tree-2
# bindkey '^K' clear-ls-all
setopt auto_cd
setopt auto_pushd
setopt pushd_ignore_dups
setopt pushdminus
'';
zplug = {
enable = true;
plugins = [
{
name = "themes/robbyrussell";
tags = [
"from:oh-my-zsh"
"as:theme"
];
}
{
name = "plugin/git";
tags = [ "from:oh-my-zsh" ];
}
{
name = "plugin/vi-mode";
tags = [ "from:oh-my-zsh" ];
}
{ name = "olets/zsh-abbr"; }
{ name = "zsh-users/zsh-completions"; }
{ name = "zsh-users/zsh-syntax-highlighting"; }
];
};
};
home.file.".config/zsh-abbr/user-abbreviations".text = builtins.readFile ./zsh/abbreviations.zsh;
}

View file

@ -1,139 +0,0 @@
abbr c="clear"
abbr cs="create-script"
abbr daily="run create-daily next"
abbr rst="rst2pdf"
abbr sz="source ~/.config/zsh/.zshrc"
abbr ti="timer"
abbr uagr="update-all-git-repos"
abbr v="nvim"
abbr yt="yt-dlp"
abbr evl="export-video-list"
abbr vv="cat ~/Documents/videos.json"
abbr g="git"
abbr ga="git add"
abbr gan="git add -N"
abbr gap="git add -p"
abbr gb="git branch"
abbr gbl="git blame"
abbr gc="git commit"
abbr gca="git commit --amend"
abbr gcan="git commit --amend --no-edit"
abbr gcl="git clone"
abbr gcm="git commit -m"
abbr gco="git checkout"
abbr gd="git diff"
abbr gds="git diff --staged"
abbr gf="git fetch"
abbr gfa="git fetch --all"
abbr gl="git log"
abbr glo="git log --oneline"
abbr gls="git log --stat"
abbr gpl="git pull"
abbr gplr="git pull --rebase"
abbr gps="git push"
abbr gpsa="git push acquia"
abbr gpsam="git push acquia main"
abbr gpsap="git push acquia HEAD:production"
abbr gpso="git push origin"
abbr gpsom="git push origin main"
abbr gr="git rebase"
abbr gri="git rebase -i"
abbr gs="git status"
abbr gsh="git show"
abbr gst="git stash"
abbr gstp="git stash pop"
# tmux
abbr ta="tmux attach"
abbr tl="tmux list-sessions"
abbr tk="tmux kill-session"
# zellij
abbr czs="create-zellij-session"
abbr z="zellij"
abbr za="zellij attach"
abbr zd="zellij delete-session"
abbr zda="zellij delete-all-sessions"
abbr ze="zellij edit"
abbr zei="zellij edit --in-place"
abbr zk="zellij kill-session"
abbr zka="zellij kill-all-sessions | sort"
abbr zl="zellij list-sessions | grep -v EXITED"
abbr zla="zellij list-sessions"
abbr znt="zellij action new-tab"
abbr zr="zellij run --"
abbr zri="zellij run --in-place --"
abbr zrf="zellij run --floating --"
abbr multitask="zellij action start-or-reload-plugin file:$HOME/zellij-plugins/multitask.wasm --configuration "shell=$SHELL,cwd=`pwd`""
# Docker and Docker Compose.
abbr dk="docker"
abbr dkp="docker ps"
abbr dkpa="docker ps -a"
abbr dkpaq="docker ps -a -q"
abbr dkb="docker build -t"
abbr dks="docker start"
abbr dkt="docker stop"
abbr dkrm="docker rm"
abbr dkri="docker rmi"
abbr dke="docker exec -ti"
abbr dkl="docker logs -f"
abbr dki="docker images"
abbr dkpu="docker pull"
abbr dkph="docker push"
abbr dkbnc="docker build --no-cache -t"
abbr dkr="docker run --rm"
abbr dkrti="docker run --rm -ti"
abbr dkc="docker compose"
abbr dkcb="docker compose build"
abbr dkcu="docker compose up"
abbr dkclean="docker ps -q -a -f status=exited | xargs -r docker rm && docker images -q -f dangling=true | xargs -r docker rmi"
# Nix and direnv.
abbr dea="direnv allow"
abbr dee="direnv edit"
abbr nxf="nix flake"
abbr nxfc="nix flake check"
abbr nxfs="nix flake show"
abbr nxfu="nix flake update"
abbr nxr="nix run nixpkgs#%"
abbr nxs="nix shell nixpkgs#%"
# run scripts.
abbr r="run"
abbr rc="run composer"
abbr rcda="run composer dump-autoload"
abbr rci="run composer install"
abbr rcr="run composer require"
abbr rcu="run composer update"
abbr rd="run drush"
abbr rdce="run drush config:export -y"
abbr rdci="run drush config:import -y"
abbr rdcr="run drush cache:rebuild"
abbr rdscr="run drush php:script"
abbr rduli="run drush uli"
abbr rdup="run drush updatedb -y"
abbr rpub="run publish"
abbr rt="run test"
abbr -g A1="| awk '{print $1}'"
abbr -g C="| xclip -sel clip"
abbr -g Fj="| jq ."
abbr -g Fy="| yq ."
abbr -g G="| grep"
abbr -g GH="| grep HTTP"
abbr -g Gi="| grep -i"
abbr -g H2="| head -n 20"
abbr -g H="| head"
abbr -g L="| less"
abbr -g V="| nvim -"
abbr -g X="| xargs -I1"
abbr today="task +TODAY"
abbr tomorrow="task +TOMORROW"
abbr overdue="task +OVERDUE"
abbr nah="git reset --hard; git clean -fd"
abbr wip="git commit -m wip"

View file

@ -1,14 +0,0 @@
{
"$" = "";
"-" = "cd -";
".." = "cd ..";
"..." = "cd ../..";
"...." = "cd ../../..";
"....." = "cd ../../../..";
cat = "bat";
s = "secrets";
secrets = ''doppler --project "$(whoami)" run'';
tag = "tag-release";
vss = "LC_ALL=C sort --unique $REPOS/dotfiles.nix/config/neovim/spell/en.utf-8.add --output $REPOS/dotfiles.nix/config/neovim/spell/en.utf-8.add";
wt = "git worktree";
}