diff --git a/alacritty/config.nix b/alacritty.nix similarity index 100% rename from alacritty/config.nix rename to alacritty.nix diff --git a/alacritty/default.nix b/alacritty/default.nix deleted file mode 100644 index e5541e3..0000000 --- a/alacritty/default.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ - config = { - programs.alacritty = { - enable = true; - settings = import ./config.nix; - }; - }; -} diff --git a/bash/default.nix b/bash/default.nix deleted file mode 100644 index 0f57e05..0000000 --- a/bash/default.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ - config = { - programs.bash = { - enable = true; - shellAliases = { - htop = "btop"; - gp = "git push"; - gco = "git checkout"; - gd = "git diff"; - gc = "git commit"; - gpl = "git pull"; - gb = "git branch"; - ga = "git add"; - gl = "git log"; - gs = "git status"; - }; - }; - }; -} diff --git a/direnv/default.nix b/direnv/default.nix deleted file mode 100644 index fd12478..0000000 --- a/direnv/default.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ - config = { - programs.direnv = { - enable = true; - enableBashIntegration = true; - nix-direnv.enable = true; - }; - }; -} diff --git a/firefox/addons.json b/firefox-addons/addons.json similarity index 100% rename from firefox/addons.json rename to firefox-addons/addons.json diff --git a/firefox/addons.nix b/firefox-addons/default.nix similarity index 84% rename from firefox/addons.nix rename to firefox-addons/default.nix index 2527bf5..82d58c1 100644 --- a/firefox/addons.nix +++ b/firefox-addons/default.nix @@ -1,7 +1,7 @@ {nurpkgs, lib, ...}@args: let rycee-addons = nurpkgs.repos.rycee.firefox-addons; - custom-addons = import ./custom-addons.nix args; + own-addons = import ./derivations.nix args; in { default = lib.concatLists [ @@ -18,7 +18,7 @@ in boring-rss # rycee.bypass-paywalls-clean ]) - (with custom-addons; [ + (with own-addons; [ http-version-indicator indicatetls sixindicator @@ -28,6 +28,6 @@ in ublock-origin istilldontcareaboutcookies keepassxc-browser - custom-addons.simple-style-fox-2 + own-addons.simple-style-fox-2 ]; } diff --git a/firefox/custom-addons.nix b/firefox-addons/derivations.nix similarity index 100% rename from firefox/custom-addons.nix rename to firefox-addons/derivations.nix diff --git a/firefox/default.nix b/firefox/default.nix deleted file mode 100644 index eaf656b..0000000 --- a/firefox/default.nix +++ /dev/null @@ -1,51 +0,0 @@ -{ pkgs, ...}@args: - -let - nurpkgs = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") { inherit pkgs; }; - firefoxAddons = import ./addons.nix (args // {inherit nurpkgs; }); - firefoxSettings = { - "browser.aboutConfig.showWarning" = false; - "browser.toolbars.bookmarks.visibility" = "always"; - "browser.tabs.firefox-view" = false; - "browser.shell.checkDefaultBrowser" = false; - }; -in -{ - config = { - programs.firefox = { - enable = true; - profiles = { - default = { - id = 0; - isDefault = true; - settings = firefoxSettings; - extensions = firefoxAddons.default; - }; - sue = { - id = 1; - settings = firefoxSettings; - extensions = firefoxAddons.sue; - }; - }; - }; - - xdg.desktopEntries.firefox-sue = { - categories = [ "Network" "WebBrowser" ]; - exec = "firefox -P sue --name firefox %U"; - genericName = "Web Browser"; - icon = "firefox"; - mimeType = [ - "text/html" - "text/xml" - "application/xhtml+xml" - "application/vnd.mozilla.xul+xml" - "x-scheme-handler/http" - "x-scheme-handler/https" - ]; - name = "Firefox | Sue"; - startupNotify = true; - terminal = false; - type = "Application"; - }; - }; -} diff --git a/fzf/default.nix b/fzf/default.nix deleted file mode 100644 index 383f47e..0000000 --- a/fzf/default.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ - config = { - programs.fzf = { - enable = true; - enableBashIntegration = true; - }; - }; -} diff --git a/git/default.nix b/git/default.nix deleted file mode 100644 index 735b4d5..0000000 --- a/git/default.nix +++ /dev/null @@ -1,12 +0,0 @@ -{ - config = { - programs.git = { - enable = true; - userName = "Pim Kunis"; - userEmail = "pim@kunis.nl"; - extraConfig = { - push.autoSetupRemote = true; - }; - }; - }; -} diff --git a/home.nix b/home.nix index 64651dc..a4bdfe8 100644 --- a/home.nix +++ b/home.nix @@ -1,26 +1,23 @@ -{ pkgs, ... }: - +{ pkgs, lib, ... }@args: +let + nurpkgs = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") { inherit pkgs; }; + firefox-addons = import ./firefox-addons (args // {inherit nurpkgs; }); + homeDirectory = "/home/pim"; + firefoxSettings = { + "browser.aboutConfig.showWarning" = false; + "browser.toolbars.bookmarks.visibility" = "always"; + "browser.tabs.firefox-view" = false; + "browser.shell.checkDefaultBrowser" = false; + }; +in { - imports = [ - ./bash - ./neovim - ./firefox - ./ssh - ./syncthing - ./alacritty - ./keepassxc - ./git - ./direnv - ./thunderbird - ./fzf - ]; - home = { username = "pim"; - homeDirectory = "/home/pim"; + homeDirectory = homeDirectory; stateVersion = "23.05"; packages = with pkgs; [ + keepassxc moonlight-qt vlc nicotine-plus @@ -34,9 +31,204 @@ ]; }; + services = { + syncthing.enable = true; + }; + programs = { home-manager.enable = true; chromium.enable = true; + + neovim = + let + toLua = str: "lua << EOF\n${str}\nEOF\n"; + toLuaFile = file: "lua << EOF\n${builtins.readFile file}\nEOF\n"; + in + { + enable = true; + + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + + extraPackages = with pkgs; [ + luajitPackages.lua-lsp + rnix-lsp + + xclip + wl-clipboard + ]; + + plugins = with pkgs.vimPlugins; [ + { + plugin = nvim-lspconfig; + config = toLuaFile ./nvim/plugin/lsp.lua; + } + + { + plugin = comment-nvim; + config = toLua "require(\"Comment\").setup()"; + } + + { + plugin = gruvbox-nvim; + config = "colorscheme gruvbox"; + } + + neodev-nvim + + nvim-cmp + { + plugin = nvim-cmp; + config = toLuaFile ./nvim/plugin/cmp.lua; + } + + { + plugin = telescope-nvim; + config = toLuaFile ./nvim/plugin/telescope.lua; + } + + telescope-fzf-native-nvim + + cmp_luasnip + cmp-nvim-lsp + + luasnip + friendly-snippets + + + lualine-nvim + nvim-web-devicons + + { + plugin = (nvim-treesitter.withPlugins (p: [ + p.tree-sitter-nix + p.tree-sitter-vim + p.tree-sitter-bash + p.tree-sitter-lua + p.tree-sitter-python + p.tree-sitter-json + ])); + config = toLuaFile ./nvim/plugin/treesitter.lua; + } + + vim-nix + + # { + # plugin = vimPlugins.own-onedark-nvim; + # config = "colorscheme onedark"; + # } + ]; + + extraLuaConfig = '' + ${builtins.readFile ./nvim/options.lua} + ''; + }; + + alacritty = { + enable = true; + settings = import ./alacritty.nix; + }; + + firefox = { + enable = true; + profiles = { + default = { + id = 0; + isDefault = true; + settings = firefoxSettings; + extensions = firefox-addons.default; + }; + sue = { + id = 1; + settings = firefoxSettings; + extensions = firefox-addons.sue; + }; + }; + }; + + bash = { + enable = true; + shellAliases = { + htop = "btop"; + gp = "git push"; + gco = "git checkout"; + gd = "git diff"; + gc = "git commit"; + gpl = "git pull"; + gb = "git branch"; + ga = "git add"; + gl = "git log"; + gs = "git status"; + }; + }; + + direnv = { + enable = true; + enableBashIntegration = true; + nix-direnv.enable = true; + }; + + git = { + enable = true; + userName = "Pim Kunis"; + userEmail = "pim@kunis.nl"; + extraConfig = { + core.editor = "nvim"; + push.autoSetupRemote = true; + }; + }; + + fzf = { + enable = true; + enableBashIntegration = true; + }; + + ssh = { + enable = true; + extraConfig = "User root"; + + matchBlocks = { + gitlab-sue = lib.hm.dag.entryBefore [ "*" ] { + hostname = "gitlab.com"; + identityFile = "~/.ssh/sue_ed25519"; + identitiesOnly = true; + }; + github = lib.hm.dag.entryBefore [ "*" ] { + hostname = "github.com"; + user = "pizzapim"; + identitiesOnly = true; + }; + lewis = lib.hm.dag.entryBefore [ "*" ] { + hostname = "lewis.hyp"; + }; + atlas = lib.hm.dag.entryBefore [ "*" ] { + hostname = "atlas.hyp"; + }; + jefke = lib.hm.dag.entryBefore [ "*" ] { + hostname = "jefke.hyp"; + }; + hermes = lib.hm.dag.entryBefore [ "*" ] { + hostname = "hermes.dmz"; + }; + maestro = lib.hm.dag.entryBefore [ "*" ] { + hostname = "maestro.dmz"; + }; + bancomart = lib.hm.dag.entryBefore [ "*" ] { + hostname = "bancomart.dmz"; + }; + handjecontantje = lib.hm.dag.entryBefore [ "*" ] { + hostname = "handjecontantje.dmz"; + }; + }; + }; + + thunderbird = { + enable = true; + profiles.default = { + isDefault = true; + }; + }; }; # Let home-manager manage the X session @@ -44,5 +236,34 @@ enable = true; }; - xdg.userDirs.enable = true; + xdg = { + configFile = { + "keepassxc/keepassxc.ini".text = lib.generators.toINI {} (import ./keepassxc.nix); + "syncthing/config.xml".source = ./syncthing.xml; + }; + + userDirs = { + enable = true; + music = "${homeDirectory}/sync/Music"; + }; + + desktopEntries.firefox-sue = { + categories = [ "Network" "WebBrowser" ]; + exec = "firefox -P sue --name firefox %U"; + genericName = "Web Browser"; + icon = "firefox"; + mimeType = [ + "text/html" + "text/xml" + "application/xhtml+xml" + "application/vnd.mozilla.xul+xml" + "x-scheme-handler/http" + "x-scheme-handler/https" + ]; + name = "Firefox | Sue"; + startupNotify = true; + terminal = false; + type = "Application"; + }; + }; } diff --git a/keepassxc/config.nix b/keepassxc.nix similarity index 100% rename from keepassxc/config.nix rename to keepassxc.nix diff --git a/keepassxc/default.nix b/keepassxc/default.nix deleted file mode 100644 index b3a015c..0000000 --- a/keepassxc/default.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ pkgs, lib, ...}: - -{ - config = { - home.packages = [ pkgs.keepassxc ]; - xdg.configFile."keepassxc/keepassxc.ini".text = lib.generators.toINI {} (import ./config.nix); - }; -} diff --git a/neovim/default.nix b/neovim/default.nix deleted file mode 100644 index d17be6b..0000000 --- a/neovim/default.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ pkgs, ... }: - -{ - config = { - home.packages = with pkgs; [ - nil - nodePackages.pyright - neofetch - gopls - ]; - - programs.neovim = { - enable = true; - viAlias = true; - vimAlias = true; - vimdiffAlias = true; - defaultEditor = true; - plugins = with pkgs.vimPlugins; [ - nvim-lspconfig - gruvbox-nvim - leap-nvim - telescope-nvim - vim-commentary - vim-sleuth - gitsigns-nvim - nvim-cmp - cmp-nvim-lsp - friendly-snippets - neodev-nvim - ]; - extraLuaConfig = builtins.readFile ./neovim.lua; - }; - - programs.git.extraConfig.core.editor = "nvim"; - }; -} diff --git a/neovim/neovim.lua b/neovim/neovim.lua deleted file mode 100644 index 918c3f2..0000000 --- a/neovim/neovim.lua +++ /dev/null @@ -1,124 +0,0 @@ ---[ GLOBAL ]-- - -vim.o.background = "dark" -vim.cmd([[colorscheme gruvbox]]) -vim.g.mapleader = ";" -vim.o.signcolumn = "yes" -vim.wo.number = true -vim.wo.relativenumber = true -vim.wo.cursorline = true - ---[ LSPCONFIG ]-- - -local on_attach = function(_, bufnr) - - local bufmap = function(keys, func) - vim.keymap.set('n', keys, func, { buffer = bufnr }) - end - - bufmap('r', vim.lsp.buf.rename) - bufmap('a', vim.lsp.buf.code_action) - - bufmap('gd', vim.lsp.buf.definition) - bufmap('gD', vim.lsp.buf.declaration) - bufmap('gI', vim.lsp.buf.implementation) - bufmap('D', vim.lsp.buf.type_definition) - - bufmap('gr', require('telescope.builtin').lsp_references) - bufmap('s', require('telescope.builtin').lsp_document_symbols) - bufmap('S', require('telescope.builtin').lsp_dynamic_workspace_symbols) - - bufmap('K', vim.lsp.buf.hover) - - vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) - vim.lsp.buf.format() - end, {}) -end - -local capabilities = vim.lsp.protocol.make_client_capabilities() -capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) - -require('neodev').setup() -require'lspconfig'.nil_ls.setup{ on_attach = on_attach, capabilities = capabilities } -require'lspconfig'.pyright.setup{ on_attach = on_attach, capabilities = capabilities } -require'lspconfig'.gopls.setup{ on_attach = on_attach, capabilities = capabilities } - ---[ LEAP ]-- - -require('leap').add_default_mappings() --- Don't remap 'x' in visual mode. -vim.keymap.del({'x', 'o'}, 'x') -vim.keymap.del({'x', 'o'}, 'X') - ---[ TELESCOPE ]-- - -local builtin = require('telescope.builtin') - -vim.keymap.set('n', 'ff', builtin.find_files, {}) -vim.keymap.set('n', 'fg', builtin.live_grep, {}) -vim.keymap.set('n', 'fb', builtin.buffers, {}) -vim.keymap.set('n', 'fr', builtin.lsp_references, {}) -vim.keymap.set('n', 'fs', builtin.lsp_document_symbols, {}) - -require('telescope').setup{ - pickers = { - find_files = { - theme = "dropdown" - }, - live_grep = { - theme = "dropdown" - }, - buffers = { - theme = "dropdown" - }, - lsp_references = { - theme = "dropdown" - }, - lsp_document_symbols = { - theme = "dropdown" - } - } -} - ---[ COMMENTARY ]-- -vim.cmd([[autocmd FileType nix setlocal commentstring=#\ %s]]) - ---[ GITSIGNS ]-- -require("gitsigns").setup() - ---[ CMP ]-- - --- For snippets: look at https://github.com/vimjoyer/nvim-nix-video/blob/main/nvim/plugin/cmp.lua - -local cmp = require('cmp') - -cmp.setup { - mapping = cmp.mapping.preset.insert { - [''] = cmp.mapping.select_next_item(), - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.complete {}, - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }, - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - else - fallback() - end - end, { 'i', 's' }), - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - else - fallback() - end - end, { 'i', 's' }), - }, - sources = { - { name = 'nvim_lsp' }, - }, -} diff --git a/nvim/options.lua b/nvim/options.lua new file mode 100644 index 0000000..ef6883a --- /dev/null +++ b/nvim/options.lua @@ -0,0 +1,19 @@ + +vim.g.mapleader = ';' +vim.g.maplocalleader = ';' + +vim.o.clipboard = 'unnamedplus' + +vim.o.number = true +-- vim.o.relativenumber = true + +vim.o.signcolumn = 'yes' + +vim.o.tabstop = 4 +vim.o.shiftwidth = 4 + +vim.o.updatetime = 300 + +vim.o.termguicolors = true + +vim.o.mouse = 'a' diff --git a/nvim/plugin/cmp.lua b/nvim/plugin/cmp.lua new file mode 100644 index 0000000..cf2b7a7 --- /dev/null +++ b/nvim/plugin/cmp.lua @@ -0,0 +1,46 @@ +local cmp = require('cmp') +local luasnip = require('luasnip') + +require('luasnip.loaders.from_vscode').lazy_load() +luasnip.config.setup {} + +cmp.setup { + snippet = { + expand = function(args) + luasnip.lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert { + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete {}, + [''] = cmp.mapping.confirm { + behavior = cmp.ConfirmBehavior.Replace, + select = true, + }, + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_locally_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { 'i', 's' }), + [''] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { 'i', 's' }), + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + }, +} diff --git a/nvim/plugin/lsp.lua b/nvim/plugin/lsp.lua new file mode 100644 index 0000000..a65c1b2 --- /dev/null +++ b/nvim/plugin/lsp.lua @@ -0,0 +1,48 @@ +local on_attach = function(_, bufnr) + + local bufmap = function(keys, func) + vim.keymap.set('n', keys, func, { buffer = bufnr }) + end + + bufmap('r', vim.lsp.buf.rename) + bufmap('a', vim.lsp.buf.code_action) + + bufmap('gd', vim.lsp.buf.definition) + bufmap('gD', vim.lsp.buf.declaration) + bufmap('gI', vim.lsp.buf.implementation) + bufmap('D', vim.lsp.buf.type_definition) + + bufmap('gr', require('telescope.builtin').lsp_references) + bufmap('s', require('telescope.builtin').lsp_document_symbols) + bufmap('S', require('telescope.builtin').lsp_dynamic_workspace_symbols) + + bufmap('K', vim.lsp.buf.hover) + + vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_) + vim.lsp.buf.format() + end, {}) +end + +local capabilities = vim.lsp.protocol.make_client_capabilities() +capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities) + +require('neodev').setup() +require('lspconfig').lua_ls.setup { + on_attach = on_attach, + capabilities = capabilities, + root_dir = function() + return vim.loop.cwd() + end, + cmd = { "lua-lsp" }, + settings = { + Lua = { + workspace = { checkThirdParty = false }, + telemetry = { enable = false }, + }, + } +} + +require('lspconfig').rnix.setup { + on_attach = on_attach, + capabilities = capabilities, +} diff --git a/nvim/plugin/other.lua b/nvim/plugin/other.lua new file mode 100644 index 0000000..34ff92e --- /dev/null +++ b/nvim/plugin/other.lua @@ -0,0 +1,11 @@ +-- Lualine +require("lualine").setup({ + icons_enabled = true, + theme = 'onedark', +}) + +-- Colorscheme +vim.cmd("colorscheme gruvbox") + +-- Comment +require("Comment").setup() diff --git a/nvim/plugin/telescope.lua b/nvim/plugin/telescope.lua new file mode 100644 index 0000000..59c0ffc --- /dev/null +++ b/nvim/plugin/telescope.lua @@ -0,0 +1,27 @@ +local builtin = require('telescope.builtin') + +vim.keymap.set('n', 'ff', builtin.find_files, {}) +vim.keymap.set('n', 'fg', builtin.live_grep, {}) +vim.keymap.set('n', 'fb', builtin.buffers, {}) +vim.keymap.set('n', 'fr', builtin.lsp_references, {}) +vim.keymap.set('n', 'fs', builtin.lsp_document_symbols, {}) + +require('telescope').setup{ + pickers = { + find_files = { + theme = "dropdown" + }, + live_grep = { + theme = "dropdown" + }, + buffers = { + theme = "dropdown" + }, + lsp_references = { + theme = "dropdown" + }, + lsp_document_symbols = { + theme = "dropdown" + } + } +} diff --git a/nvim/plugin/treesitter.lua b/nvim/plugin/treesitter.lua new file mode 100644 index 0000000..2edb953 --- /dev/null +++ b/nvim/plugin/treesitter.lua @@ -0,0 +1,9 @@ +require('nvim-treesitter.configs').setup { + ensure_installed = {}, + + auto_install = false, + + highlight = { enable = true }, + + indent = { enable = true }, +} diff --git a/ssh/default.nix b/ssh/default.nix deleted file mode 100644 index b5c52e1..0000000 --- a/ssh/default.nix +++ /dev/null @@ -1,44 +0,0 @@ -{ lib, ...}: - -{ - config = { - programs.ssh = { - enable = true; - extraConfig = "User root"; - - matchBlocks = { - gitlab-sue = lib.hm.dag.entryBefore [ "*" ] { - hostname = "gitlab.com"; - identityFile = "~/.ssh/sue_ed25519"; - identitiesOnly = true; - }; - github = lib.hm.dag.entryBefore [ "*" ] { - hostname = "github.com"; - user = "pizzapim"; - identitiesOnly = true; - }; - lewis = lib.hm.dag.entryBefore [ "*" ] { - hostname = "lewis.hyp"; - }; - atlas = lib.hm.dag.entryBefore [ "*" ] { - hostname = "atlas.hyp"; - }; - jefke = lib.hm.dag.entryBefore [ "*" ] { - hostname = "jefke.hyp"; - }; - hermes = lib.hm.dag.entryBefore [ "*" ] { - hostname = "hermes.dmz"; - }; - maestro = lib.hm.dag.entryBefore [ "*" ] { - hostname = "maestro.dmz"; - }; - bancomart = lib.hm.dag.entryBefore [ "*" ] { - hostname = "bancomart.dmz"; - }; - handjecontantje = lib.hm.dag.entryBefore [ "*" ] { - hostname = "handjecontantje.dmz"; - }; - }; - }; - }; -} diff --git a/syncthing/syncthing.xml b/syncthing.xml similarity index 100% rename from syncthing/syncthing.xml rename to syncthing.xml diff --git a/syncthing/default.nix b/syncthing/default.nix deleted file mode 100644 index f68e931..0000000 --- a/syncthing/default.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ config, ... }: - -{ - config = { - services.syncthing.enable = true; - xdg.configFile."syncthing/config.xml".source = ./syncthing.xml; - xdg.userDirs.music = "${config.home.homeDirectory}/sync/Music"; - }; -} diff --git a/thunderbird/default.nix b/thunderbird/default.nix deleted file mode 100644 index c3d1be6..0000000 --- a/thunderbird/default.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ - config = { - programs.thunderbird = { - enable = true; - profiles.default = { - isDefault = true; - }; - }; - }; -}