Skip to content
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

Nix hygiene #4511

Merged
merged 6 commits into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 53 additions & 26 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/master";
nixpkgs.url = "github:nixos/nixpkgs/release-24.11";

# cross-platform convenience
flake-utils.url = "github:numtide/flake-utils";
Expand All @@ -17,40 +17,67 @@
pkgs = nixpkgs.legacyPackages.${system};

# control versions
ruby = pkgs.ruby_3_3;
llvm = pkgs.llvmPackages_16;
gcc = pkgs.gcc13;
ruby = pkgs.ruby_3_4;
llvm = pkgs.llvmPackages_19;
gcc = pkgs.gcc14;

hook = ''
# get major.minor.0 ruby version
export RUBY_VERSION="$(ruby -e 'puts RUBY_VERSION.gsub(/\d+$/, "0")')"

# make gem install work in-project, compatibly with bundler
export GEM_HOME="$(pwd)/vendor/bundle/ruby/$RUBY_VERSION"

# make bundle work in-project
export BUNDLE_PATH="$(pwd)/vendor/bundle"

# enable calling gem scripts without bundle exec
export PATH="$GEM_HOME/bin:$PATH"

# enable implicitly resolving gems to bundled version
export RUBYGEMS_GEMDEPS="$(pwd)/Gemfile"
'';

deps = [
pkgs.libyaml.dev

# TODO: some gems insist on using `gcc` on Linux, satisfy them for now:
# - json
# - protobuf
# - ruby-prof
gcc
];
in {
devShell = pkgs.llvm.stdenv.mkDerivation {
devShells.default = llvm.stdenv.mkDerivation {
name = "devshell";

buildInputs = with pkgs; [
ruby
libyaml.dev
buildInputs = [ ruby ] ++ deps;

# TODO: some gems insist on using `gcc` on Linux, satisfy them for now:
# - json
# - protobuf
# - ruby-prof
gcc
];
shellHook = hook;
};

shellHook = ''
# get major.minor.0 ruby version
export RUBY_VERSION="$(ruby -e 'puts RUBY_VERSION.gsub(/\d+$/, "0")')"
devShells.ruby33 = llvm.stdenv.mkDerivation {
name = "devshell";

# make gem install work in-project, compatibly with bundler
export GEM_HOME="$(pwd)/vendor/bundle/ruby/$RUBY_VERSION"
buildInputs = [ pkgs.ruby_3_3 ] ++ deps;

# make bundle work in-project
export BUNDLE_PATH="$(pwd)/vendor/bundle"
shellHook = hook;
};

devShells.ruby32 = llvm.stdenv.mkDerivation {
name = "devshell";

buildInputs = [ pkgs.ruby_3_2 ] ++ deps;

shellHook = hook;
};

devShells.ruby31 = llvm.stdenv.mkDerivation {
name = "devshell";

# enable calling gem scripts without bundle exec
export PATH="$GEM_HOME/bin:$PATH"
buildInputs = [ pkgs.ruby_3_1 ] ++ deps;

# enable implicitly resolving gems to bundled version
export RUBYGEMS_GEMDEPS="$(pwd)/Gemfile"
'';
shellHook = hook;
};
}
);
Expand Down
2 changes: 1 addition & 1 deletion spec/datadog/tracing/contrib_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'spec_helper'

RSpec.describe Datadog::Tracing::Contrib do
root = Gem::Specification.find_by_name('datadog').gem_dir
root = Gem.loaded_specs['datadog'].gem_dir

# Our module names are camelized directory name with some exceptions
mapping = {
Expand Down
Loading