ruby-nix icon indicating copy to clipboard operation
ruby-nix copied to clipboard

How to add new buildInputs

Open fzakaria opened this issue 11 months ago • 1 comments

I'm trying to work on a rails 8 project with tailwindcss. I'm having trouble adding tailwindcss-ruby to my gemset.nix

gemset.nix seems to include every possible platform and tailwindcss-ruby is offered on linux-gnu and linux-musl.

I am failing to run autoPatchElf for the linux-musl variant and it's not clear how to fix this (or if i even should?) relevant: https://github.com/inscapist/ruby-nix/blob/main/modules/gems/expand.nix#L46

# frozen_string_literal: true
source "https://rubygems.org"
gem "tailwindcss", "~> 1.0"
gem "tailwindcss-ruby", "~> 4.0"
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
    systems.url = "github:nix-systems/default";
    bundix = {
      url = "github:inscapist/bundix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    ruby-nix = {
      url = "github:inscapist/ruby-nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = {
    self,
    systems,
    nixpkgs,
    bundix,
    ruby-nix,
    ...
  }: let
    eachSystem = f:
      nixpkgs.lib.genAttrs (import systems) (system:
        f {
          pkgs = nixpkgs.legacyPackages.${system};
          inherit system;
        });
  in {
    formatter = eachSystem ({pkgs, ...}: pkgs.alejandra);

    devShells = eachSystem ({
      pkgs,
      system,
    }: {
      default = let
        rubyNix = ruby-nix.lib pkgs;
        gemset =
          if builtins.pathExists ./gemset.nix
          then import ./gemset.nix
          else {};
        ruby = pkgs.ruby_3_4;
        bundixcli = bundix.packages.${system}.default;
        inherit
          (rubyNix {
            name = "test";
            inherit gemset ruby;
            gemConfig = pkgs.defaultGemConfig // {
              # Not sure how to get it to build here?
              tailwindcss-ruby = attrs: {
                nativeBuildInputs = [pkgs.musl.dev];
              };
            };
          })
          env;
      in
        pkgs.mkShell {
          buildInputs = [
            pkgs.ruby_3_4
            env
            bundixcli
          ];
        };
    });
  };
}

Very grateful that you seemed to have carried the bundix torch forward but I'd love to better understand how to work with platform specific gems with this flake.

fzakaria avatar Feb 04 '25 17:02 fzakaria

@fzakaria I stumbled into this too and have a fix at https://github.com/inscapist/ruby-nix/pull/65 . It works locally for me but don't have the time at the moment to fully test an app out.

cransom avatar Jul 08 '25 19:07 cransom