diff --git a/home/common/default.nix b/home/common/default.nix index 979ebe2..3a9bdc5 100644 --- a/home/common/default.nix +++ b/home/common/default.nix @@ -12,7 +12,9 @@ ../gnome ./dnote.nix ../modules/zed + ./secrets.nix inputs.hastebin.nixosModules.hm + inputs.agenix.homeManagerModules.default ]; # This value determines the Home Manager release that your configuration is @@ -212,65 +214,96 @@ }; initContent = '' . "${config.xdg.configHome}/zsh/init" + . "${config.age.secrets.context7.path}" ''; }; - lazygit = { - enable = true; - settings = { - gui = { - nerdFontsVersion = "3"; - }; - git = { - showUntrackedFiles = "all"; - branchLogCmd = "git log {{branchName}} --first-parent --color=always --pretty=format:'%Cgreen%h%Creset %Cblue%aN%Creset %C(cyan)%<(14)%ar%Creset %s' --abbrev-commit"; - overrideGpg = true; - }; - os = { - edit = "\${EDITOR} -- {{filename}}"; - editAtLine = "\${EDITOR} -- {{filename}}:{{line}}"; - editAtLineAndWait = "\${EDITOR} --wait -- {{filename}}:{{line}}"; - openDirInEditor = "\${EDITOR} -- {{dir}}"; - }; - promptToReturnFromSubprocess = false; - keybinding = { - universal = { - nextItem = ""; - prevItem = ""; + lazygit = + let + getBaseBranch = pkgs.writeShellScriptBin "git-base-branch" '' + current_branch="$(git rev-parse --abbrev-ref HEAD)" + if [[ "$current_branch" =~ -review$ ]]; then + echo "''${current_branch%-review}" + else + git config get init.defaultBranch + fi + ''; + escapeGoTemplate = builtins.replaceStrings [ "{{" "}}" ] [ ''{{"{{"}}'' ''{{"}}"}}'' ]; + in + { + enable = true; + settings = { + gui = { + nerdFontsVersion = "3"; }; - commits = { - moveDownCommit = ""; - moveUpCommit = ""; + git = { + showUntrackedFiles = "all"; + branchLogCmd = "git log {{branchName}} --first-parent --color=always --pretty=format:'%Cgreen%h%Creset %Cblue%aN%Creset %C(cyan)%<(14)%ar%Creset %s' --abbrev-commit"; + overrideGpg = true; }; + os = { + edit = "\${EDITOR} -- {{filename}}"; + editAtLine = "\${EDITOR} -- {{filename}}:{{line}}"; + editAtLineAndWait = "\${EDITOR} --wait -- {{filename}}:{{line}}"; + openDirInEditor = "\${EDITOR} -- {{dir}}"; + }; + promptToReturnFromSubprocess = false; + keybinding = { + universal = { + nextItem = ""; + prevItem = ""; + }; + commits = { + moveDownCommit = ""; + moveUpCommit = ""; + }; + }; + customCommands = [ + { + key = ""; + context = "global"; + command = '' + git push --force-with-lease --set-upstream origin "{{.SelectedLocalBranch.Name}}" && + gh pr create --title "{{.SelectedLocalBranch.Name}}" -B "$(${lib.getExe getBaseBranch})" --fill || + (git log --reverse --no-merges --pretty='- %s' master..HEAD | gh pr edit --body-file -); + gh pr view --web + ''; + } + { + key = "N"; + context = "localBranches"; + prompts = [ + { + type = "input"; + title = "New Branch Name:"; + key = "BranchName"; + initialValue = "{{.SelectedLocalBranch.Name}}-review"; + } + ]; + command = '' + git checkout -b {{.Form.BranchName | quote}} + ''; + } + { + key = "G"; + context = "localBranches"; + prompts = [ + { + type = "menuFromCommand"; + title = "PR:"; + key = "pr"; + command = escapeGoTemplate "gh pr list --search '-author:@me' --json number,title,author,updatedAt -t '{{range .}}{{tablerow .number .title .author.login}}{{end}}'"; + filter = "(?[0-9]+)(?.*)"; + labelFormat = "{{ .rest }}"; + valueFormat = "{{ .pr_number }}"; + } + ]; + command = '' + gh pr checkout {{.Form.pr | quote}} + ''; + } + ]; }; - customCommands = [ - { - key = ""; - context = "global"; - command = '' - git push --force-with-lease --set-upstream origin "{{.SelectedLocalBranch.Name}}" && - gh pr create --title "{{.SelectedLocalBranch.Name}}" -B "$(git config get init.defaultBranch)" --fill || - (git log --reverse --no-merges --pretty='- %s' master..HEAD | gh pr edit --body-file -); - gh pr view --web - ''; - } - { - key = "N"; - context = "localBranches"; - prompts = [ - { - type = "input"; - title = "New Branch Name:"; - key = "BranchName"; - initialValue = "{{.SelectedLocalBranch.Name}}_review"; - } - ]; - command = '' - git checkout -b {{.Form.BranchName | quote}} - ''; - } - ]; }; - }; obs-studio.enable = true; ssh = { enable = true; @@ -589,6 +622,7 @@ programs.rbw.enable = true; programs.rclone.enable = true; + programs.firefox.enable = true; xdg.configFile."opencode/opencode.jsonc".text = builtins.toJSON { "$schema" = "https://opencode.ai/config.json"; @@ -597,6 +631,57 @@ agent = { explore.model = "opencode/minimax-m2.1"; }; + lsp = { + ruby-lsp = { + initialization = { + enabledFeatures = { + codeActions = true; + codeLens = true; + completion = true; + definition = true; + diagnostics = true; + documentHighlights = true; + documentLink = true; + documentSymbols = true; + foldingRanges = true; + formatting = false; + hover = true; + inlayHint = true; + onTypeFormatting = true; + selectionRanges = true; + semanticHighlighting = true; + signatureHelp = true; + typeHierarchy = true; + workspaceSymbol = true; + }; + linters = [ "standard" ]; + }; + extensions = [ + ".rb" + ".erb" + ".haml" + ]; + command = [ + "bundle" + "exec" + "ruby-lsp" + "--lsp" + ]; + }; + rubocop = { + command = [ + "bundle" + "exec" + "rubocop" + "--lsp" + ]; + extensions = [ + ".rb" + ".erb" + ".haml" + ]; + }; + }; mcp = { memory = { type = "local"; @@ -617,6 +702,14 @@ (lib.getExe pkgs-unstable.chromium) ]; }; + context7 = { + type = "remote"; + url = "https://mcp.context7.com/mcp"; + headers = { + CONTEXT7_API_KEY = "{env:CONTEXT7_API_KEY}"; + }; + enabled = true; + }; }; }; diff --git a/home/common/secrets.nix b/home/common/secrets.nix new file mode 100644 index 0000000..5e97954 --- /dev/null +++ b/home/common/secrets.nix @@ -0,0 +1,15 @@ +{ lib, ... }: +{ + age.secrets = lib.listToAttrs ( + map + (secret: { + name = secret; + value = { + file = ../../secrets/${secret}.age; + }; + }) + [ + "context7" + ] + ); +} diff --git a/secrets/context7.age b/secrets/context7.age new file mode 100644 index 0000000..9b7717d --- /dev/null +++ b/secrets/context7.age @@ -0,0 +1,9 @@ +age-encryption.org/v1 +-> ssh-ed25519 osOCZA wDdoFnPs/OUczxmB6WgzSQ0HtguSmIsX1di6gH5guFM +b6PAgnY1Kki92V+ky+/Cuq5UezYdchS3g5MtqtRxDMQ +-> ssh-ed25519 DFiohQ oZmlLt1Em4PnIZAUwqxed5EH1ZG/Bkm3FPiZI9uxVUY +/dAEjEHp9mcygfYj+taalhqjJ6ywkWu45ymwnmtlzaY +-> ssh-ed25519 hRPDBg MKpKkBgl0baf6qJh940ekh1z/0bKbzYTBb9In2yVd3Q +1uX/3y+A/a+vxSl41DlUnZVdh6lpDYFwunzLV3DRblk +--- KQncWqjni5UN+D3I1OSWdKxVf5/UiLBUNBwFMG/1+mg +\Xz̮\~.fw@ IqvEiMǛE׀f9j< Y`< ]e \ No newline at end of file diff --git a/secrets/secrets.nix b/secrets/secrets.nix index 4a1f16d..2ee7eb0 100644 --- a/secrets/secrets.nix +++ b/secrets/secrets.nix @@ -41,4 +41,5 @@ in "glance/reddit/app-secret.age".publicKeys = users ++ [ freun-dev ]; "actual.age".publicKeys = users ++ [ freun-dev ]; "voidauth.age".publicKeys = users ++ [ freun-dev ]; + "context7.age".publicKeys = users ++ [ radish ]; }