Issue running Tailwind CSS with Rails on NixOS (devenv.sh setup)

Hi everyone!

I’m new to both NixOS and Ruby on Rails, and I’m currently trying to learn them at the same time.

I’m using the devenv.sh Ruby on Rails example to set up a development environment. When I initialized the Rails app, I used the --css=tailwind flag. However, I get the following error :

Compile initial Tailwind build
run rails tailwindcss:build from “.”
Could not start dynamically linked executable: /home/tortillas/Code/Entrainement/rubyonrails3/.devenv/state/.bundle/ruby/3.2.0/gems/tailwindcss-ruby-4.1.3-x86_64-linux-gnu/exe/x86_64-linux-gnu/tailwindcss
NixOS cannot run dynamically linked executables intended for generic
linux environments out of the box. For more information, see:
Frequently Asked Questions — nix.dev documentation
bin/rails aborted!
Command failed with exit 127: /home/tortillas/Code/Entrainement/rubyonrails3/.devenv/state/.bundle/ruby/3.2.0/gems/tailwindcss-ruby-4.1.3-x86_64-linux-gnu/exe/x86_64-linux-gnu/tailwindcss

Tasks: TOP => tailwindcss:build
(See full trace by running task with --trace)

From what I understand, it seems like the bundled Tailwind binary isn’t compatible with NixOS due to how dynamic linking works. But I’m not sure what the best workaround is.

Is there a recommended way to get Tailwind working in a Rails project on NixOS?
Any help would be appreciated!

Thanks in advance :slightly_smiling_face:

I put default.nix in the directory for my project, and run nix-shell . before starting rails stuff, here’s the content

{ pkgs ? import <nixpkgs> {} }:

(pkgs.buildFHSUserEnv {
  name = "rails-tailwind-env"; # Meaningful name for your Rails project
  targetPkgs = pkgs: with pkgs; [
    zlib              
    libffi            
    libyaml           
    postgresql        
    jq                
    imagemagick       
    pkg-config        
    glibc             
    gcc               
    nodejs            
    nodePackages.tailwindcss
    yarn
    openssl           
    asdf-vm           
    ghostscript
  ];
  multiPkgs = pkgs: with pkgs; [
    zlib              # Libraries needed for multiple architectures
    libffi
    openssl
  ];
  runScript = "zsh"; # Drops into a bash shell
}).env

Notice the nodePackages.tailwindcss line in there. Works for me, I hope it helps you as well.