From e2ee24b57af87f0f0c4866ed551ae6c84ce1f973 Mon Sep 17 00:00:00 2001 From: zack Date: Thu, 31 Oct 2024 21:01:42 -0400 Subject: [PATCH] updates --- modules/home/apps/term/kitty/default.nix | 16 +-- .../apps/tools/neovim/config/lazyvim.json | 1 + .../neovim/config/lua/config/keymaps.lua | 124 +++++++++++++++++- .../tools/neovim/config/lua/plugins/core.lua | 66 ++++++++-- .../tools/neovim/config/lua/plugins/curl.lua | 2 +- modules/home/apps/tools/neovim/default.nix | 1 + modules/home/wms/hyprland/default.nix | 4 +- modules/nixos/sites/minio/default.nix | 54 ++------ modules/nixos/ui/fonts/default.nix | 4 +- packages/sc/default.nix | 28 ++++ packages/zen-browser-unwrapped/default.nix | 4 +- systems/x86_64-linux/earth/default.nix | 2 +- systems/x86_64-linux/pluto/default.nix | 2 + 13 files changed, 238 insertions(+), 70 deletions(-) create mode 100644 packages/sc/default.nix diff --git a/modules/home/apps/term/kitty/default.nix b/modules/home/apps/term/kitty/default.nix index 2d57c4d..afef99b 100644 --- a/modules/home/apps/term/kitty/default.nix +++ b/modules/home/apps/term/kitty/default.nix @@ -12,14 +12,14 @@ in { enable = mkBoolOpt false "Enable Kitty Term"; fonts = { - # normal = mkStringOpt "ZedMono Nerd Font Mono Bold" "Normal Font"; - # bold = mkStringOpt "ZedMono Nerd Font Mono ExtraBold" "Bold Font"; - # italic = mkStringOpt "ZedMono Nerd Font Mono Bold Italic" "Italic Font"; - # bold_italic = mkStringOpt "ZedMono Nerd Font Mono ExtraBold Italic" "Bold Italic Font"; - normal = mkStringOpt "Iosevka Bold" "Normal Font"; - bold = mkStringOpt "Iosevka ExtraBold" "Bold Font"; - italic = mkStringOpt "Iosevka Bold Italic" "Italic Font"; - bold_italic = mkStringOpt "Iosevka ExtraBold Italic" "Bold Italic Font"; + normal = mkStringOpt "JetBrainsMonoNL Nerd Font Mono Bold" "Normal Font"; + bold = mkStringOpt "JetBrainsMonoNL Nerd Font Mono ExtraBold" "Bold Font"; + italic = mkStringOpt "JetBrainsMonoNL Nerd Font Mono Bold Italic" "Italic Font"; + bold_italic = mkStringOpt "JetBrainsMonoNL Nerd Font Mono ExtraBold Italic" "Bold Italic Font"; + # normal = mkStringOpt "Iosevka Bold" "Normal Font"; + # bold = mkStringOpt "Iosevka ExtraBold" "Bold Font"; + # italic = mkStringOpt "Iosevka Bold Italic" "Italic Font"; + # bold_italic = mkStringOpt "Iosevka ExtraBold Italic" "Bold Italic Font"; }; }; diff --git a/modules/home/apps/tools/neovim/config/lazyvim.json b/modules/home/apps/tools/neovim/config/lazyvim.json index 24ac257..5c27be1 100644 --- a/modules/home/apps/tools/neovim/config/lazyvim.json +++ b/modules/home/apps/tools/neovim/config/lazyvim.json @@ -20,6 +20,7 @@ "lazyvim.plugins.extras.lang.tailwind", "lazyvim.plugins.extras.lang.elixir", "lazyvim.plugins.extras.lang.tex", + "lazyvim.plugins.extras.lang.go", "lazyvim.plugins.extras.lang.typescript", "lazyvim.plugins.extras.test.core", "lazyvim.plugins.extras.util.dot", diff --git a/modules/home/apps/tools/neovim/config/lua/config/keymaps.lua b/modules/home/apps/tools/neovim/config/lua/config/keymaps.lua index 2c134f7..91ddc41 100644 --- a/modules/home/apps/tools/neovim/config/lua/config/keymaps.lua +++ b/modules/home/apps/tools/neovim/config/lua/config/keymaps.lua @@ -1,3 +1,121 @@ --- Keymaps are automatically loaded on the VeryLazy event --- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua --- Add any additional keymaps here +-- Function to get the visual selection +local function get_visual_selection() + -- Get the current buffer number (0 means current buffer) + local bufnr = 0 + + -- Get the total number of lines in the buffer + local line_count = vim.api.nvim_buf_line_count(bufnr) + + -- Get all lines from the buffer (0-based index, end is exclusive) + local lines = vim.api.nvim_buf_get_lines(bufnr, 0, line_count, false) + + -- Get the file name + local file_name = vim.fn.expand("%:p") + + -- Create the file info description + local file_info = string.format("File: %s (%d lines)", file_name, line_count) + + -- Convert the lines into a single string + local file_contents = table.concat(lines, "\n") + + -- Return both the file contents and the file info + return file_contents, file_info +end + +-- Function to parse JSON response and get gist URL +local function handle_response(response) + -- Parse the JSON response + local ok, decoded = pcall(vim.fn.json_decode, response) + if not ok then + vim.api.nvim_echo({ { + "Failed to parse response: " .. decoded, + "ErrorMsg", + } }, true, {}) + return nil + end + + -- Check if we have the expected data structure + if not (decoded and decoded.data and decoded.data.id) then + vim.api.nvim_echo({ { + "Invalid response format", + "ErrorMsg", + } }, true, {}) + return nil + end + + -- Construct the URL + return string.format("https://zoeys.computer/gists/%s", decoded.data.id) +end + +-- Function to create gist +local function create_gist() + -- Get the selected code and line range + local selected_code, line_range = get_visual_selection() + + -- Check if we got any code + if selected_code == "" then + vim.api.nvim_echo({ { + "No text selected", + "ErrorMsg", + } }, true, {}) + return + end + + -- Get the current file name with extension + local file_name = vim.fn.expand("%:t") + if file_name == "" then + file_name = "untitled." .. vim.bo.filetype + end + + -- Create the payload table first + local payload = { + title = file_name, + desc = line_range, + code = selected_code, + lang = vim.bo.filetype, + } + + -- Convert to JSON string + local json_data = vim.fn.json_encode(payload) + + -- Create a temporary file for the JSON payload + local temp_file = os.tmpname() + local f = io.open(temp_file, "w") + f:write(json_data) + f:close() + + -- Construct and execute the curl command + local cmd = string.format( + [[ + curl -s -X POST \ + https://zoeys.computer/api/gists/create \ + -H "Accept: application/json" \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer Z4MYrYtJUb3Y8VvJynkWAw9eBVU3kvvW9gQ50--hROw" \ + -d @%s + ]], + temp_file + ) + + -- Execute the command and get the response + local response = vim.fn.system(cmd) + + -- Clean up the temporary file + os.remove(temp_file) + + -- Parse response and get URL + local url = handle_response(response) + if url then + -- Copy URL to system clipboard + vim.fn.setreg("+", url) + + -- Show success message + vim.api.nvim_echo({ { + "Gist created! URL copied to clipboard: " .. url, + "Normal", + } }, true, {}) + end +end + +-- Set up the keybinding (you can modify this to your preferred key combination) +vim.keymap.set("n", "zc", create_gist, { noremap = true, silent = true, expr = true }) diff --git a/modules/home/apps/tools/neovim/config/lua/plugins/core.lua b/modules/home/apps/tools/neovim/config/lua/plugins/core.lua index 8818f3b..1caeab3 100644 --- a/modules/home/apps/tools/neovim/config/lua/plugins/core.lua +++ b/modules/home/apps/tools/neovim/config/lua/plugins/core.lua @@ -1,3 +1,9 @@ +function confirm(opts) + local cmp = require("blink.cmp") + opts = vim.tbl_extend("force", { select = true }, opts or {}) + return function(fallback) end +end + return { { "LazyVim/LazyVim", @@ -5,6 +11,8 @@ return { colorscheme = "catppuccin", }, }, + { "nvim-lualine/lualine.nvim", enabled = false }, + { "echasnovski/mini.statusline", opts = {} }, { "L3MON4D3/LuaSnip", dependencies = { @@ -29,6 +37,18 @@ return { }, }, { "hrsh7th/nvim-cmp", enabled = false }, + { + "lukas-reineke/indent-blankline.nvim", + main = "ibl", + tag = "v3.8.2", + ---@module "ibl" + ---@type ibl.config + -- opts = { + -- debounce = 100, + -- indent = { char = "|" }, + -- whitespace = { highlight = "Whitespace", "NonText" }, + -- }, + }, { "jake-stewart/force-cul.nvim", config = function() @@ -39,19 +59,49 @@ return { "saghen/blink.cmp", lazy = false, -- lazy loading handled internally -- optional: provides snippets for the snippet source - dependencies = "rafamadriz/friendly-snippets", + dependencies = { "rafamadriz/friendly-snippets", "saghen/blink.compat" }, build = "cargo build --release", + sources = { + completion = { + enabled_providers = { "lsp", "path", "snippets", "buffer", "dadbod", "crates" }, + }, + + providers = { + dadbod = { + name = "vim-dadbod-completion", + module = "blink.compat", + opts = {}, + }, + crates = { + name = "crates", + module = "blink.compat", + opts = {}, + }, + }, + }, + + ---@module 'blink.cmp' + ---@type blink.cmp.Config opts = { keymap = { - show = "", - accept = "", - select_prev = { "", "", "" }, - select_next = { "", "", "" }, - - snippet_forward = "", - snippet_backward = "", + [""] = { "scroll_documentation_down", "fallback" }, + [""] = { "scroll_documentation_up", "fallback" }, + [""] = { "select_prev", "fallback" }, + [""] = { "select_next", "fallback" }, + [""] = { "show", "show_documentation", "hide_documentation" }, + [""] = { + function(cmp) + if cmp.is_in_snippet() then + return cmp.accept() + else + return cmp.select_and_accept() + end + end, + "snippet_forward", + "fallback", + }, }, windows = { diff --git a/modules/home/apps/tools/neovim/config/lua/plugins/curl.lua b/modules/home/apps/tools/neovim/config/lua/plugins/curl.lua index 929011d..61340b9 100644 --- a/modules/home/apps/tools/neovim/config/lua/plugins/curl.lua +++ b/modules/home/apps/tools/neovim/config/lua/plugins/curl.lua @@ -2,7 +2,7 @@ return { "oysandvik94/curl.nvim", cmd = { "CurlOpen" }, keys = { - { "co", "CurlOpen", desc = "Open Curl" }, + { "C", "CurlOpen", desc = "Open Curl" }, }, dependencies = { "nvim-lua/plenary.nvim", diff --git a/modules/home/apps/tools/neovim/default.nix b/modules/home/apps/tools/neovim/default.nix index 83d008a..90dfd04 100644 --- a/modules/home/apps/tools/neovim/default.nix +++ b/modules/home/apps/tools/neovim/default.nix @@ -70,6 +70,7 @@ in { markdownlint-cli2 shfmt sqlfluff + go tailwindcss-language-server clang diff --git a/modules/home/wms/hyprland/default.nix b/modules/home/wms/hyprland/default.nix index 81b3d23..536f431 100644 --- a/modules/home/wms/hyprland/default.nix +++ b/modules/home/wms/hyprland/default.nix @@ -97,8 +97,8 @@ in { "${mod},mouse_up,workspace,e-1" # move to the previous ws "${mod},X,exec, ags --toggle-window \"dashboard\"" - "${mod},Print,exec,grim -g \"$(slurp)\" - | wl-copy && wl-paste > ~/Pictures/Screenshots/Screenshot-$(date +%F_%T).png;" - ",Print,exec, grim - | wl-copy" + "${mod},Print,exec,${lib.getExe pkgs.custom.sc}" + "${mod},Shift&Print,exec,${lib.getExe pkgs.wf-recorder} -g \"$(${lib.getExe pkgs.slurp})\" -f out.mp4" "${modshift},O,exec,wl-ocr" "${mod},Period,exec, tofi-emoji" diff --git a/modules/nixos/sites/minio/default.nix b/modules/nixos/sites/minio/default.nix index 40685c4..fa49738 100644 --- a/modules/nixos/sites/minio/default.nix +++ b/modules/nixos/sites/minio/default.nix @@ -27,59 +27,27 @@ in { rootCredentialsFile = config.age.secrets.minio.path; }; - services.nginx.virtualHosts."s3.zoeys.computer" = { + services.nginx.virtualHosts."minio.zoeys.computer" = { forceSSL = true; enableACME = true; - extraConfig = '' - # Allow special characters in headers - ignore_invalid_headers off; - # Allow any size file to be uploaded. - # Set to a value such as 1000m; to restrict file size to a specific value - client_max_body_size 0; - # Disable buffering - proxy_buffering off; - proxy_request_buffering off; - ''; locations."/" = { - proxyPass = "http://localhost${config.services.minio.listenAddress}"; - extraConfig = '' - proxy_set_header Host $http_host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - - proxy_connect_timeout 300; - # Default is HTTP/1, keepalive is only enabled in HTTP/1.1 - proxy_http_version 1.1; - proxy_set_header Connection ""; - chunked_transfer_encoding off; - ''; - }; - locations."/minio/ui" = { proxyPass = "http://localhost${config.services.minio.consoleAddress}"; + extraConfig = '' - rewrite ^/minio/ui/(.*) /$1 break; - proxy_set_header Host $http_host; - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-NginX-Proxy true; - - # This is necessary to pass the correct IP to be hashed - real_ip_header X-Real-IP; - - proxy_connect_timeout 300; - - # To support websockets in MinIO versions released after January 2023 + # To support websocket proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; - # Some environments may encounter CORS errors (Kubernetes + Nginx Ingress) - # Uncomment the following line to set the Origin request to an empty string - # proxy_set_header Origin \'\'; - chunked_transfer_encoding off; ''; }; }; + + services.nginx.virtualHosts."s3.zoeys.computer" = { + forceSSL = true; + enableACME = true; + locations."/" = { + proxyPass = "http://localhost${config.services.minio.listenAddress}"; + }; + }; }; } diff --git a/modules/nixos/ui/fonts/default.nix b/modules/nixos/ui/fonts/default.nix index 9e9a860..1707554 100644 --- a/modules/nixos/ui/fonts/default.nix +++ b/modules/nixos/ui/fonts/default.nix @@ -40,11 +40,11 @@ in { exportGlyphNames = true [buildPlans.IosevkaCustom.variants] - inherits = "ss16" + inherits = "ss01" ''; }) noto-fonts - noto-fonts-cjk + noto-fonts-cjk-sans noto-fonts-emoji jetbrains-mono (nerdfonts.override {fonts = ["Iosevka" "JetBrainsMono"];}) diff --git a/packages/sc/default.nix b/packages/sc/default.nix new file mode 100644 index 0000000..ff23047 --- /dev/null +++ b/packages/sc/default.nix @@ -0,0 +1,28 @@ +{ + writeShellScriptBin, + lib, + pkgs, + ... +}: +writeShellScriptBin "sc" '' + + # Take a screenshot with grim and slurp + ${lib.getExe pkgs.grim} -g "$(${lib.getExe pkgs.slurp})" /tmp/screenshot.png + + # Upload the screenshot and store the response + response=$(${lib.getExe pkgs.curl} -s \ + -X POST \ + -H "Accept: application/json" \ + -H "Authorization: Bearer Z4MYrYtJUb3Y8VvJynkWAw9eBVU3kvvW9gQ50--hROw" \ + -F "file=@/tmp/screenshot.png" \ + https://zoeys.computer/api/images/create) + + # Extract the URL using jq and copy to clipboard + echo "$response" | ${lib.getExe pkgs.jq} -r '.url' | ${pkgs.wl-clipboard}/bin/wl-copy + + # Clean up the temporary file + rm /tmp/screenshot.png + + # Notify user + echo "Screenshot uploaded and URL copied to clipboard!" +'' diff --git a/packages/zen-browser-unwrapped/default.nix b/packages/zen-browser-unwrapped/default.nix index 0598761..96b75af 100644 --- a/packages/zen-browser-unwrapped/default.nix +++ b/packages/zen-browser-unwrapped/default.nix @@ -151,7 +151,7 @@ in buildStdenv.mkDerivation rec { pname = "zen-browser-unwrapped"; - version = "1.0.1-a.12"; + version = "1.0.1-a.13"; src = fetchFromGitHub { owner = "zen-browser"; @@ -159,7 +159,7 @@ in rev = "${version}"; leaveDotGit = true; fetchSubmodules = true; - hash = "sha256-O5S468G+2fF11mnjR8lMSVBOTRe/X5VxfBLAEVh2mA0="; + hash = "sha256-z1YIdulvzkbSa266RZwBbYbeHqY22RvdHAdboR9uqig="; }; firefoxVersion = (lib.importJSON "${src}/surfer.json").version.version; diff --git a/systems/x86_64-linux/earth/default.nix b/systems/x86_64-linux/earth/default.nix index c71809e..3bd9528 100644 --- a/systems/x86_64-linux/earth/default.nix +++ b/systems/x86_64-linux/earth/default.nix @@ -94,7 +94,7 @@ environment.systemPackages = [ pkgs.BeatSaberModManager pkgs.sbctl - pkgs.custom.vesktop + pkgs.vesktop pkgs.mangohud pkgs.transmission_4 inputs.agenix.packages.${system}.agenix diff --git a/systems/x86_64-linux/pluto/default.nix b/systems/x86_64-linux/pluto/default.nix index f4caaf0..e533591 100644 --- a/systems/x86_64-linux/pluto/default.nix +++ b/systems/x86_64-linux/pluto/default.nix @@ -39,6 +39,8 @@ services.gh.enable = true; services.fail2ban.enable = true; + ui.fonts.enable = true; + age.secrets = { zc_key = { owner = "zoeyscomputer-phx";