Skip to content

generated code to offer nix-develop as version manager #3691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

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
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!

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.

1 participant