Hello, I am lost and need some help.
I have a simple Nix Flake that creates a dev shell like this:
# flake.nix
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { nixpkgs, ... }:
let
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
tailwindcss-v4-beta = pkgs.callPackage ./tailwindcss-v4-beta.nix {};
in {
devShells.${system}.default = pkgs.mkShell {
packages = with pkgs; [
python313
# python313Packages.setuptools
python313Packages.jinja2
python313Packages.livereload
tailwindcss-v4-beta
];
};
};
}
The tailwindcss cli tool (v3) is available in nixpkgs, see source. I tried to take this as a base and package the v4 executable from here myself. That’s my first try ever to do such a thing and it didn’t work out well. Here’s what I have:
# tailwindcss-v4-beta.nix
{
lib,
fetchurl,
stdenv,
autoPatchelfHook,
}:
stdenv.mkDerivation rec {
pname = "tailwindcss";
version = "4.0.0-beta.9";
src = fetchurl {
url = "https://github.com/tailwindlabs/tailwindcss/releases/download/v${version}/tailwindcss-linux-x64";
# How to obtain hash:
# nix-prefetch-url --type sha256 https://github.com/tailwindlabs/tailwindcss/releases/download/v4.0.0-beta.9/tailwindcss-linux-x64
# nix hash to-sri --type sha256 <hash-from-previous-command>
hash = "sha256-6UCE1kQDxzqS2Epi73qLwySgOO3k2Mmj7yHdHucPP1c=";
};
nativeBuildInputs = [autoPatchelfHook];
dontUnpack = true;
dontConfigure = true;
dontBuild = true;
# dontFixup = true;
installPhase = ''
mkdir -p $out/bin
cp ${src} $out/bin/tailwindcss
chmod 755 $out/bin/tailwindcss
'';
meta = with lib; {
description = "Tailwind CSS v4 Beta CLI";
homepage = "https://tailwindcss.com";
license = licenses.mit;
sourceProvenance = [sourceTypes.binaryNativeCode];
platforms = ["x86_64-linux"];
};
}
When I download the v3 executable from Github manually, I can execute it. But when I try to do the same with v4, I get:
Could not start dynamically linked executable: ./twv4
NixOS cannot run dynamically linked executables intended for generic
linux environments out of the box. For more information, see:
https://nix.dev/permalink/stub-ld
That’s why I added autoPatchelfHook
.
At first this seems to work. I get a tailwindcss
executable available in my shell. But when I try to run it, very weird things happen:
new-website on main [+] via 🐍 v3.13.1 via ❄️ impure (nix-shell-env)
❯ tailwindcss --version
1.1.43
new-website on main [+] via 🐍 v3.13.1 via ❄️ impure (nix-shell-env)
❯ tailwindcss
Bun is a fast JavaScript runtime, package manager, bundler, and test runner. (1.1.43+76800b049)
Usage: bun <command> [...flags] [...args]
Commands:
run ./my-script.ts Execute a file with Bun
lint Run a package.json script
test Run unit tests with Bun
x prettier Execute a package binary (CLI), installing if needed (bunx)
repl Start a REPL session with Bun
exec Run a shell script directly with Bun
install Install dependencies for a package.json (bun i)
add @shumai/shumai Add a dependency to package.json (bun a)
remove browserify Remove a dependency from package.json (bun rm)
update hono Update outdated dependencies
outdated Display latest versions of outdated dependencies
link [<package>] Register or link a local npm package
unlink Unregister a local npm package
publish Publish a package to the npm registry
patch <pkg> Prepare a package for patching
pm <subcommand> Additional package management utilities
build ./a.ts ./b.jsx Bundle TypeScript & JavaScript into a single file
init Start an empty Bun project from a blank template
create vite Create a new project from a template (bun c)
upgrade Upgrade to latest version of Bun.
<command> --help Print help text for command.
Learn more about Bun: https://bun.sh/docs
Join our Discord community: https://bun.sh/discord
It shows the version and help output of Bun, instead of tailwindcss. I assume the tailwindcss executable is built using Bun. And here someone ran into a similar issue.
Can someone explain to me what is happening here? And if there’s a solution to this?