From e8c2411e8232fb984f47794b2630ee5abacf6216 Mon Sep 17 00:00:00 2001 From: figsoda Date: Thu, 17 Aug 2023 12:44:23 -0400 Subject: [PATCH 1/2] tailwindcss: set meta.mainProgram --- pkgs/development/tools/tailwindcss/default.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/development/tools/tailwindcss/default.nix b/pkgs/development/tools/tailwindcss/default.nix index c1675a806aea..c05fbdc0c5f8 100644 --- a/pkgs/development/tools/tailwindcss/default.nix +++ b/pkgs/development/tools/tailwindcss/default.nix @@ -56,6 +56,7 @@ stdenv.mkDerivation rec { license = licenses.mit; sourceProvenance = [ sourceTypes.binaryNativeCode ]; maintainers = [ maintainers.adamcstephens ]; + mainProgram = "tailwindcss"; platforms = platforms.darwin ++ platforms.linux; }; } From 6208a37211d3abac4b922b4e9d3f01d0e3c0d74f Mon Sep 17 00:00:00 2001 From: figsoda Date: Thu, 17 Aug 2023 10:51:28 -0400 Subject: [PATCH 2/2] oranda: 0.2.0 -> 0.3.0 Diff: https://github.com/axodotdev/oranda/compare/v0.2.0...v0.3.0 Changelog: https://github.com/axodotdev/oranda/blob/v0.3.0/CHANGELOG.md --- pkgs/applications/misc/oranda/default.nix | 19 +++++-- pkgs/applications/misc/oranda/tailwind.patch | 52 ++++++++++++++++++++ 2 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 pkgs/applications/misc/oranda/tailwind.patch diff --git a/pkgs/applications/misc/oranda/default.nix b/pkgs/applications/misc/oranda/default.nix index 759a929e4988..15e3ec3774a3 100644 --- a/pkgs/applications/misc/oranda/default.nix +++ b/pkgs/applications/misc/oranda/default.nix @@ -5,20 +5,28 @@ , oniguruma , stdenv , darwin +, tailwindcss }: rustPlatform.buildRustPackage rec { pname = "oranda"; - version = "0.2.0"; + version = "0.3.0"; src = fetchFromGitHub { owner = "axodotdev"; repo = "oranda"; rev = "v${version}"; - hash = "sha256-1pkAIz6Zh0ArIDmRSLHTnIgySWdxrDx0amTkdZhY6vY="; + hash = "sha256-R9b2T/Em3s4hwcXa3l2i8A3w/aBu0Dz+izFcE4Q8J/4="; }; - cargoHash = "sha256-TKpPAzqwWBH2dlBNvU2kuqqOVu5WhSnSR3wW5FsW7yk="; + cargoHash = "sha256-0eH7LZfO5/YgXP9Hom7pgALKFksSTAiczgT7rrNnqow="; + + patches = [ + # oranda-generate-css which is used in the build script tries to download + # tailwindcss from the internet, so we have to patch it to use the + # tailwindcss from nixpkgs + ./tailwind.patch + ]; nativeBuildInputs = [ pkg-config @@ -33,10 +41,15 @@ rustPlatform.buildRustPackage rec { # requires internet access checkFlags = [ "--skip=build" + "--skip=integration" ]; env = { RUSTONIG_SYSTEM_LIBONIG = true; + TAILWINDCSS = lib.getExe tailwindcss; + } // lib.optionalAttrs stdenv.isDarwin { + # without this, tailwindcss fails with OpenSSL configuration error + OPENSSL_CONF = ""; }; meta = with lib; { diff --git a/pkgs/applications/misc/oranda/tailwind.patch b/pkgs/applications/misc/oranda/tailwind.patch new file mode 100644 index 000000000000..6a1ffb3c959f --- /dev/null +++ b/pkgs/applications/misc/oranda/tailwind.patch @@ -0,0 +1,52 @@ +--- a/generate-css/src/lib.rs ++++ b/generate-css/src/lib.rs +@@ -28,48 +28,7 @@ pub fn default_css_output_dir() -> Utf8PathBuf { + } + + pub fn build_css(dist_dir: &Utf8Path) -> Result<()> { +- // Fetch our cache dir +- let project_dir = ProjectDirs::from("dev", "axo", "oranda") +- .expect("Unable to create cache dir for downloading Tailwind!"); +- let cache_dir = project_dir.cache_dir(); +- // Figure out our target "double" (tailwind has weird naming around this) +- let double = match (env::consts::OS, env::consts::ARCH) { +- ("linux", "x86_64") => "linux-x64", +- ("linux", "aarch64") => "linux-arm64", +- ("linux", "arm") => "linux-armv7", +- ("macos", "x86_64") => "macos-x64", +- ("macos", "aarch64") => "macos-arm64", +- ("windows", "x86_64") => "windows-x64.exe", +- ("windows", "aarch64") => "windows-arm64.exe", +- _ => "linux-x64", +- }; +- let mut binary_path = Utf8PathBuf::from(cache_dir.display().to_string()); +- LocalAsset::create_dir_all(&binary_path)?; +- binary_path.push(format!("tailwindcss-{double}")); +- if !binary_path.exists() { +- // Fetch the binary from GitHub if it doesn't exist +- tracing::info!("Fetching Tailwind binary from GitHub release..."); +- let url = format!( +- "https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-{double}" +- ); +- let handle = tokio::runtime::Handle::current(); +- let response = handle.block_on(reqwest::get(url))?; +- let bytes = handle.block_on(response.bytes())?; +- let file = LocalAsset::new(&binary_path, Vec::from(bytes))?; +- file.write( +- binary_path +- .parent() +- .expect("Tailwind binary path has no parent!?"), +- )?; +- +- // On non-Windows platforms, we need to mark the file as executable +- #[cfg(target_family = "unix")] +- { +- use std::os::unix::prelude::PermissionsExt; +- let user_execute = std::fs::Permissions::from_mode(0o755); +- std::fs::set_permissions(&binary_path, user_execute)?; +- } +- } ++ let binary_path = env!("TAILWINDCSS"); + + tracing::info!("Building oranda CSS using Tailwind..."); + let css_src_path = manifest_dir().join(CSS_SRC_PATH);