diff --git a/flake.nix b/flake.nix index 682ccb8..d0e8979 100644 --- a/flake.nix +++ b/flake.nix @@ -123,10 +123,12 @@ inputs.nixpkgs.follows = "nixpkgs"; }; + # ===== Nvim Plugins ===== # marks-nvim = { url = "github:chentoast/marks.nvim"; flake = false; }; + # ======================== # }; outputs = diff --git a/home/presets/basic.nix b/home/presets/basic.nix index 714529d..ce1de11 100644 --- a/home/presets/basic.nix +++ b/home/presets/basic.nix @@ -15,6 +15,6 @@ ../user/vscode.nix ../user/yazi.nix ../user/zellij.nix - ../user/nvf.nix + ../user/nvf ]; } diff --git a/home/scripts/md2html.nix b/home/scripts/md2html.nix new file mode 100644 index 0000000..fc6f88c --- /dev/null +++ b/home/scripts/md2html.nix @@ -0,0 +1,23 @@ +{ pkgs, ... }: +let + cssStyle = pkgs.fetchurl { + url = "https://raw.githubusercontent.com/xz/new.css/refs/heads/master/new.css"; + hash = "sha256-Xd3AMZOeThsrupQusSLjqv3hbNmcpeTms0ieI9nyxOk="; + }; +in +pkgs.writeShellScriptBin "md2html" '' + set -e + + INPUT="$1" + shift + + BASENAME="''\${INPUT%.*}" + HTML_TEMP="''\${BASENAME}.html" + PDF_OUTPUT="''\${BASENAME}.pdf" + + ${pkgs.pandoc}/bin/pandoc "$INPUT" -s \ + --to=html5 --embed-resources \ + --css=${cssStyle} -o "$HTML_TEMP" "$@" + + echo "generated: $HTML_TEMP" +'' diff --git a/home/user/nvf.nix b/home/user/nvf/default.nix similarity index 82% rename from home/user/nvf.nix rename to home/user/nvf/default.nix index 4b4d6b5..bef8537 100644 --- a/home/user/nvf.nix +++ b/home/user/nvf/default.nix @@ -1,9 +1,7 @@ { pkgs, lib, - osConfig, inputs, - system, ... }: let @@ -25,6 +23,10 @@ let }; in { + imports = [ + ./plugins/snacks-nvim + ]; + programs.nvf = { enable = true; settings = { @@ -87,68 +89,6 @@ in }; keymaps = [ - # === Files === # - # Explorer - { - key = "e"; - mode = [ "n" ]; - action = ":Neotree toggle"; - silent = true; - desc = "Toggle file explorer"; - } - # === Fzf lua === # - { - key = ""; - silent = true; - mode = [ "n" ]; - action = ":FzfLua files"; - nowait = true; - unique = true; - desc = "Find file"; - } - { - key = "/"; - mode = [ "n" ]; - action = ":FzfLua live_grep"; - nowait = true; - unique = true; - desc = "Live grep"; - } - # Lsp symbol document - { - key = "ss"; - silent = true; - mode = [ "n" ]; - action = ":FzfLua lsp_document_symbols"; - nowait = true; - unique = true; - desc = "Find symbols (document)"; - } - # Lsp symbol workspace - { - key = "sS"; - silent = true; - mode = [ "n" ]; - action = ":FzfLua lsp_workspace_symbols"; - unique = true; - nowait = true; - desc = "Find symbols (workspace)"; - } - # Registers - { - key = ''""''; - mode = [ "n" ]; - action = ":FzfLua registers"; - desc = "Registers"; - } - # Marks - { - key = "''"; - mode = [ "n" ]; - action = ":FzfLua marks"; - desc = "Marks"; - } - # === Buffer === # { key = "bo"; @@ -181,34 +121,6 @@ in action = ""; desc = "Shift left"; } - { - key = "gd"; - mode = [ "n" ]; - action = ":FzfLua lsp_definitions"; - nowait = true; - desc = "Go to definition"; - } - { - key = "gD"; - mode = [ "n" ]; - action = ":FzfLua lsp_declarations"; - nowait = true; - desc = "Go to declaration"; - } - { - key = "gi"; - mode = [ "n" ]; - action = ":FzfLua lsp_implementations"; - nowait = true; - desc = "Go to implementation"; - } - { - key = "gr"; - mode = [ "n" ]; - action = ":FzfLua lsp_references"; - nowait = true; - desc = "List references"; - } { key = "n"; mode = [ "n" ]; @@ -496,12 +408,6 @@ in visuals = { nvim-web-devicons.enable = true; nvim-cursorline.enable = true; - cinnamon-nvim = { - enable = true; - setupOpts.keymaps = { - basic = true; - }; - }; fidget-nvim = { enable = true; setupOpts.notification = { @@ -705,7 +611,15 @@ in snippets.luasnip = { enable = true; - providers = [ "blink-cmp" ]; + providers = [ + "friendly-snippets" + "blink-cmp" + "base16" + "lsp-signature-nvim" + "snacks-nvim" + "render-markdown-nvim" + "cmp-path" + ]; setupOpts.enable_autosnippets = true; }; @@ -715,7 +629,7 @@ in filetree = { neo-tree = { - enable = true; + enable = false; setupOpts = { window = { position = "right"; @@ -754,86 +668,6 @@ in whichKey.enable = true; }; - fzf-lua = { - enable = true; - setupOpts = { - previewers = { - builtin = { - extensions = { - "jpg" = { - "kitty" = ""; - }; - }; - snacks_image = { - enabled = false; - render_inline = false; - }; - }; - }; - winopts = { - preview = { - hidden = "hidden"; - }; - border = "rounded"; - }; - fzf_opts = { - "--no-header" = ""; - "--no-scrollbar" = ""; - }; - files = { - formatter = "path.filename_first"; - prompt = ":"; - no_header = true; - cwd_header = false; - cwd_prompt = false; - winopts = { - title = " files 📑 "; - title_pos = "center"; - title_flags = false; - }; - }; - buffers = { - formatter = "path.filename_first"; - prompt = ":"; - no_header = true; - fzf_opts = { - "--delimiter" = " "; - "--with-nth" = "-1.."; - }; - winopts = { - title = " buffers 📝 "; - title_pos = "center"; - }; - }; - lsp = { - symbols = { - cwd_only = true; - no_header = true; - prompt = ":"; - winopts = { - title = " symbols ✨ "; - title_pos = "center"; - height = 0.6; - preview = { - hidden = "nohidden"; - horizontal = "down:40%"; - wrap = "wrap"; - }; - }; - }; - - }; - registers = { - prompt = "registers:"; - filter = "%a"; - winopts = { - title = " registers 🏷️ "; - title_pos = "center"; - }; - }; - }; - }; - dashboard = { alpha.enable = true; }; diff --git a/home/user/nvf/plugins/snacks-nvim/default.nix b/home/user/nvf/plugins/snacks-nvim/default.nix new file mode 100644 index 0000000..888bc3e --- /dev/null +++ b/home/user/nvf/plugins/snacks-nvim/default.nix @@ -0,0 +1,55 @@ +{ pkgs, ... }: +{ + programs.nvf.settings.vim = { + keymaps = import ./keymaps.nix; + extraPackages = with pkgs; [ fd ]; + }; + + programs.nvf.settings.vim.utility.snacks-nvim = { + enable = true; + setupOpts = { + bigfile = { + enabled = true; + }; + dashboard = { + enabled = false; + }; + explorer = { + enabled = true; + }; + indent = { + enabled = true; + }; + input = { + enabled = true; + }; + picker = { + enabled = true; + sources = { + explorer.layout.layout.position = "right"; + }; + formatters = { + file.filename_first = true; + }; + }; + notifier = { + enabled = true; + }; + quickfile = { + enabled = true; + }; + scope = { + enabled = true; + }; + scroll = { + enabled = true; + }; + statuscolumn = { + enabled = false; + }; + words = { + enabled = true; + }; + }; + }; +} diff --git a/home/user/nvf/plugins/snacks-nvim/keymaps.nix b/home/user/nvf/plugins/snacks-nvim/keymaps.nix new file mode 100644 index 0000000..3176caf --- /dev/null +++ b/home/user/nvf/plugins/snacks-nvim/keymaps.nix @@ -0,0 +1,132 @@ +let + keyList = [ + { + key = "e"; + action = "explorer()"; + desc = "Toggle explorer"; + } + { + key = ""; + action = "picker.smart()"; + desc = "Smart Find Files"; + } + { + key = "/"; + action = "picker.grep()"; + desc = "Live Grep"; + } + { + key = "ss"; + action = "picker.lsp_symbols()"; + desc = "Find symbols"; + } + { + key = "sS"; + action = "picker.lsp_workspace_symbols()"; + desc = "Find symbols (Workspace)"; + } + # Grep + { + key = "sb"; + action = "picker.lines()"; + desc = "Buffer Lines"; + } + { + key = "sB"; + action = "picker.grep_buffers()"; + desc = "Grep Open Buffers"; + } + { + key = "sw"; + action = "picker.grep_word()"; + desc = "Visual selection or word"; + mode = [ + "n" + "x" + ]; + } + { + key = ''s"''; + action = "picker.registers()"; + desc = "Registers"; + } + { + key = "sd"; + action = "picker.diagnostics()"; + desc = "Diagnostics"; + } + { + key = "sD"; + action = "picker.diagnostics_buffer()"; + desc = "Buffer Diagnostics"; + } + { + key = "gd"; + action = "picker.lsp_definitions()"; + desc = "Goto Definition"; + } + { + key = "gD"; + action = "picker.lsp_declarations()"; + desc = "Goto Declaration"; + } + { + key = "gr"; + action = "picker.lsp_references()"; + desc = "References"; + } + { + key = "gI"; + action = "picker.lsp_implementations()"; + desc = "Goto Implementation"; + } + { + key = "gy"; + action = "picker.lsp_type_definitions()"; + desc = "Goto T[y]pe Definition"; + } + { + key = "st"; + action = "picker.todo_comments()"; + desc = "Todo"; + } + { + key = "sT"; + action = ''picker.todo_comments({ keywords = { "TODO", "FIX", "FIXME" } })''; + desc = "Todo/Fix/Fixme"; + } + + # === Git === # + { + key = "gd"; + action = "picker.git_diff()"; + desc = "Git Diff"; + } + { + key = "gl"; + action = "picker.git_log()"; + desc = "Git Log"; + } + { + key = "gs"; + action = "picker.git_stash()"; + desc = "Git Stash"; + } + ]; + + mkLuaKeyMap = + { + key, + action, + desc ? "", + mode ? [ "n" ], + }: + { + inherit key desc mode; + action = "function() Snacks.${action} end"; + lua = true; + nowait = true; + unique = true; + }; +in +map (x: mkLuaKeyMap x) keyList diff --git a/home/user/packages.nix b/home/user/packages.nix index 7e5e0fa..f9e07c3 100644 --- a/home/user/packages.nix +++ b/home/user/packages.nix @@ -6,15 +6,10 @@ osConfig, ... }: +let + md2html = pkgs.callPackage ../scripts/md2html.nix { }; +in { - programs.poetry = { - enable = true; - settings = { - virtualenvs.create = true; - virtualenvs.in-project = true; - }; - }; - programs.btop = { enable = true; settings = { @@ -93,6 +88,8 @@ ffmpegthumbnailer thunderbird + + md2html ] ++ ( if osConfig.programs.steam.enable then diff --git a/system/dev/dn-server/services.nix b/system/dev/dn-server/services.nix index f39705f..9d64497 100644 --- a/system/dev/dn-server/services.nix +++ b/system/dev/dn-server/services.nix @@ -139,11 +139,17 @@ let allowedIPs = [ "10.0.0.145/32" ]; } { - # Skydrive + # Skydrive Lap dns = "skydrive-mesh"; publicKey = "MK6UX8WadSbDXI3919F5EarYlZHjFNbHwYJH8Ub/YXk="; allowedIPs = [ "10.0.0.146/32" ]; } + { + # Skydrive Phone + dns = "skydrive-mesh-phone"; + publicKey = "K6Pd69/Hfu4ceCAp/JbeEL2QQ+/4ohugW1lAOxHFKDA="; + allowedIPs = [ "10.0.0.147/32" ]; + } ]; in { diff --git a/system/dev/generic/default.nix b/system/dev/generic/default.nix index d2eef1b..8469823 100644 --- a/system/dev/generic/default.nix +++ b/system/dev/generic/default.nix @@ -8,27 +8,24 @@ { imports = [ (modulesPath + "/installer/scan/not-detected.nix") - (modulesPath + "/profiles/qemu-guest.nix") ./disk.nix ./hardware-configuration.nix ../../modules/nixsettings.nix ]; - # boot.loader.systemd-boot.enable = true; - boot.loader.grub = { - enable = true; - devices = [ "/dev/sda" ]; - efiSupport = true; - efiInstallAsRemovable = true; - }; + boot.loader.systemd-boot.enable = true; boot.kernelPackages = pkgs.linuxPackages_latest; + networking.firewall = { + allowedTCPPorts = [ 22 ]; + allowedUDPPorts = [ ]; + }; + services.openssh = { enable = true; ports = [ 22 - 30072 ]; settings = { PasswordAuthentication = true; diff --git a/system/dev/skydrive-lap/default.nix b/system/dev/skydrive-lap/default.nix index d91e388..b663308 100644 --- a/system/dev/skydrive-lap/default.nix +++ b/system/dev/skydrive-lap/default.nix @@ -152,5 +152,6 @@ in users.users."${username}".openssh.authorizedKeys.keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJSAOufpee7f8D8ONIIGU3qsN+8+DGO7BfZnEOTYqtQ5 danny@pre7780.dn" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBDk8GmC7b9+XSDxnIj5brYmNLPVO47G5enrL3Q+8fuh 好強上的捷徑" ]; }