summary refs log tree commit diff stats
path: root/nix/package.nix
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-03-19 07:45:14 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-03-19 07:45:14 +0100
commitf6a3fb9c4d8dd86f78c9f75a23c1ac35bf35d4eb (patch)
tree5f28fbca03d83921b568f7cb1708374456d9ec42 /nix/package.nix
parentfeat(treewide): Add further buttons (diff)
downloadweb-client-f6a3fb9c4d8dd86f78c9f75a23c1ac35bf35d4eb.zip
feat(treewide): Commit MVP
Diffstat (limited to 'nix/package.nix')
-rw-r--r--nix/package.nix69
1 files changed, 69 insertions, 0 deletions
diff --git a/nix/package.nix b/nix/package.nix
new file mode 100644
index 0000000..1bcc0ae
--- /dev/null
+++ b/nix/package.nix
@@ -0,0 +1,69 @@
+# rocie - An enterprise grocery management system
+#
+# Copyright (C) 2024 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of Rocie.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
+{
+  lib,
+  craneLib,
+  # nativeBuildInputs
+  trunk,
+  tailwindcss,
+  wasm-bindgen-cli_0_2_104,
+  binaryen,
+}:
+craneLib.buildPackage {
+  pname = "rocie-mobile";
+  inherit
+    ((builtins.fromTOML (builtins.readFile
+          ../Cargo.toml)).package)
+    version
+    ;
+
+  src = lib.cleanSourceWith {
+    src = lib.cleanSource ./..;
+    filter = name: type:
+      (type == "directory")
+      || (builtins.elem (builtins.baseNameOf name) [
+        "Cargo.toml"
+        "Cargo.lock"
+        "tailwind.config.js"
+        "index.html"
+        "input.css"
+        "Trunk.toml"
+        "manifest.json"
+        "favicon.ico"
+      ])
+      || (lib.strings.hasSuffix ".rs" (builtins.baseNameOf name));
+  };
+  strictDeps = true;
+
+  cargoExtraArgs = "--target wasm32-unknown-unknown";
+
+  # Tests currently need to be run via `cargo wasi` which
+  # isn't packaged in nixpkgs yet...
+  doCheck = false;
+
+  nativeBuildInputs = [
+    trunk
+    tailwindcss
+    wasm-bindgen-cli_0_2_104
+    binaryen # for wasm-opt
+  ];
+
+  buildInputs = [
+  ];
+
+  postInstall = ''
+    trunk --offline --verbose build --release --locked --frozen --dist "./dist"
+
+    rm --recursive $out/bin
+
+    cp --recursive ./dist/. $out/
+  '';
+}