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

set GEM_HOME to allow repo as flake input #100

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

Conversation

cscorley
Copy link

@cscorley cscorley commented Jan 30, 2023

Sets GEM_HOME, which allows this repository's default.nix to be used as a flake input with Ruby 3.x:

Setting GEM_HOME is also performed in the nixpkgs build

Example use within a flake using this PR, using the nixpkgs-ruby to override:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
    nixpkgs-ruby.url = "github:bobvanderlinden/nixpkgs-ruby";
    nixpkgs-ruby.inputs.nixpkgs.follows = "nixpkgs";
    flake-utils.url = "github:numtide/flake-utils";
    bundix-src = {
      url = "github:cscorley/bundix/add-gem-home";
      flake = false;
    };
  };

  outputs = { self, nixpkgs, nixpkgs-ruby, flake-utils, bundix-src }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system};
        rubyVersion = nixpkgs.lib.strings.removePrefix "ruby-"
          (nixpkgs.lib.fileContents ./.ruby-version);
        ruby = nixpkgs-ruby.packages.${system}."ruby-${rubyVersion}";

        gems = pkgs.bundlerEnv {
          name = "gemset";
          inherit ruby;
          gemfile = ./Gemfile;
          lockfile = ./Gemfile.lock;
          gemset = ./gemset.nix;
          groups = [ "default" "production" "development" "test" ];
        };

        # Override bundix to use the later ruby
        bundler = pkgs.bundler.override { inherit ruby; };
        bundix = pkgs.callPackage bundix-src { inherit pkgs ruby bundler; };
      in {
        devShells.default =
          pkgs.mkShell { buildInputs = [ gems ruby bundix ]; };
      });
}

@cscorley cscorley changed the title set GEM_HOME set GEM_HOME to allow flake inputs Jan 30, 2023
@cscorley cscorley changed the title set GEM_HOME to allow flake inputs set GEM_HOME to allow repo as flake input Jan 30, 2023
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.

None yet

1 participant