about summary refs log tree commit diff
path: root/pkgs/development/tools/tailwindcss
diff options
context:
space:
mode:
authorAdam Stephens <adam@valkor.net>2023-06-28 12:11:25 -0400
committerAdam Stephens <adam@valkor.net>2023-06-28 12:22:01 -0400
commit15bcd972ccd4fb30489bd5d38223eee3e3a5b688 (patch)
treeff4f98f629339747886b6b9e097ec9545b680323 /pkgs/development/tools/tailwindcss
parent4bb4d449a7f705bd58997884cccae7fd35b17d98 (diff)
downloadnixlib-15bcd972ccd4fb30489bd5d38223eee3e3a5b688.tar
nixlib-15bcd972ccd4fb30489bd5d38223eee3e3a5b688.tar.gz
nixlib-15bcd972ccd4fb30489bd5d38223eee3e3a5b688.tar.bz2
nixlib-15bcd972ccd4fb30489bd5d38223eee3e3a5b688.tar.lz
nixlib-15bcd972ccd4fb30489bd5d38223eee3e3a5b688.tar.xz
nixlib-15bcd972ccd4fb30489bd5d38223eee3e3a5b688.tar.zst
nixlib-15bcd972ccd4fb30489bd5d38223eee3e3a5b688.zip
tailwindcss-bin: init at 3.3.2
Diffstat (limited to 'pkgs/development/tools/tailwindcss')
-rw-r--r--pkgs/development/tools/tailwindcss/default.nix61
-rwxr-xr-xpkgs/development/tools/tailwindcss/update.sh31
2 files changed, 92 insertions, 0 deletions
diff --git a/pkgs/development/tools/tailwindcss/default.nix b/pkgs/development/tools/tailwindcss/default.nix
new file mode 100644
index 000000000000..d9faf7de900f
--- /dev/null
+++ b/pkgs/development/tools/tailwindcss/default.nix
@@ -0,0 +1,61 @@
+{ lib
+, fetchurl
+, stdenv
+, runCommand
+, tailwindcss-bin
+,
+}:
+let
+  inherit (stdenv.hostPlatform) system;
+  throwSystem = throw "tailwindcss-bin has not been packaged for ${system} yet.";
+
+  plat = {
+    aarch64-darwin = "macos-arm64";
+    aarch64-linux = "linux-arm64";
+    armv7l-linux = "linux-armv7";
+    x86_64-darwin = "macos-x64";
+    x86_64-linux = "linux-x64";
+  }.${system} or throwSystem;
+
+  hash = {
+    aarch64-darwin = "sha256-GXSFDXRBGnEgqfISou85Ivd5npjZB7aMsfrQ2Y+EN0g=";
+    aarch64-linux = "sha256-H2kbeso8/566czi1pEyip5rAgFJQYfdLnAImP25tDe0=";
+    armv7l-linux = "sha256-52XyCmsjuHKs3aGUaAA0uQxGTY06k8gxK/fLYSVdP74=";
+    x86_64-darwin = "sha256-8gwu/sVTjQGE4mSdxtk7ivQyAiRwCuL0Ot/aCrER/as=";
+    x86_64-linux = "sha256-W9JRBB4JDTighDry21ukaFm1H1iKyg7HVG9RJHmIn2Q=";
+  }.${system} or throwSystem;
+in
+stdenv.mkDerivation rec {
+  pname = "tailwindcss-bin";
+  version = "3.3.2";
+
+  src = fetchurl {
+    url = "https://github.com/tailwindlabs/tailwindcss/releases/download/v${version}/tailwindcss-${plat}";
+    inherit hash;
+  };
+
+  dontUnpack = true;
+  dontConfigure = true;
+  dontBuild = true;
+  dontFixup = true;
+
+  installPhase = ''
+    mkdir -p $out/bin
+    cp ${src} $out/bin/tailwindcss
+    chmod 755 $out/bin/tailwindcss
+  '';
+
+  passthru.tests.helptext = runCommand "tailwindcss-test-helptext" { } ''
+    ${tailwindcss-bin}/bin/tailwindcss --help > $out
+  '';
+  passthru.updateScript = ./update.sh;
+
+  meta = with lib; {
+    description = "Command-line tool for the CSS framework with composable CSS classes, standalone CLI";
+    homepage = "https://tailwindcss.com/blog/standalone-cli";
+    license = licenses.mit;
+    sourceProvenance = [ sourceTypes.binaryNativeCode ];
+    maintainers = [ maintainers.adamcstephens ];
+    platforms = platforms.darwin ++ platforms.linux;
+  };
+}
diff --git a/pkgs/development/tools/tailwindcss/update.sh b/pkgs/development/tools/tailwindcss/update.sh
new file mode 100755
index 000000000000..43951b5ec224
--- /dev/null
+++ b/pkgs/development/tools/tailwindcss/update.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p curl gnused jq nix-prefetch
+set -eou pipefail
+
+ROOT="$(dirname "$(readlink -f "$0")")"
+
+CURRENT_VERSION=$(nix-instantiate --eval --strict --json -A tailwindcss-bin.version . | jq -r .)
+LATEST_VERSION=$(curl --fail --silent https://api.github.com/repos/tailwindlabs/tailwindcss/releases/latest | jq --raw-output .tag_name | sed 's/v//')
+sed -i "s/version = \".*\"/version = \"${LATEST_VERSION}\"/" "$ROOT/default.nix"
+
+if [ "$CURRENT_VERSION" = "$LATEST_VERSION" ]; then
+    echo "tailwindcss-bin already at latest version $CURRENT_VERSION, exiting"
+    exit 0
+fi
+
+function updatePlatform() {
+    NIXPLAT=$1
+    TAILWINDPLAT=$2
+    echo "Updating tailwindcss-bin for $NIXPLAT"
+
+    URL="https://github.com/tailwindlabs/tailwindcss/releases/download/v${LATEST_VERSION}/tailwindcss-${TAILWINDPLAT}"
+    HASH=$(nix hash to-sri --type sha256 "$(nix-prefetch-url --type sha256 "$URL")")
+
+    sed -i "s,$NIXPLAT = \"sha256.*\",$NIXPLAT = \"${HASH}\"," "$ROOT/default.nix"
+}
+
+updatePlatform aarch64-darwin macos-arm64
+updatePlatform aarch64-linux linux-arm64
+updatePlatform armv7l-linux linux-armv7
+updatePlatform x86_64-darwin macos-x64
+updatePlatform x86_64-linux linux-x64