Skip to content

Conversation

@Jeffrey04
Copy link

@Jeffrey04 Jeffrey04 commented Jul 27, 2025

Motivation

I was having problem with setting up ruby-lsp with nix develop, and turned to the discussion board #3683 for help. After getting some tips from @vinistock I decided to see if I could submit a patch

Implementation

I am very new to both nix and vscode extension development, so most of the work is done by gemini-cli. From what I can tell, here are the changes:

  1. Defining a new version manager type nix-develop
  2. (possibly need revision) For now, reuse customRubyCommand to define the directory holding the flake.nix file
  3. By referring to vscode/src/ruby/custom.ts, create a version for nixDevelop.ts, that fires the command as follows
`nix develop /Users/jeffrey04/Projects/home-manager/devenvs/ruby-3.3 --command ruby -EUTF-8:UTF-8 '/Users/jeffrey04/.vscode-oss/extensions/shopify.ruby-lsp-0.9.31/activation.rb'

Automated Tests

I need help on this one

Manual Tests

this is my flake.nix

# flake.nix
{
  description = "A cross-platform Ruby development environment";

  # Define the inputs for this flake, primarily nixpkgs.
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
  };

  # Define the outputs of this flake.
  outputs = { self, nixpkgs }:
    let
      # A list of systems we want to support.
      supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];

      # A helper function to generate an attribute set for each system.
      forEachSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
        pkgs = nixpkgs.legacyPackages.${system};
        system = system;
      });

    in
    {
      # Generate a `devShell` for each of the `supportedSystems`.
      devShells = forEachSystem ({ pkgs, system }:
      {
        default = pkgs.mkShell {
          # A name for the shell environment.
          name = "ruby-3.3";

          # List of packages to be available in the development environment.
          buildInputs = with pkgs; [
            # fish is kept so that fish-specific completions from other
            # packages can be made available.
            fish
            # Git is needed for fetching gems from git repositories.
            git
            # The Ruby interpreter.
            ruby
            # Bundler for managing Ruby gems.
            bundler
            # Common dependencies for building native extensions.
            cmake
            findutils
            gcc
            gnumake
            # Libraries often required by gems.
            openssl
            pkg-config
            libmysqlclient
            shared-mime-info
            re2
            readline
            zlib
          ] ++ lib.optionals stdenv.isDarwin [
            # Add macOS-specific dependencies.
            libiconv
          ];

          # This hook now correctly detects the parent shell (e.g., fish)
          # and works for both `nix develop` and `direnv`.
          shellHook = ''
            # Ruby-specific setup
            export FREEDESKTOP_MIME_TYPES_PATH="${pkgs.shared-mime-info}/share/mime/packages/freedesktop.org.xml"
            export PATH=$HOME/.local/share/gem/ruby/3.3.0/bin:$PATH
          '';
        };
      });
    };
}

and this is my workspace settings.json

{
  "rubyLsp.rubyVersionManager": {
    "identifier": "nix-develop"
  },
  "rubyLsp.customRubyCommand": "/Users/jeffrey04/Projects/home-manager/devenvs/ruby-3.3"
}

@Jeffrey04 Jeffrey04 requested a review from a team as a code owner July 27, 2025 10:03
@graphite-app
Copy link

graphite-app bot commented Jul 27, 2025

How to use the Graphite Merge Queue

Add the label graphite-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

@Jeffrey04
Copy link
Author

I have signed the CLA!

@github-actions
Copy link
Contributor

This pull request is being marked as stale because there was no activity in the last 2 months

@github-actions github-actions bot added the Stale label Sep 29, 2025
@github-actions github-actions bot closed this Oct 13, 2025
@Jeffrey04
Copy link
Author

? @vinistock

@Jeffrey04
Copy link
Author

any feedback?

@st0012
Copy link
Member

st0012 commented Oct 23, 2025

Hi @Jeffrey04, the main concern for us is that we do not use and aren't familiar with nix-develop. And that means 1) we can't effectively test and review this change and 2) it'd be hard for us to maintain this going forward.
So at the moment we don't plan to add take this PR as is. But if you can come up with a PR to improve the custom manager so that it works with nix-develop while being compatible with other existing use cases, we'll probably accept it 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants