From bd378e1359ac57f8da8eab902fff88ade3c08d30 Mon Sep 17 00:00:00 2001 From: Ethan Girouard Date: Thu, 11 Jun 2026 19:21:48 -0400 Subject: [PATCH] Add daisyui Add wrapper scripts and fetch JS for nix compatibility --- flake.nix | 40 ++++++++++++++++++++++++++++++++++ style/daisyui-theme-wrapper.js | 18 +++++++++++++++ style/daisyui-wrapper.js | 18 +++++++++++++++ style/tailwind.css | 8 +++++++ 4 files changed, 84 insertions(+) create mode 100644 style/daisyui-theme-wrapper.js create mode 100644 style/daisyui-wrapper.js diff --git a/flake.nix b/flake.nix index 2c27d49..4bafdb0 100644 --- a/flake.nix +++ b/flake.nix @@ -38,6 +38,40 @@ ]; }; + daisyui-version = "v5.5.23"; + + daisyui = pkgs.stdenvNoCC.mkDerivation { + name = "daisyui"; + + src = pkgs.fetchurl { + url = "https://github.com/saadeghi/daisyui/releases/download/${daisyui-version}/daisyui.js"; + sha256 = "sha256-IHsOrki86HGPW02ERe3gXTatzWJjjQ6EPQ3eodW/yXw="; + }; + + unpackPhase = "true"; + + installPhase = '' + mkdir "$out" + cp "$src" "$out/daisyui.js" + ''; + }; + + daisyui-theme = pkgs.stdenvNoCC.mkDerivation { + name = "daisyui-theme"; + + src = pkgs.fetchurl { + url = "https://github.com/saadeghi/daisyui/releases/download/${daisyui-version}/daisyui-theme.js"; + sha256 = "sha256-p/ofznslFSKQ87UuP4XV4bvU7xmAkci/WRlAznJt9MY="; + }; + + unpackPhase = "true"; + + installPhase = '' + mkdir "$out" + cp "$src" "$out/daisyui-theme.js" + ''; + }; + rust = pkgs.rust-bin.stable.latest.default.override { targets = [ "wasm32-unknown-unknown" ]; }; @@ -52,6 +86,9 @@ in rec { devShells.default = pkgs.mkShell { + DAISYUI_PATH = "${daisyui}"; + DAISYUI_THEME_PATH = "${daisyui-theme}"; + buildInputs = with pkgs; [ rust ] ++ build-pkgs; @@ -63,6 +100,9 @@ name = "libretunes"; src = ./.; + DAISYUI_PATH = "${daisyui}"; + DAISYUI_THEME_PATH = "${daisyui-theme}"; + cargoLock.lockFile = ./Cargo.lock; nativeBuildInputs = with pkgs; [ diff --git a/style/daisyui-theme-wrapper.js b/style/daisyui-theme-wrapper.js new file mode 100644 index 0000000..7265523 --- /dev/null +++ b/style/daisyui-theme-wrapper.js @@ -0,0 +1,18 @@ +let daisyui_theme = null; + +try { + daisyui_theme = require('daisyui/theme'); +} catch (e) { } + +if (daisyui_theme == null) { + try { + daisyui_theme = require(`${process.env.DAISYUI_THEME_PATH}/daisyui-theme.js`); + } catch (e) { } +} + +if (daisyui_theme == null) { + console.error('Could not find DaisyUI/theme'); + throw new Error('Could not find DaisyUI/theme'); +} + +export default daisyui_theme.default || daisyui_theme; diff --git a/style/daisyui-wrapper.js b/style/daisyui-wrapper.js new file mode 100644 index 0000000..52873dd --- /dev/null +++ b/style/daisyui-wrapper.js @@ -0,0 +1,18 @@ +let daisyui = null; + +try { + daisyui = require('daisyui'); +} catch (e) { } + +if (daisyui == null) { + try { + daisyui = require(`${process.env.DAISYUI_PATH}/daisyui.js`); + } catch (e) { } +} + +if (daisyui == null) { + console.error('Could not find DaisyUI'); + throw new Error('Could not find DaisyUI'); +} + +export default daisyui.default || daisyui; diff --git a/style/tailwind.css b/style/tailwind.css index 906ef8e..a37e38a 100644 --- a/style/tailwind.css +++ b/style/tailwind.css @@ -1,3 +1,11 @@ @import "tailwindcss"; + +@plugin "./daisyui-wrapper.js" { + themes: all; +}; + +@plugin "./daisyui-theme-wrapper.js" { +}; + @source not "*"; @source "./src/**/*.{rs,html,css}";