From 875c360794d1018ed81d16562c6ec44c35c8f9fc Mon Sep 17 00:00:00 2001 From: Johannes Rothe Date: Thu, 3 Oct 2024 19:30:10 +0200 Subject: [PATCH] Make mail configurable Inspired by: https://librephoenix.com/2024-01-28-program-a-modular-control-center-for-your-config-using-special-args-in-nixos-flakes.html --- flake.nix | 9 + home/terminal/default.nix | 387 +++++++++++++++++++------------------- 2 files changed, 203 insertions(+), 193 deletions(-) diff --git a/flake.nix b/flake.nix index f93d81e..40d31da 100644 --- a/flake.nix +++ b/flake.nix @@ -29,18 +29,27 @@ ./home/rothe.nix ./home/wayland ]; + extraSpecialArgs = { + mail = "mail@johannes-rothe.de"; + }; }; "rothe@johannes-powermachine" = home-manager.lib.homeManagerConfiguration { inherit pkgs; modules = [ ./home/rothe.nix ]; + extraSpecialArgs = { + mail = "mail@johannes-rothe.de"; + }; }; "rothe@pdemu1cml000301" = home-manager.lib.homeManagerConfiguration { inherit pkgs; modules = [ ./home/rothe.nix ]; + extraSpecialArgs = { + mail = "rothe@magazino.eu"; + }; }; }; }; diff --git a/home/terminal/default.nix b/home/terminal/default.nix index ceda8b6..cf8508c 100644 --- a/home/terminal/default.nix +++ b/home/terminal/default.nix @@ -1,223 +1,224 @@ -{ config, pkgs, lib, ... }: +{ config, pkgs, lib, mail, ... }: { - home.packages = with pkgs; [ - black - go - gopls - gotools - htop - jq - pylint - python311 - python311Packages.flake8 - python311Packages.ipython - rusti-cal - roboto-mono - silver-searcher - shellcheck - (nerdfonts.override { fonts = [ "RobotoMono" ]; }) - ]; - fonts.fontconfig.enable = true; + config = { + home.packages = with pkgs; [ + black + go + gopls + gotools + htop + jq + pylint + python311 + python311Packages.flake8 + python311Packages.ipython + rusti-cal + roboto-mono + silver-searcher + shellcheck + (nerdfonts.override { fonts = [ "RobotoMono" ]; }) + ]; + fonts.fontconfig.enable = true; - programs.fish = { - enable = true; - # start sway on login - loginShellInit = '' - if test -z "$DISPLAY" -a $XDG_VTNR = 1 - exec sway - end - ''; - # TODO make mails configurable - # disable greeting - shellInit = '' - set fish_greeting - fish_add_path ~/bin/ - fish_add_path ~/go/bin/ - export DEBFULLNAME="Johannes Rothe" - export DEBEMAIL="mail@johannes-rothe.de" - export GIT_AUTHOR_NAME="Johannes Rothe" - export GIT_AUTHOR_EMAIL="rothe@magazino.eu" - export GIT_COMMITTER_NAME="Johannes Rothe" - export GIT_COMMITTER_EMAIL="rothe@magazino.eu" - export VAULT_ADDR="https://passwords.magazino.eu:8201" - ''; - shellAliases = { - "..." = "cd ../.."; - "cds" = "cd ~/src/"; - "ll" = "ls -lh"; - "cal" = "rusti-cal --color -w"; - "ip" = "ip -c"; - }; - }; - - programs.git = { - enable = true; - userEmail = "mail@johannes-rothe.de"; - userName = "Johannes Rothe"; - aliases = { - a = "add"; - ci = "commit"; - ca = "commit --amend --no-edit"; - st = "status"; - co = "checkout"; - br = "branch"; - }; - lfs = { + programs.fish = { enable = true; - }; - difftastic = { - enable = true; - background = "dark"; - }; - extraConfig = { - core = { - editor = "vim"; + # start sway on login + loginShellInit = '' + if test -z "$DISPLAY" -a $XDG_VTNR = 1 + exec sway + end + ''; + # disable greeting + shellInit = '' + set fish_greeting + fish_add_path ~/bin/ + fish_add_path ~/go/bin/ + export DEBFULLNAME="Johannes Rothe" + export DEBEMAIL="${mail}" + export GIT_AUTHOR_NAME="Johannes Rothe" + export GIT_AUTHOR_EMAIL="${mail}" + export GIT_COMMITTER_NAME="Johannes Rothe" + export GIT_COMMITTER_EMAIL="${mail}" + export VAULT_ADDR="https://passwords.magazino.eu:8201" + ''; + shellAliases = { + "..." = "cd ../.."; + "cds" = "cd ~/src/"; + "ll" = "ls -lh"; + "cal" = "rusti-cal --color -w"; + "ip" = "ip -c"; }; }; - }; - programs.tmux = { - enable = true; - prefix = "C-a"; - historyLimit = 150000; - keyMode = "vi"; - customPaneNavigationAndResize = true; - extraConfig = '' - bind-key Space next-window + programs.git = { + enable = true; + userEmail = "${mail}"; + userName = "Johannes Rothe"; + aliases = { + a = "add"; + ci = "commit"; + ca = "commit --amend --no-edit"; + st = "status"; + co = "checkout"; + br = "branch"; + }; + lfs = { + enable = true; + }; + difftastic = { + enable = true; + background = "dark"; + }; + extraConfig = { + core = { + editor = "vim"; + }; + }; + }; - set -g status-right '#[fg=colour242]#S' - set -g status-left ' ' - set -g window-status-format '#I:#W' - set -g window-status-current-format '#I:#W' - set -g allow-rename off + programs.tmux = { + enable = true; + prefix = "C-a"; + historyLimit = 150000; + keyMode = "vi"; + customPaneNavigationAndResize = true; + extraConfig = '' + bind-key Space next-window - # default statusbar colors - set-option -g status-style bg=colour232,fg=colour239,default + set -g status-right '#[fg=colour242]#S' + set -g status-left ' ' + set -g window-status-format '#I:#W' + set -g window-status-current-format '#I:#W' + set -g allow-rename off - # border - set -g pane-border-style fg=colour234,bg=default - set -g pane-active-border-style fg=colour236,bg=default + # default statusbar colors + set-option -g status-style bg=colour232,fg=colour239,default - # active window title colors - set-window-option -g window-status-current-style fg=colour231,bg=default - set-window-option -g window-status-style fg=colour239,bg=default + # border + set -g pane-border-style fg=colour234,bg=default + set -g pane-active-border-style fg=colour236,bg=default - # bell - set-window-option -g window-status-bell-style fg=colour232,bg=colour253 + # active window title colors + set-window-option -g window-status-current-style fg=colour231,bg=default + set-window-option -g window-status-style fg=colour239,bg=default - # Correct colors - set -g default-terminal "tmux-256color" - set -ga terminal-overrides ",*256col*:Tc" - ''; - }; + # bell + set-window-option -g window-status-bell-style fg=colour232,bg=colour253 - programs.vim = { - enable = true; - defaultEditor = true; - # List of supported plugins: nix-env -f '' -qaP -A vimPlugins - # TODO Black plugin missing - plugins = [ - pkgs.vimPlugins.ale - pkgs.vimPlugins.gitgutter - pkgs.vimPlugins.indentLine - pkgs.vimPlugins.nerdtree - pkgs.vimPlugins.python-syntax - pkgs.vimPlugins.rainbow - pkgs.vimPlugins.sonokai - pkgs.vimPlugins.vim-airline - pkgs.vimPlugins.vim-devicons - pkgs.vimPlugins.vim-go - pkgs.vimPlugins.vim-hcl - pkgs.vimPlugins.vim-isort - pkgs.vimPlugins.vim-terraform - pkgs.vimPlugins.YouCompleteMe - ]; - extraConfig = '' - set number - set colorcolumn=88 - set background=dark - set cursorline - set encoding=utf-8 + # Correct colors + set -g default-terminal "tmux-256color" + set -ga terminal-overrides ",*256col*:Tc" + ''; + }; - " Theme - if has('termguicolors') - set termguicolors - endif - let g:sonokai_style = "atlantis" - let g:sonokai_disable_italic_comment = 1 - colorscheme sonokai - let g:airline_theme = "sonokai" + programs.vim = { + enable = true; + defaultEditor = true; + # List of supported plugins: nix-env -f '' -qaP -A vimPlugins + # TODO Black plugin missing + plugins = [ + pkgs.vimPlugins.ale + pkgs.vimPlugins.gitgutter + pkgs.vimPlugins.indentLine + pkgs.vimPlugins.nerdtree + pkgs.vimPlugins.python-syntax + pkgs.vimPlugins.rainbow + pkgs.vimPlugins.sonokai + pkgs.vimPlugins.vim-airline + pkgs.vimPlugins.vim-devicons + pkgs.vimPlugins.vim-go + pkgs.vimPlugins.vim-hcl + pkgs.vimPlugins.vim-isort + pkgs.vimPlugins.vim-terraform + pkgs.vimPlugins.YouCompleteMe + ]; + extraConfig = '' + set number + set colorcolumn=88 + set background=dark + set cursorline + set encoding=utf-8 - " Filetypes - au BufNewFile,BufRead *.launch set filetype=xml + " Theme + if has('termguicolors') + set termguicolors + endif + let g:sonokai_style = "atlantis" + let g:sonokai_disable_italic_comment = 1 + colorscheme sonokai + let g:airline_theme = "sonokai" - augroup indent - autocmd FileType python,go,dockerfile,js,toml :set tabstop=4 softtabstop=4 shiftwidth=4 expandtab autoindent fileformat=unix - autocmd FileType terraform,sh,json,yaml,html,css :set tabstop=2 softtabstop=2 shiftwidth=2 expandtab autoindent fileformat=unix - augroup end + " Filetypes + au BufNewFile,BufRead *.launch set filetype=xml - augroup spell - autocmd FileType gitcommit :set spell - autocmd FileType markdown :set spell - augroup end + augroup indent + autocmd FileType python,go,dockerfile,js,toml :set tabstop=4 softtabstop=4 shiftwidth=4 expandtab autoindent fileformat=unix + autocmd FileType terraform,sh,json,yaml,html,css :set tabstop=2 softtabstop=2 shiftwidth=2 expandtab autoindent fileformat=unix + augroup end - augroup shortcuts - autocmd FileType terraform nnoremap :! terraform fmt - autocmd FileType python nnoremap :Black :Isort - autocmd FileType go nnoremap (go-fmt)(go-lint) - autocmd FileType go nnoremap (go-build) - autocmd FileType go nnoremap (go-run) - autocmd FileType go nnoremap gd (go-def) - augroup end + augroup spell + autocmd FileType gitcommit :set spell + autocmd FileType markdown :set spell + augroup end - " Ale - let g:ale_linters = {'python': ['flake8', 'mypy'],'javascript': ['eslint']} - let g:ale_fixers = {'python': ['black', 'isort']} - let g:ale_python_pylint_options = '--disable=C0111,C0114' + augroup shortcuts + autocmd FileType terraform nnoremap :! terraform fmt + autocmd FileType python nnoremap :Black :Isort + autocmd FileType go nnoremap (go-fmt)(go-lint) + autocmd FileType go nnoremap (go-build) + autocmd FileType go nnoremap (go-run) + autocmd FileType go nnoremap gd (go-def) + augroup end - " YouCompleteMe - let g:ycm_gopls_binary_path = "${pkgs.gopls}/bin/gopls" + " Ale + let g:ale_linters = {'python': ['flake8', 'mypy'],'javascript': ['eslint']} + let g:ale_fixers = {'python': ['black', 'isort']} + let g:ale_python_pylint_options = '--disable=C0111,C0114' - " Black - let g:black_linelength = 88 + " YouCompleteMe + let g:ycm_gopls_binary_path = "${pkgs.gopls}/bin/gopls" - " NERDTREE - " open nerdtree when no file is specified on startup - autocmd StdinReadPre * let s:std_in=1 - autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif - " toggle nerdtree keyboard shortcut - map :NERDTreeToggle + " Black + let g:black_linelength = 88 - " Devicons - let g:webdevicons_conceal_nerdtree_brackets = 1 - syntax enable - if exists("g:loaded_webdevicons") - call webdevicons#refresh() - endif + " NERDTREE + " open nerdtree when no file is specified on startup + autocmd StdinReadPre * let s:std_in=1 + autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif + " toggle nerdtree keyboard shortcut + map :NERDTreeToggle - " terraform - let g:terraform_fmt_on_save = 1 - let g:terraform_align = 1 - ''; - }; + " Devicons + let g:webdevicons_conceal_nerdtree_brackets = 1 + syntax enable + if exists("g:loaded_webdevicons") + call webdevicons#refresh() + endif - programs.ssh = { - enable = true; - extraConfig = '' - AddKeysToAgent yes - SendEnv GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME - ''; - }; + " terraform + let g:terraform_fmt_on_save = 1 + let g:terraform_align = 1 + ''; + }; - programs.newsboat = { - enable = true; - extraConfig = " - urls-source \"miniflux\"\n - miniflux-url \"https://feeds.johannes-rothe.de/\"\n - miniflux-login \"johannes\"\n - miniflux-passwordfile ~/.minifluxpw\n - "; + programs.ssh = { + enable = true; + extraConfig = '' + AddKeysToAgent yes + SendEnv GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME + ''; + }; + + programs.newsboat = { + enable = true; + extraConfig = " + urls-source \"miniflux\"\n + miniflux-url \"https://feeds.johannes-rothe.de/\"\n + miniflux-login \"johannes\"\n + miniflux-passwordfile ~/.minifluxpw\n + "; + }; }; }