summaryrefslogtreecommitdiffstats
path: root/nix
diff options
context:
space:
mode:
Diffstat (limited to '')
-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/
+ '';
+}