diff --git a/pkgs/by-name/ir/ironcalc/0001-FIX-test-message.patch b/pkgs/by-name/ir/ironcalc/0001-FIX-test-message.patch new file mode 100644 index 000000000000..bb7f1fae5d7b --- /dev/null +++ b/pkgs/by-name/ir/ironcalc/0001-FIX-test-message.patch @@ -0,0 +1,26 @@ +From 29add00f50083f14b52f8fd18ee1913dacbb3271 Mon Sep 17 00:00:00 2001 +From: phanirithvij +Date: Mon, 16 Mar 2026 14:16:24 +0530 +Subject: [PATCH] FIX: test message + +Signed-off-by: phanirithvij +--- + base/src/test/user_model/test_to_from_bytes.rs | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/base/src/test/user_model/test_to_from_bytes.rs b/base/src/test/user_model/test_to_from_bytes.rs +index f9a9a2f..508a589 100644 +--- a/base/src/test/user_model/test_to_from_bytes.rs ++++ b/base/src/test/user_model/test_to_from_bytes.rs +@@ -25,7 +25,7 @@ fn errors() { + let model_bytes = "Early in the morning, late in the century, Cricklewood Broadway.".as_bytes(); + assert_eq!( + &UserModel::from_bytes(model_bytes, "en").unwrap_err(), +- "Error parsing workbook: invalid packing" ++ "Error parsing workbook: bitcode error" + ); + } + +-- +2.53.0 + diff --git a/pkgs/by-name/ir/ironcalc/docs.nix b/pkgs/by-name/ir/ironcalc/docs.nix new file mode 100644 index 000000000000..9f0a5cbc9cf0 --- /dev/null +++ b/pkgs/by-name/ir/ironcalc/docs.nix @@ -0,0 +1,42 @@ +{ + lib, + buildNpmPackage, + ironcalc, + gitMinimal, +}: + +buildNpmPackage { + pname = "ironcalc-docs"; + inherit (ironcalc) version src; + + postPatch = '' + cd docs + ''; + + npmDepsHash = "sha256-lH4HUUiVSGcF/5cSse0l2ZWial3tkwOO8peb5Wl35rI="; + + nativeBuildInputs = [ + gitMinimal + ]; + + # https://discourse.nixos.org/t/nix-build-of-vuepress-project-is-slow-or-hangs/56521/5 + buildPhase = '' + runHook preBuild + + # Icons are expected in public/ + mkdir -p src/public + cp -v src/*.svg src/*.png src/public/ || true + + npm run build > tmp 2>&1 + runHook postBuild + ''; + + installPhase = '' + mkdir -p $out/share/doc/ironcalc + cp -r src/.vitepress/dist/* $out/share/doc/ironcalc/ + ''; + + meta = ironcalc.meta // { + description = "Documentation for IronCalc"; + }; +} diff --git a/pkgs/by-name/ir/ironcalc/frontend.nix b/pkgs/by-name/ir/ironcalc/frontend.nix new file mode 100644 index 000000000000..d729b5943b8b --- /dev/null +++ b/pkgs/by-name/ir/ironcalc/frontend.nix @@ -0,0 +1,183 @@ +{ + rustPlatform, + buildNpmPackage, + python3, + pkg-config, + binaryen, + bzip2, + zstd, + esbuild, + wasm-bindgen-cli_0_2_108, + wasm-pack, + nodejs, + typescript, + lld, + writableTmpDirAsHomeHook, + + ironcalc, +}: +let + inherit (ironcalc) + version + src + cargoHash + ; + + wasm = rustPlatform.buildRustPackage { + pname = "ironcalc-wasm"; + inherit + version + src + cargoHash + ; + + nativeBuildInputs = [ + binaryen + pkg-config + python3 + wasm-bindgen-cli_0_2_108 + wasm-pack + nodejs + typescript + lld + writableTmpDirAsHomeHook + ]; + + buildInputs = [ + bzip2 + zstd + ]; + + buildPhase = '' + cd bindings/wasm + make tests + + wasm-pack build --target web --scope ironcalc --release + cp README.pkg.md pkg/README.md + tsc types.ts --target esnext --module esnext + python3 fix_types.py + rm -f types.js + + # wasm-pack generates a package.json, we must provide one + cat > pkg/package.json < ../../bindings/wasm/pkg/package.json + ''; + + npmDepsHash = "sha256-jPnUUEOjW9WHVjpBH/qKB4P5RuMI0uvjog8C41cPQdY="; + + preConfigure = '' + cp -rv ${wasm}/. ../../bindings/wasm/pkg/ + ''; + + buildPhase = '' + npm run build + ''; + + installPhase = '' + mkdir -p $out + cp -r . $out + ''; + + __structuredAttrs = true; + strictDeps = true; + + meta = ironcalc.meta // { + description = "Ironcalc frontend widget package"; + }; + }; + + frontend = buildNpmPackage { + pname = "ironcalc-frontend"; + inherit version src; + sourceRoot = "source"; + + postPatch = '' + cd webapp/app.ironcalc.com/frontend + chmod -R u+w ../../.. + + # wasm location fix + mkdir -p ../../../bindings/wasm/pkg + cp -rv ${wasm}/. ../../../bindings/wasm/pkg/ + + rm -rf ../../IronCalc + cp -r ${widget} ../../IronCalc + chmod -R u+w ../../IronCalc + + substituteInPlace src/components/WorkbookTitle.tsx \ + --replace-warn 'onInput={handleChange}' 'onChange={handleChange}' + ''; + + npmDepsHash = "sha256-QVpUV3dxaqiWCF8RC1MR2ylYC500Lbp5pJgzzOrF20c="; + + preBuild = '' + # wasm resolution fix + mkdir -p node_modules/@ironcalc + cp -rv ${wasm}/. node_modules/@ironcalc/wasm + ''; + + installPhase = '' + mkdir -p $out + cp -r dist/. $out + ''; + + __structuredAttrs = true; + strictDeps = true; + + meta = ironcalc.meta // { + description = "Ironcalc frontend package"; + }; + }; +in +{ + inherit + wasm + widget + frontend + ; +} diff --git a/pkgs/by-name/ir/ironcalc/nodejs.nix b/pkgs/by-name/ir/ironcalc/nodejs.nix new file mode 100644 index 000000000000..50cb077de5db --- /dev/null +++ b/pkgs/by-name/ir/ironcalc/nodejs.nix @@ -0,0 +1,84 @@ +{ + lib, + stdenv, + pnpm, + pnpmConfigHook, + fetchPnpmDeps, + rustPlatform, + pkg-config, + bzip2, + zstd, + ironcalc, + nodejs, + cargo, + rustc, + writableTmpDirAsHomeHook, +}: + +stdenv.mkDerivation { + pname = "ironcalc-nodejs"; + inherit (ironcalc) version src; + + postPatch = '' + cd bindings/nodejs + ''; + + strictDeps = true; + __structuredAttrs = true; + + pnpmDeps = fetchPnpmDeps { + inherit (ironcalc) src; + pname = "ironcalc-nodejs"; + hash = "sha256-q0PTXKAX0mhrMKMnFzV65YU948lh+/rGn9ttWzBfdNc="; + fetcherVersion = 3; + preInstall = '' + cd bindings/nodejs + ''; + }; + + makeCacheWritable = true; + + cargoDeps = rustPlatform.fetchCargoVendor { + inherit (ironcalc) src; + hash = ironcalc.cargoHash; + }; + + cargoRoot = "../.."; + + nativeBuildInputs = [ + pkg-config + pnpm + nodejs + cargo + rustc + pnpmConfigHook + rustPlatform.cargoSetupHook + rustPlatform.cargoCheckHook + writableTmpDirAsHomeHook + ]; + + buildPhase = '' + runHook preBuild + pnpm run build + runHook postBuild + ''; + + doCheck = true; + + checkPhase = '' + runHook preCheck + pnpm run test + runHook postCheck + ''; + + installPhase = '' + runHook preInstall + mkdir -p $out/lib/node_modules/@ironcalc/nodejs + cp index.js index.d.ts package.json *.node $out/lib/node_modules/@ironcalc/nodejs/ + runHook postInstall + ''; + + meta = ironcalc.meta // { + description = "Node.js bindings for IronCalc"; + }; +} diff --git a/pkgs/by-name/ir/ironcalc/package.nix b/pkgs/by-name/ir/ironcalc/package.nix new file mode 100644 index 000000000000..c1f998745787 --- /dev/null +++ b/pkgs/by-name/ir/ironcalc/package.nix @@ -0,0 +1,197 @@ +{ + lib, + callPackage, + fetchFromGitHub, + + rustPlatform, + + pkg-config, + python3, + python3Packages, + bzip2, + zstd, + stdenv, + + coreutils, + sqlite, + writeShellApplication, + symlinkJoin, + nix-update-script, +}: + +let + version = "0.7.1-unstable-2026-04-29"; + + src = fetchFromGitHub { + owner = "ironcalc"; + repo = "ironcalc"; + rev = "8461ff71347ab19145cd7ad50ef829181ba765c2"; + hash = "sha256-vjI3M+hS9bXK8QQlopAy6f4dCISfQHGMvN9sMNKp88Q="; + }; + + cargoHash = "sha256-q5DnqhIYKUUqfJ4/TNHYF1QgTbH198QtgirQ+lP30wk="; + + meta = { + description = "Open source selfhosted spreadsheet engine"; + homepage = "https://github.com/ironcalc/IronCalc"; + license = with lib.licenses; [ + asl20 + mit + ]; + mainProgram = "ironcalc"; + maintainers = with lib.maintainers; [ phanirithvij ]; + teams = with lib.teams; [ ngi ]; + # see checkNoDefaultFeatures below + broken = stdenv.hostPlatform.isAarch64; + }; + + server = rustPlatform.buildRustPackage { + pname = "ironcalc-server"; + inherit src version; + + buildAndTestSubdir = "webapp/app.ironcalc.com/server"; + cargoRoot = "webapp/app.ironcalc.com/server"; + + cargoHash = "sha256-46IwZJI9AOs+IQFbfz89A2yIi5db7rVMVNsO9W+tn+c="; + + __structuredAttrs = true; + strictDeps = true; + + nativeBuildInputs = [ pkg-config ]; + buildInputs = [ + bzip2 + zstd + ]; + + postInstall = '' + install -Dm644 webapp/app.ironcalc.com/server/init_db.sql $out/share/ironcalc/init_db.sql + ''; + + meta = meta // { + description = "IronCalc server package"; + mainProgram = "ironcalc_server"; + }; + }; + + frontend_packages = callPackage ./frontend.nix { }; + + inherit (frontend_packages) + frontend + wasm + widget + ; + + tools = rustPlatform.buildRustPackage { + pname = "ironcalc-tools"; + inherit src version; + inherit cargoHash; + + patches = [ + # nix specific issue, can't reproduce without nix, not upstreaming + ./0001-FIX-test-message.patch + ]; + + __structuredAttrs = true; + strictDeps = true; + + nativeBuildInputs = [ + pkg-config + python3 + ]; + + buildInputs = [ + bzip2 + zstd + ]; + + doCheck = true; + + # for aarch64-darwin and aarch64-linux + # there are a lot of undefined references to Py + # https://github.com/PyO3/pyo3/issues/1800 + checkNoDefaultFeatures = stdenv.hostPlatform.isAarch64; + + doInstallCheck = true; + installCheckPhase = '' + runHook preInstallCheck + { $out/bin/xlsx_2_icalc 2>&1 || true; } | grep -q "Usage:" + + $out/bin/xlsx_2_icalc xlsx/tests/docs/CHOOSE.xlsx test.ic + test -f test.ic + runHook postInstallCheck + ''; + + meta = meta // { + description = "IronCalc helper tools"; + mainProgram = "xlsx_2_icalc"; + }; + }; + + wrapper = writeShellApplication { + name = "ironcalc"; + + runtimeInputs = [ + coreutils + sqlite + server + ]; + + text = '' + IRONCALC_DB_PATH="''${IRONCALC_DB_PATH:-ironcalc.sqlite}" + mkdir -p "$(dirname "$IRONCALC_DB_PATH")" + + if [ ! -f "$IRONCALC_DB_PATH" ]; then + echo "Initializing database..." + sqlite3 "$IRONCALC_DB_PATH" < "${server}/share/ironcalc/init_db.sql" + fi + + export ROCKET_DATABASES="{ironcalc={url=\"$IRONCALC_DB_PATH\"}}" + export IRONCALC_WEBAPP_DIR="''${IRONCALC_WEBAPP_DIR:-${frontend}}" + + exec ironcalc_server "$@" + ''; + }; + + python = python3Packages.ironcalc; + nodejs = callPackage ./nodejs.nix { }; + docs = callPackage ./docs.nix { }; +in +symlinkJoin { + pname = "ironcalc"; + inherit version; + paths = [ + tools + wrapper + ]; + + __structuredAttrs = true; + strictDeps = true; + + passthru = + let + exports = { + inherit + frontend + widget + server + tools + docs + wasm + nodejs + python + wrapper + ; + }; + in + { + inherit + src + cargoHash + ; + updateScript = [ ./update.sh ]; + tests = exports; + } + // exports; + + inherit meta; +} diff --git a/pkgs/by-name/ir/ironcalc/python.nix b/pkgs/by-name/ir/ironcalc/python.nix new file mode 100644 index 000000000000..8bff79b33c64 --- /dev/null +++ b/pkgs/by-name/ir/ironcalc/python.nix @@ -0,0 +1,56 @@ +{ + python3, + buildPythonPackage, + rustPlatform, + pkg-config, + bzip2, + zstd, + pytestCheckHook, + + ironcalc, +}: + +buildPythonPackage { + pname = "ironcalc"; + inherit (ironcalc) src version; + pyproject = true; + + postPatch = '' + cd bindings/python + ''; + + strictDeps = true; + __structuredAttrs = true; + + cargoDeps = rustPlatform.fetchCargoVendor { + inherit (ironcalc) src; + hash = ironcalc.cargoHash; + }; + + cargoRoot = "../.."; + + env.PYO3_PYTHON = "${python3}/bin/python3"; + + nativeBuildInputs = [ + rustPlatform.cargoSetupHook + rustPlatform.maturinBuildHook + pkg-config + ]; + + buildInputs = [ + bzip2 + zstd + ]; + + doCheck = true; + + nativeCheckInputs = [ + pytestCheckHook + ]; + + pythonImportsCheck = [ "ironcalc" ]; + + meta = ironcalc.meta // { + description = "Python bindings for IronCalc"; + }; +} diff --git a/pkgs/by-name/ir/ironcalc/update.sh b/pkgs/by-name/ir/ironcalc/update.sh new file mode 100755 index 000000000000..f8dfab297e48 --- /dev/null +++ b/pkgs/by-name/ir/ironcalc/update.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p curl jq common-updater-scripts nix-update + +set -euo pipefail + +owner="ironcalc" +repo="ironcalc" +branch="main" + +commit=$(curl -s "https://api.github.com/repos/$owner/$repo/branches/$branch" | jq -r .commit.sha) +date=$(curl -s "https://api.github.com/repos/$owner/$repo/commits/$commit" | jq -r .commit.committer.date | cut -d'T' -f1) + +current_version=$(nix-instantiate --eval -A ironcalc.version 2>/dev/null | tr -d '"' || echo "0.0.0") +base_version=$(echo "$current_version" | sed -E 's/-unstable-.*//') +new_version="$base_version-unstable-$date" + +echo "Updating ironcalc to $new_version ($commit)" + +if [ "$current_version" = "$new_version" ]; then + echo "Already up to date: $current_version" + exit 0 +fi + +update-source-version ironcalc "$new_version" --rev="$commit" + +echo "Updating hashes..." + +nix-update ironcalc.tools --version=skip +nix-update ironcalc.server --version=skip +nix-update ironcalc.widget --version=skip +nix-update ironcalc.frontend --version=skip +nix-update ironcalc.nodejs --version=skip diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 75b4ff0e3a9c..f151e163aec0 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -7832,6 +7832,10 @@ self: super: with self; { irm-kmi-api = callPackage ../development/python-modules/irm-kmi-api { }; + ironcalc = callPackage ../by-name/ir/ironcalc/python.nix { + inherit (pkgs) ironcalc; + }; + isal = callPackage ../development/python-modules/isal { }; isbnlib = callPackage ../development/python-modules/isbnlib { };