From cb28fcf8c492776affb64bdf1400e445ebdeba48 Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Wed, 3 May 2023 16:20:47 -0400 Subject: [PATCH] Rerrange directories. Set up default.nix files. Try to build the wasm code. --- flake.nix | 11 +++++++++-- kifu/kifu-pwa/{web => }/converter.css | 0 kifu/kifu-pwa/{web => }/default.nix | 0 kifu/kifu-pwa/{web => }/icon512.png | Bin kifu/kifu-pwa/{web => }/index.html | 0 kifu/kifu-pwa/{web => }/manifest.json | 0 kifu/kifu-pwa/{web => }/node-env.nix | 0 kifu/kifu-pwa/{web => }/node-packages.nix | 0 kifu/kifu-pwa/{web => }/package-lock.json | 0 kifu/kifu-pwa/{web => }/package.json | 0 kifu/kifu-pwa/{web => }/src/converter.ts | 0 kifu/kifu-pwa/{web => }/src/sw.js | 0 kifu/kifu-pwa/{web => }/tsconfig.json | 0 kifu/kifu-pwa/{web => }/webpack.config.js | 0 kifu/{kifu-pwa/core => kifu-wasm}/Cargo.lock | 0 kifu/{kifu-pwa/core => kifu-wasm}/Cargo.nix | 2 +- kifu/{kifu-pwa/core => kifu-wasm}/Cargo.toml | 2 +- kifu/{kifu-pwa/core => kifu-wasm}/build.rs | 0 kifu/kifu-wasm/default.nix | 17 +++++++++++++++++ kifu/{kifu-pwa/core => kifu-wasm}/src/lib.rs | 0 20 files changed, 28 insertions(+), 4 deletions(-) rename kifu/kifu-pwa/{web => }/converter.css (100%) rename kifu/kifu-pwa/{web => }/default.nix (100%) rename kifu/kifu-pwa/{web => }/icon512.png (100%) rename kifu/kifu-pwa/{web => }/index.html (100%) rename kifu/kifu-pwa/{web => }/manifest.json (100%) rename kifu/kifu-pwa/{web => }/node-env.nix (100%) rename kifu/kifu-pwa/{web => }/node-packages.nix (100%) rename kifu/kifu-pwa/{web => }/package-lock.json (100%) rename kifu/kifu-pwa/{web => }/package.json (100%) rename kifu/kifu-pwa/{web => }/src/converter.ts (100%) rename kifu/kifu-pwa/{web => }/src/sw.js (100%) rename kifu/kifu-pwa/{web => }/tsconfig.json (100%) rename kifu/kifu-pwa/{web => }/webpack.config.js (100%) rename kifu/{kifu-pwa/core => kifu-wasm}/Cargo.lock (100%) rename kifu/{kifu-pwa/core => kifu-wasm}/Cargo.nix (99%) rename kifu/{kifu-pwa/core => kifu-wasm}/Cargo.toml (88%) rename kifu/{kifu-pwa/core => kifu-wasm}/build.rs (100%) create mode 100644 kifu/kifu-wasm/default.nix rename kifu/{kifu-pwa/core => kifu-wasm}/src/lib.rs (100%) diff --git a/flake.nix b/flake.nix index ecdaa1c..b2ac681 100644 --- a/flake.nix +++ b/flake.nix @@ -42,6 +42,7 @@ pkgs.crate2nix pkgs.wasm-pack pkgs.node2nix + pkgs.wasm-bindgen-cli pkgs-unstable.typeshare ]; LIBCLANG_PATH="${pkgs.llvmPackages.libclang.lib}/lib"; @@ -96,11 +97,17 @@ typeshare = typeshare.packages."x86_64-linux".default; }; + kifu-wasm = import ./kifu/kifu-wasm { + inherit pkgs; + typeshare = typeshare.packages."x86_64-linux".default; + wasm-pack = pkgs.wasm-pack; + }; + kifu-pwa = let - deps = (import ./kifu/kifu-pwa/web { inherit pkgs; }).nodeDependencies; + deps = (import ./kifu/kifu-pwa { inherit pkgs; }).nodeDependencies; in pkgs.stdenv.mkDerivation { name = "kifu-pwa"; - src = ./kifu/kifu-pwa/web; + src = ./kifu/kifu-pwa; buildInputs = [ pkgs.nodejs pkgs.nodePackages.webpack-cli ]; buildPhase = '' diff --git a/kifu/kifu-pwa/web/converter.css b/kifu/kifu-pwa/converter.css similarity index 100% rename from kifu/kifu-pwa/web/converter.css rename to kifu/kifu-pwa/converter.css diff --git a/kifu/kifu-pwa/web/default.nix b/kifu/kifu-pwa/default.nix similarity index 100% rename from kifu/kifu-pwa/web/default.nix rename to kifu/kifu-pwa/default.nix diff --git a/kifu/kifu-pwa/web/icon512.png b/kifu/kifu-pwa/icon512.png similarity index 100% rename from kifu/kifu-pwa/web/icon512.png rename to kifu/kifu-pwa/icon512.png diff --git a/kifu/kifu-pwa/web/index.html b/kifu/kifu-pwa/index.html similarity index 100% rename from kifu/kifu-pwa/web/index.html rename to kifu/kifu-pwa/index.html diff --git a/kifu/kifu-pwa/web/manifest.json b/kifu/kifu-pwa/manifest.json similarity index 100% rename from kifu/kifu-pwa/web/manifest.json rename to kifu/kifu-pwa/manifest.json diff --git a/kifu/kifu-pwa/web/node-env.nix b/kifu/kifu-pwa/node-env.nix similarity index 100% rename from kifu/kifu-pwa/web/node-env.nix rename to kifu/kifu-pwa/node-env.nix diff --git a/kifu/kifu-pwa/web/node-packages.nix b/kifu/kifu-pwa/node-packages.nix similarity index 100% rename from kifu/kifu-pwa/web/node-packages.nix rename to kifu/kifu-pwa/node-packages.nix diff --git a/kifu/kifu-pwa/web/package-lock.json b/kifu/kifu-pwa/package-lock.json similarity index 100% rename from kifu/kifu-pwa/web/package-lock.json rename to kifu/kifu-pwa/package-lock.json diff --git a/kifu/kifu-pwa/web/package.json b/kifu/kifu-pwa/package.json similarity index 100% rename from kifu/kifu-pwa/web/package.json rename to kifu/kifu-pwa/package.json diff --git a/kifu/kifu-pwa/web/src/converter.ts b/kifu/kifu-pwa/src/converter.ts similarity index 100% rename from kifu/kifu-pwa/web/src/converter.ts rename to kifu/kifu-pwa/src/converter.ts diff --git a/kifu/kifu-pwa/web/src/sw.js b/kifu/kifu-pwa/src/sw.js similarity index 100% rename from kifu/kifu-pwa/web/src/sw.js rename to kifu/kifu-pwa/src/sw.js diff --git a/kifu/kifu-pwa/web/tsconfig.json b/kifu/kifu-pwa/tsconfig.json similarity index 100% rename from kifu/kifu-pwa/web/tsconfig.json rename to kifu/kifu-pwa/tsconfig.json diff --git a/kifu/kifu-pwa/web/webpack.config.js b/kifu/kifu-pwa/webpack.config.js similarity index 100% rename from kifu/kifu-pwa/web/webpack.config.js rename to kifu/kifu-pwa/webpack.config.js diff --git a/kifu/kifu-pwa/core/Cargo.lock b/kifu/kifu-wasm/Cargo.lock similarity index 100% rename from kifu/kifu-pwa/core/Cargo.lock rename to kifu/kifu-wasm/Cargo.lock diff --git a/kifu/kifu-pwa/core/Cargo.nix b/kifu/kifu-wasm/Cargo.nix similarity index 99% rename from kifu/kifu-pwa/core/Cargo.nix rename to kifu/kifu-wasm/Cargo.nix index a215183..0dd1075 100644 --- a/kifu/kifu-pwa/core/Cargo.nix +++ b/kifu/kifu-wasm/Cargo.nix @@ -497,7 +497,7 @@ rec { crateName = "kifu-core"; version = "0.1.0"; edition = "2021"; - src = lib.cleanSourceWith { filter = sourceFilter; src = ../../kifu-core; }; + src = lib.cleanSourceWith { filter = sourceFilter; src = ../kifu-core; }; dependencies = [ { name = "serde"; diff --git a/kifu/kifu-pwa/core/Cargo.toml b/kifu/kifu-wasm/Cargo.toml similarity index 88% rename from kifu/kifu-pwa/core/Cargo.toml rename to kifu/kifu-wasm/Cargo.toml index d2407ce..9dc0ea5 100644 --- a/kifu/kifu-pwa/core/Cargo.toml +++ b/kifu/kifu-wasm/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" crate-type = ["cdylib"] [dependencies] -kifu-core = { path = "../../kifu-core" } +kifu-core = { path = "../kifu-core" } wasm-bindgen = "0.2" wasm-bindgen-futures = "*" diff --git a/kifu/kifu-pwa/core/build.rs b/kifu/kifu-wasm/build.rs similarity index 100% rename from kifu/kifu-pwa/core/build.rs rename to kifu/kifu-wasm/build.rs diff --git a/kifu/kifu-wasm/default.nix b/kifu/kifu-wasm/default.nix new file mode 100644 index 0000000..c6c9d1a --- /dev/null +++ b/kifu/kifu-wasm/default.nix @@ -0,0 +1,17 @@ +{ pkgs, typeshare, wasm-pack }: +let + customBuildInfo = pkgs: pkgs.buildRustCrate.override { + defaultCrateOverrides = pkgs.defaultCrateOverrides // { + kifu-wasm = attrs: { + buildInputs = [ + typeshare + ]; + }; + }; + }; +in (import ./Cargo.nix { + inherit pkgs; + buildRustCrateForPkgs = customBuildInfo; + release = true; +}).rootCrate.build + diff --git a/kifu/kifu-pwa/core/src/lib.rs b/kifu/kifu-wasm/src/lib.rs similarity index 100% rename from kifu/kifu-pwa/core/src/lib.rs rename to kifu/kifu-wasm/src/lib.rs