From e13ed446a1a487185dfc237a87555d8541e66527 Mon Sep 17 00:00:00 2001 From: Michael Mandl Date: Sun, 26 Jun 2022 14:42:49 +0200 Subject: [PATCH] refactor: modularize home-manager config --- home-manager/fzf.nix | 10 + home-manager/git.nix | 39 +++ home-manager/gpg/default.nix | 25 ++ {gnupg => home-manager/gpg}/pubring.asc | 0 home-manager/i3.nix | 37 +++ home-manager/i3status-rust.nix | 41 +++ home-manager/kitty.nix | 14 + {nvim => home-manager/neovim}/comment.lua | 0 home-manager/neovim/default.nix | 93 ++++++ {nvim => home-manager/neovim}/gitsigns.lua | 0 .../neovim}/indent-blankline.lua | 0 {nvim => home-manager/neovim}/keymaps.lua | 0 {nvim => home-manager/neovim}/lspconfig.lua | 0 {nvim => home-manager/neovim}/lualine.lua | 0 {nvim => home-manager/neovim}/luasnip.lua | 0 {nvim => home-manager/neovim}/notify.lua | 0 {nvim => home-manager/neovim}/nvim-cmp.lua | 0 {nvim => home-manager/neovim}/options.lua | 0 {nvim => home-manager/neovim}/tabline.lua | 0 {nvim => home-manager/neovim}/telescope.lua | 0 {nvim => home-manager/neovim}/themes.lua | 0 {nvim => home-manager/neovim}/toggleterm.lua | 0 {nvim => home-manager/neovim}/treesitter.lua | 0 home-manager/starship.nix | 11 + home-manager/tmux.nix | 20 ++ home-manager/zsh.nix | 20 ++ home-mandlm.nix | 283 +----------------- nvim/.gitignore | 1 - 28 files changed, 323 insertions(+), 271 deletions(-) create mode 100644 home-manager/fzf.nix create mode 100644 home-manager/git.nix create mode 100644 home-manager/gpg/default.nix rename {gnupg => home-manager/gpg}/pubring.asc (100%) create mode 100644 home-manager/i3.nix create mode 100644 home-manager/i3status-rust.nix create mode 100644 home-manager/kitty.nix rename {nvim => home-manager/neovim}/comment.lua (100%) create mode 100644 home-manager/neovim/default.nix rename {nvim => home-manager/neovim}/gitsigns.lua (100%) rename {nvim => home-manager/neovim}/indent-blankline.lua (100%) rename {nvim => home-manager/neovim}/keymaps.lua (100%) rename {nvim => home-manager/neovim}/lspconfig.lua (100%) rename {nvim => home-manager/neovim}/lualine.lua (100%) rename {nvim => home-manager/neovim}/luasnip.lua (100%) rename {nvim => home-manager/neovim}/notify.lua (100%) rename {nvim => home-manager/neovim}/nvim-cmp.lua (100%) rename {nvim => home-manager/neovim}/options.lua (100%) rename {nvim => home-manager/neovim}/tabline.lua (100%) rename {nvim => home-manager/neovim}/telescope.lua (100%) rename {nvim => home-manager/neovim}/themes.lua (100%) rename {nvim => home-manager/neovim}/toggleterm.lua (100%) rename {nvim => home-manager/neovim}/treesitter.lua (100%) create mode 100644 home-manager/starship.nix create mode 100644 home-manager/tmux.nix create mode 100644 home-manager/zsh.nix delete mode 100644 nvim/.gitignore diff --git a/home-manager/fzf.nix b/home-manager/fzf.nix new file mode 100644 index 0000000..0e83315 --- /dev/null +++ b/home-manager/fzf.nix @@ -0,0 +1,10 @@ +{ config, lib, pkgs, user, ... }: + +{ + programs = { + fzf = { + enable = true; + enableZshIntegration = true; + }; + }; +} diff --git a/home-manager/git.nix b/home-manager/git.nix new file mode 100644 index 0000000..8a51dd0 --- /dev/null +++ b/home-manager/git.nix @@ -0,0 +1,39 @@ +{ config, lib, pkgs, user, ... }: + +{ + programs = { + git = { + enable = true; + extraConfig = { + user.private.name = "Michael Mandl"; + user.private.email = "mandlm@molez.net"; + user.private.signingkey = "4AA25D647AA54CC7"; + + user.swp.name = "Michael Mandl"; + user.swp.email = "mandl@vi-bim.de"; + user.swp.signingkey = "4E60F44227F611B4"; + + core.editor = "nvim"; + fetch.writeCommitGraph = true; + format.pretty = "format:%C(yellow)%h %Cblue%>(12)%ad %C(red)%G? %Cgreen%<(7,trunc)%aN%Cred%d %Creset%s"; + init.defaultBranch = "main"; + log.date = "relative"; + pull.rebase = true; + rebase.autostash = true; + rerere.enabled = true; + worktree.guessRemote = true; + }; + + aliases = { + identity = "! git config user.name \"$(git config user.$1.name)\"; git config user.email \"$(git config user.$1.email)\"; git config user.signingkey \"$(git config user.$1.signingkey)\"; git config commit.gpgsign \"true\"; :"; + }; + + ignores = [ + ".env" + ".direnv" + "*.swp" + ]; + }; + }; +} + diff --git a/home-manager/gpg/default.nix b/home-manager/gpg/default.nix new file mode 100644 index 0000000..e8c9d75 --- /dev/null +++ b/home-manager/gpg/default.nix @@ -0,0 +1,25 @@ +{ config, lib, pkgs, user, ... }: + +{ + services.gpg-agent = { + enable = true; + enableZshIntegration = true; + pinentryFlavor = "gtk2"; + extraConfig = '' + allow-loopback-pinentry + ''; + }; + + programs.gpg = { + enable = true; + mutableKeys = false; + mutableTrust = false; + publicKeys = [{ + source = ./pubring.asc; + trust = "ultimate"; + }]; + settings = { + pinentry-mode = "loopback"; + }; + }; +} diff --git a/gnupg/pubring.asc b/home-manager/gpg/pubring.asc similarity index 100% rename from gnupg/pubring.asc rename to home-manager/gpg/pubring.asc diff --git a/home-manager/i3.nix b/home-manager/i3.nix new file mode 100644 index 0000000..41be812 --- /dev/null +++ b/home-manager/i3.nix @@ -0,0 +1,37 @@ +{ config, lib, pkgs, user, ... }: + +{ + xsession.windowManager.i3 = { + enable = true; + config = { + modifier = "Mod4"; + terminal = "${pkgs.kitty}/bin/kitty"; + + fonts = { + names = [ "DejaVu Sans Mono" ]; + size = 12.0; + }; + + window = { + titlebar = false; + border = 0; + }; + + floating = { + titlebar = false; + border = 0; + }; + + bars = [{ + mode = "hide"; + position = "top"; + statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ~/.config/i3status-rust/config-default.toml"; + + fonts = { + names = [ "DejaVu Sans Mono" ]; + size = 12.0; + }; + }]; + }; + }; +} diff --git a/home-manager/i3status-rust.nix b/home-manager/i3status-rust.nix new file mode 100644 index 0000000..ae90afa --- /dev/null +++ b/home-manager/i3status-rust.nix @@ -0,0 +1,41 @@ +{ config, lib, pkgs, user, ... }: + +{ + programs.i3status-rust = { + enable = true; + bars = { + default = { + theme = "solarized-dark"; + icons = "awesome"; + + blocks = [ + { + block = "memory"; + display_type = "memory"; + format_mem = "{mem_used_percents}"; + } + { + block = "cpu"; + interval = 1; + format = "{barchart} {frequency}"; + } + { + block = "load"; + interval = 1; + format = "{1m}"; + } + { + block = "battery"; + hide_missing = true; + format = "{time} ({percentage})"; + } + { + block = "time"; + interval = 60; + format = "%a %d.%m %R"; + } + ]; + }; + }; + }; +} diff --git a/home-manager/kitty.nix b/home-manager/kitty.nix new file mode 100644 index 0000000..87721a3 --- /dev/null +++ b/home-manager/kitty.nix @@ -0,0 +1,14 @@ +{ config, lib, pkgs, user, ... }: + +{ + programs = { + kitty = { + enable = true; + theme = "Solarized Light"; + font = { + name = "DejaVu Sans Mono"; + size = 12; + }; + }; + }; +} diff --git a/nvim/comment.lua b/home-manager/neovim/comment.lua similarity index 100% rename from nvim/comment.lua rename to home-manager/neovim/comment.lua diff --git a/home-manager/neovim/default.nix b/home-manager/neovim/default.nix new file mode 100644 index 0000000..3b14a53 --- /dev/null +++ b/home-manager/neovim/default.nix @@ -0,0 +1,93 @@ +{ config, lib, pkgs, user, ... }: + +{ + home.packages = with pkgs; [ + # LSP + sumneko-lua-language-server + rnix-lsp + terraform-ls + tflint + nodePackages.bash-language-server + rust-analyzer + ]; + + programs = { + neovim = { + enable = true; + plugins = with pkgs.vimPlugins; [ + # theme + nvim-solarized-lua + + delimitMate + vim-bbye + ansible-vim + + # session handling + vim-obsession + vim-prosession + + nvim-web-devicons + nvim-treesitter + markdown-preview-nvim # use({ "iamcco/markdown-preview.nvim", run = ":call mkdp#util#install()" }) + toggleterm-nvim + nvim-notify + comment-nvim + lualine-nvim + tabline-nvim + indent-blankline-nvim + plenary-nvim + + # git + gitsigns-nvim + vim-fugitive + gv-vim + + # snippets + friendly-snippets + luasnip + + # auto-completion + nvim-cmp + cmp-nvim-lsp + cmp-buffer + cmp-path + cmp-cmdline + cmp-nvim-lua + cmp_luasnip + cmp-calc + + # telescope + telescope-nvim + telescope-fzf-native-nvim + telescope-ui-select-nvim + + # LSP + nvim-lspconfig + lsp-status-nvim + rust-tools-nvim + lua-dev-nvim + ]; + + extraConfig = '' + lua << EOF + ${builtins.readFile ./keymaps.lua } + ${builtins.readFile ./options.lua } + ${builtins.readFile ./treesitter.lua } + ${builtins.readFile ./lspconfig.lua } + ${builtins.readFile ./toggleterm.lua } + ${builtins.readFile ./notify.lua } + ${builtins.readFile ./comment.lua } + ${builtins.readFile ./lualine.lua } + ${builtins.readFile ./tabline.lua } + ${builtins.readFile ./indent-blankline.lua } + ${builtins.readFile ./gitsigns.lua } + ${builtins.readFile ./luasnip.lua } + ${builtins.readFile ./nvim-cmp.lua } + ${builtins.readFile ./telescope.lua } + ${builtins.readFile ./themes.lua } + EOF + ''; + }; + }; +} + diff --git a/nvim/gitsigns.lua b/home-manager/neovim/gitsigns.lua similarity index 100% rename from nvim/gitsigns.lua rename to home-manager/neovim/gitsigns.lua diff --git a/nvim/indent-blankline.lua b/home-manager/neovim/indent-blankline.lua similarity index 100% rename from nvim/indent-blankline.lua rename to home-manager/neovim/indent-blankline.lua diff --git a/nvim/keymaps.lua b/home-manager/neovim/keymaps.lua similarity index 100% rename from nvim/keymaps.lua rename to home-manager/neovim/keymaps.lua diff --git a/nvim/lspconfig.lua b/home-manager/neovim/lspconfig.lua similarity index 100% rename from nvim/lspconfig.lua rename to home-manager/neovim/lspconfig.lua diff --git a/nvim/lualine.lua b/home-manager/neovim/lualine.lua similarity index 100% rename from nvim/lualine.lua rename to home-manager/neovim/lualine.lua diff --git a/nvim/luasnip.lua b/home-manager/neovim/luasnip.lua similarity index 100% rename from nvim/luasnip.lua rename to home-manager/neovim/luasnip.lua diff --git a/nvim/notify.lua b/home-manager/neovim/notify.lua similarity index 100% rename from nvim/notify.lua rename to home-manager/neovim/notify.lua diff --git a/nvim/nvim-cmp.lua b/home-manager/neovim/nvim-cmp.lua similarity index 100% rename from nvim/nvim-cmp.lua rename to home-manager/neovim/nvim-cmp.lua diff --git a/nvim/options.lua b/home-manager/neovim/options.lua similarity index 100% rename from nvim/options.lua rename to home-manager/neovim/options.lua diff --git a/nvim/tabline.lua b/home-manager/neovim/tabline.lua similarity index 100% rename from nvim/tabline.lua rename to home-manager/neovim/tabline.lua diff --git a/nvim/telescope.lua b/home-manager/neovim/telescope.lua similarity index 100% rename from nvim/telescope.lua rename to home-manager/neovim/telescope.lua diff --git a/nvim/themes.lua b/home-manager/neovim/themes.lua similarity index 100% rename from nvim/themes.lua rename to home-manager/neovim/themes.lua diff --git a/nvim/toggleterm.lua b/home-manager/neovim/toggleterm.lua similarity index 100% rename from nvim/toggleterm.lua rename to home-manager/neovim/toggleterm.lua diff --git a/nvim/treesitter.lua b/home-manager/neovim/treesitter.lua similarity index 100% rename from nvim/treesitter.lua rename to home-manager/neovim/treesitter.lua diff --git a/home-manager/starship.nix b/home-manager/starship.nix new file mode 100644 index 0000000..80923d4 --- /dev/null +++ b/home-manager/starship.nix @@ -0,0 +1,11 @@ +{ config, lib, pkgs, user, ... }: + +{ + programs.starship = { + enable = true; + settings = { + format = lib.concatStrings [ "$all" "$directory" "$character" ]; + hostname.format = "[$ssh_symbol$hostname]($style) "; + }; + }; +} diff --git a/home-manager/tmux.nix b/home-manager/tmux.nix new file mode 100644 index 0000000..50fd280 --- /dev/null +++ b/home-manager/tmux.nix @@ -0,0 +1,20 @@ +{ config, lib, pkgs, user, ... }: + +{ + programs.tmux = { + enable = true; + newSession = true; + keyMode = "vi"; + escapeTime = 10; + terminal = "tmux-256color"; + + extraConfig = '' + set-option -g status off + ''; + + plugins = with pkgs.tmuxPlugins; [ + vim-tmux-navigator + tmux-colors-solarized + ]; + }; +} diff --git a/home-manager/zsh.nix b/home-manager/zsh.nix new file mode 100644 index 0000000..0aba561 --- /dev/null +++ b/home-manager/zsh.nix @@ -0,0 +1,20 @@ +{ config, lib, pkgs, user, ... }: + +{ + programs.zsh = { + enable = true; + enableSyntaxHighlighting = true; + history.size = 10000; + + oh-my-zsh = { + enable = true; + plugins = [ "direnv" "tmux" "vi-mode" ]; + }; + + localVariables = { + ZSH_TMUX_AUTOSTART = true; + ZSH_TMUX_AUTOCONNECT = true; + ZSH_TMUX_UNICODE = true; + }; + }; +} diff --git a/home-mandlm.nix b/home-mandlm.nix index 6a14eb0..a7f34b1 100644 --- a/home-mandlm.nix +++ b/home-mandlm.nix @@ -25,280 +25,23 @@ direnv tree light - - # LSP - sumneko-lua-language-server - rnix-lsp - terraform-ls - tflint - nodePackages.bash-language-server - rust-analyzer ]; stateVersion = "22.05"; }; - services.gpg-agent = { - enable = true; - enableZshIntegration = true; - pinentryFlavor = "gtk2"; - extraConfig = '' - allow-loopback-pinentry - ''; - }; + programs.home-manager.enable = true; - programs = { - fzf = { - enable = true; - enableZshIntegration = true; - }; - - git = { - enable = true; - extraConfig = { - user.private.name = "Michael Mandl"; - user.private.email = "mandlm@molez.net"; - user.private.signingkey = "4AA25D647AA54CC7"; - - user.swp.name = "Michael Mandl"; - user.swp.email = "mandl@vi-bim.de"; - user.swp.signingkey = "4E60F44227F611B4"; - - core.editor = "nvim"; - fetch.writeCommitGraph = true; - format.pretty = "format:%C(yellow)%h %Cblue%>(12)%ad %C(red)%G? %Cgreen%<(7,trunc)%aN%Cred%d %Creset%s"; - init.defaultBranch = "main"; - log.date = "relative"; - pull.rebase = true; - rebase.autostash = true; - rerere.enabled = true; - worktree.guessRemote = true; - }; - - aliases = { - identity = "! git config user.name \"$(git config user.$1.name)\"; git config user.email \"$(git config user.$1.email)\"; git config user.signingkey \"$(git config user.$1.signingkey)\"; git config commit.gpgsign \"true\"; :"; - }; - - ignores = [ - ".env" - ".direnv" - "*.swp" - ]; - }; - - kitty = { - enable = true; - theme = "Solarized Light"; - font = { - name = "DejaVu Sans Mono"; - size = 12; - }; - }; - - neovim = { - enable = true; - plugins = with pkgs.vimPlugins; [ - # theme - nvim-solarized-lua - - delimitMate - vim-bbye - ansible-vim - - # session handling - vim-obsession - vim-prosession - - nvim-web-devicons - nvim-treesitter - markdown-preview-nvim # use({ "iamcco/markdown-preview.nvim", run = ":call mkdp#util#install()" }) - toggleterm-nvim - nvim-notify - comment-nvim - lualine-nvim - tabline-nvim - indent-blankline-nvim - plenary-nvim - - # git - gitsigns-nvim - vim-fugitive - gv-vim - - # snippets - friendly-snippets - luasnip - - # auto-completion - nvim-cmp - cmp-nvim-lsp - cmp-buffer - cmp-path - cmp-cmdline - cmp-nvim-lua - cmp_luasnip - cmp-calc - - # telescope - telescope-nvim - telescope-fzf-native-nvim - telescope-ui-select-nvim - - # LSP - nvim-lspconfig - lsp-status-nvim - rust-tools-nvim - lua-dev-nvim - ]; - - extraConfig = '' - lua << EOF - ${builtins.readFile ./nvim/keymaps.lua } - ${builtins.readFile ./nvim/options.lua } - ${builtins.readFile ./nvim/treesitter.lua } - ${builtins.readFile ./nvim/lspconfig.lua } - ${builtins.readFile ./nvim/toggleterm.lua } - ${builtins.readFile ./nvim/notify.lua } - ${builtins.readFile ./nvim/comment.lua } - ${builtins.readFile ./nvim/lualine.lua } - ${builtins.readFile ./nvim/tabline.lua } - ${builtins.readFile ./nvim/indent-blankline.lua } - ${builtins.readFile ./nvim/gitsigns.lua } - ${builtins.readFile ./nvim/luasnip.lua } - ${builtins.readFile ./nvim/nvim-cmp.lua } - ${builtins.readFile ./nvim/telescope.lua } - ${builtins.readFile ./nvim/themes.lua } - EOF - ''; - }; - - tmux = { - enable = true; - newSession = true; - keyMode = "vi"; - escapeTime = 10; - terminal = "tmux-256color"; - - extraConfig = '' - set-option -g status off - ''; - - plugins = with pkgs.tmuxPlugins; [ - vim-tmux-navigator - tmux-colors-solarized - ]; - }; - - gpg = { - enable = true; - mutableKeys = false; - mutableTrust = false; - publicKeys = [{ - source = ./gnupg/pubring.asc; - trust = "ultimate"; - }]; - settings = { - pinentry-mode = "loopback"; - }; - }; - - zsh = { - enable = true; - enableSyntaxHighlighting = true; - history.size = 10000; - - oh-my-zsh = { - enable = true; - plugins = [ "direnv" "tmux" "vi-mode" ]; - }; - - localVariables = { - ZSH_TMUX_AUTOSTART = true; - ZSH_TMUX_AUTOCONNECT = true; - ZSH_TMUX_UNICODE = true; - }; - }; - - starship = { - enable = true; - settings = { - format = lib.concatStrings [ "$all" "$directory" "$character" ]; - hostname.format = "[$ssh_symbol$hostname]($style) "; - }; - }; - - i3status-rust = { - enable = true; - bars = { - default = { - theme = "solarized-dark"; - icons = "awesome"; - - blocks = [ - { - block = "memory"; - display_type = "memory"; - format_mem = "{mem_used_percents}"; - } - { - block = "cpu"; - interval = 1; - format = "{barchart} {frequency}"; - } - { - block = "load"; - interval = 1; - format = "{1m}"; - } - { - block = "battery"; - hide_missing = true; - format = "{time} ({percentage})"; - } - { - block = "time"; - interval = 60; - format = "%a %d.%m %R"; - } - ]; - }; - }; - }; - - home-manager.enable = true; - }; - - xsession.windowManager.i3 = { - enable = true; - config = { - modifier = "Mod4"; - terminal = "${pkgs.kitty}/bin/kitty"; - - fonts = { - names = [ "DejaVu Sans Mono" ]; - size = 12.0; - }; - - window = { - titlebar = false; - border = 0; - }; - - floating = { - titlebar = false; - border = 0; - }; - - bars = [{ - mode = "hide"; - position = "top"; - statusCommand = "${pkgs.i3status-rust}/bin/i3status-rs ~/.config/i3status-rust/config-default.toml"; - - fonts = { - names = [ "DejaVu Sans Mono" ]; - size = 12.0; - }; - }]; - }; - }; + imports = [ + home-manager/fzf.nix + home-manager/git.nix + home-manager/kitty.nix + home-manager/neovim + home-manager/gpg + home-manager/tmux.nix + home-manager/zsh.nix + home-manager/starship.nix + home-manager/i3.nix + home-manager/i3status-rust.nix + ]; } diff --git a/nvim/.gitignore b/nvim/.gitignore deleted file mode 100644 index 87553b2..0000000 --- a/nvim/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/plugin/