Skip to content

feat: add NixOS module options **.*ssh.extraConfig as ssh_config lang#32

Open
n0099 wants to merge 1 commit intocalops:mainfrom
n0099:feat/ssh
Open

feat: add NixOS module options **.*ssh.extraConfig as ssh_config lang#32
n0099 wants to merge 1 commit intocalops:mainfrom
n0099:feat/ssh

Conversation

@n0099
Copy link

@n0099 n0099 commented Jan 28, 2026

No description provided.

@gemini-code-assist
Copy link

Summary of Changes

Hello @n0099, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request integrates ssh_config language injection into the Nix language parser, specifically for various SSH-related extraConfig options within NixOS modules. This enhancement aims to provide improved syntax highlighting and a better editing experience for users defining SSH configurations directly in their Nix files.

Highlights

  • SSH Configuration Language Injection: Introduces ssh_config language injection for NixOS module options, enhancing syntax highlighting and developer experience for SSH configurations.
  • Supported NixOS Options: Specifically adds support for services.openssh.extraConfig, programs.ssh.extraConfig, and boot.initrd.network.ssh.extraConfig to benefit from this new language injection.
  • Documentation Update: The README.md has been updated to reflect the new ssh_config language injection capabilities and the relevant NixOS options.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds language injection for several NixOS SSH configuration options, which is a great addition. The changes in the README.md correctly document the new supported options. In queries/nix/injections.scm, I've suggested an improvement to combine the three new injection rules into one, which would reduce code duplication and improve maintainability. Overall, this is a useful feature.

Comment on lines +127 to +144
(binding
attrpath: (_) @_path (#hmts-path? @_path "services" "openssh" "extraConfig")
expression: (_ (string_fragment) @injection.content)
(#set! injection.language "ssh_config")
(#set! injection.combined)
)
(binding
attrpath: (_) @_path (#hmts-path? @_path "programs" "ssh" "extraConfig")
expression: (_ (string_fragment) @injection.content)
(#set! injection.language "ssh_config")
(#set! injection.combined)
)
(binding
attrpath: (_) @_path (#hmts-path? @_path "boot" "initrd" "network" "ssh" "extraConfig")
expression: (_ (string_fragment) @injection.content)
(#set! injection.language "ssh_config")
(#set! injection.combined)
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

These three binding blocks for SSH configurations are very similar and can be combined into a single block. This will reduce code duplication and make the query file more concise and maintainable. You can use the #lua-match? predicate with a regex to match all three attribute paths. This approach keeps all related SSH extraConfig paths in one place.

(binding
  attrpath: (_) @_path (#lua-match? @_path "^(services%.openssh|programs%.ssh|boot%.initrd%.network%.ssh)%.extraConfig$")
  expression: (_ (string_fragment) @injection.content)
  (#set! injection.language "ssh_config")
  (#set! injection.combined)
)

Copy link
Author

@n0099 n0099 Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If lua-match? predicate is enough then why creating the custom

hmts.nvim/plugin/hmts.lua

Lines 120 to 145 in a32cd41

--- Checks if the given capture is located at the end of the given nix path. Every node can be matched by a regex.
---@param match table<string, TSNode>
---@param _ string
---@param bufnr integer
---@param predicate string[]
---@return boolean
local function hmts_path_handler(match, _, bufnr, predicate)
local node = match[predicate[2]]:parent()
local target_path = vim.list_slice(predicate, 3, nil)
while node do
if #target_path == 0 then
return true
end
if node:type() == "binding" then
local path_node = node:field("attrpath")[1]
local is_match = path_diff(target_path, attrpath_to_strings(path_node, bufnr))
if not is_match then
return false
end
end
node = node:parent()
end
return false
end
?

@n0099
Copy link
Author

n0099 commented Jan 28, 2026

n0099 added a commit to n0099/nixos that referenced this pull request Jan 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant