This commit is contained in:
Quinn Dougherty 2022-08-16 20:25:31 -07:00
parent 607bd60021
commit 07c3004c82
27 changed files with 168 additions and 113 deletions

2
.gitignore vendored
View File

@ -7,3 +7,5 @@ yarn-error.log
**/.sync.ffs_db **/.sync.ffs_db
.direnv .direnv
.log .log
result
result-bin

View File

@ -21,7 +21,8 @@
}; };
}; };
outputs = { self, nixpkgs, gentype, hercules-ci-effects, cargo2nix, flake-utils, ... }: outputs = { self, nixpkgs, gentype, hercules-ci-effects, cargo2nix
, flake-utils, ... }:
let let
version = builtins.substring 0 8 self.lastModifiedDate; version = builtins.substring 0 8 self.lastModifiedDate;
commonFn = pkgs: { commonFn = pkgs: {
@ -30,29 +31,33 @@
which = [ pkgs.which ]; which = [ pkgs.which ];
}; };
gentypeOutputFn = pkgs: gentype.outputs.packages.${pkgs.system}.default; gentypeOutputFn = pkgs: gentype.outputs.packages.${pkgs.system}.default;
mcCacheFn = { pkgs, ... }: mcFn = { pkgs, ... }:
import ./nix/squiggle-mcCache.nix { inherit pkgs; }; import ./nix/squiggle-mc.nix { inherit pkgs commonFn; };
langFn = { pkgs, ... }: langFn = { pkgs, ... }:
import ./nix/squiggle-lang.nix { import ./nix/squiggle-lang.nix {
inherit pkgs commonFn mcCacheFn gentypeOutputFn; inherit pkgs commonFn mcFn gentypeOutputFn;
}; };
componentsFn = { pkgs, ... }: componentsFn = { pkgs, ... }:
import ./nix/squiggle-components.nix { inherit pkgs commonFn mcCacheFn langFn; }; import ./nix/squiggle-components.nix {
inherit pkgs commonFn mcFn langFn;
};
websiteFn = { pkgs, ... }: websiteFn = { pkgs, ... }:
import ./nix/squiggle-website.nix { import ./nix/squiggle-website.nix {
inherit pkgs commonFn mcCacheFn langFn componentsFn; inherit pkgs commonFn mcFn langFn componentsFn;
}; };
# local machines # local machines
localFlake = { pkgs, ... }: localFlake = { pkgs, ... }:
let let
mcCache = mcCacheFn pkgs; mc = mcFn pkgs;
lang = langFn pkgs; lang = langFn pkgs;
components = componentsFn pkgs; components = componentsFn pkgs;
website = websiteFn pkgs; website = websiteFn pkgs;
in { in {
# validating # validating
checks = flake-utils.lib.flattenTree { checks = flake-utils.lib.flattenTree {
wasm-lint = mc.rust-lint;
wasm-headless-test = mc.firefox-test;
lang-lint = lang.lint; lang-lint = lang.lint;
lang-test = lang.test; lang-test = lang.test;
components-lint = components.lint; components-lint = components.lint;
@ -61,7 +66,8 @@
# building # building
packages = flake-utils.lib.flattenTree { packages = flake-utils.lib.flattenTree {
default = website.docusaurus; default = website.docusaurus;
mc-wasm = mcCache.mc-cached; mc-wasm = mc.lib;
mc-wasm-pkg = mc.webpack-build-pkg;
lang-bundle = lang.bundle; lang-bundle = lang.bundle;
components = components.package-build; components = components.package-build;
storybook = components.site-build; storybook = components.site-build;
@ -70,7 +76,8 @@
# developing # developing
devShells = flake-utils.lib.flattenTree { devShells = flake-utils.lib.flattenTree {
default = (import ./nix/shell.nix { inherit pkgs cargo2nix; }).shell; default =
(import ./nix/shell.nix { inherit pkgs cargo2nix; }).shell;
}; };
}; };
@ -79,6 +86,7 @@
hciSystem = "x86_64-linux"; hciSystem = "x86_64-linux";
hciPkgs = import nixpkgs { system = hciSystem; }; hciPkgs = import nixpkgs { system = hciSystem; };
effects = hercules-ci-effects.lib.withPkgs hciPkgs; effects = hercules-ci-effects.lib.withPkgs hciPkgs;
mc = mcFn hciPkgs;
lang = langFn hciPkgs; lang = langFn hciPkgs;
components = componentsFn hciPkgs; components = componentsFn hciPkgs;
website = websiteFn hciPkgs; website = websiteFn hciPkgs;
@ -86,6 +94,11 @@
herculesCI = { herculesCI = {
ciSystems = [ hciSystem ]; ciSystems = [ hciSystem ];
onPush = { onPush = {
wasm.outputs = {
squiggle-wasm-lint = mc.rust-lint;
squiggle-wasm-pkg = mc.webpack-build-pkg;
squiggle-wasm-test-ff = mc.rust-firefox-test;
};
lang.outputs = { lang.outputs = {
squiggle-lang-lint = lang.lint; squiggle-lang-lint = lang.lint;
squiggle-lang-build = lang.build; squiggle-lang-build = lang.build;

View File

@ -1,8 +1,8 @@
{ pkgs, commonFn, mcCacheFn, langFn }: { pkgs, commonFn, mcFn, langFn }:
rec { rec {
common = commonFn pkgs; common = commonFn pkgs;
mcCache = mcCacheFn pkgs; mc = mcFn pkgs;
lang = langFn pkgs; lang = langFn pkgs;
componentsPackageJson = let componentsPackageJson = let
raw = pkgs.lib.importJSON ../packages/components/package.json; raw = pkgs.lib.importJSON ../packages/components/package.json;
@ -12,11 +12,12 @@ rec {
in pkgs.writeText "packages/components/patched-package.json" in pkgs.writeText "packages/components/patched-package.json"
packageJsonString; packageJsonString;
yarn-source = pkgs.mkYarnPackage { yarn-source = pkgs.mkYarnPackage {
name = "squiggle-components_source"; name = "squiggle-components_yarnsource";
buildInputs = common.buildInputs; buildInputs = common.buildInputs;
src = ../packages/components; src = ../packages/components;
packageJSON = componentsPackageJson; packageJSON = componentsPackageJson;
yarnLock = ../yarn.lock; yarnLock = ../yarn.lock;
packageResolutions."@quri/squiggle-mc" = mc.webpack-build-pkg;
packageResolutions."@quri/squiggle-lang" = lang.build; packageResolutions."@quri/squiggle-lang" = lang.build;
}; };
lint = pkgs.stdenv.mkDerivation { lint = pkgs.stdenv.mkDerivation {

View File

@ -1,10 +1,10 @@
{ pkgs, commonFn, mcCacheFn, gentypeOutputFn }: { pkgs, commonFn, mcFn, gentypeOutputFn }:
rec { rec {
common = commonFn pkgs; common = commonFn pkgs;
mcCache = mcCacheFn pkgs; mc = mcFn pkgs;
yarn-source = pkgs.mkYarnPackage { yarn-source = pkgs.mkYarnPackage {
name = "squiggle-lang_source"; name = "squiggle-lang_yarnsource";
src = ../packages/squiggle-lang; src = ../packages/squiggle-lang;
packageJSON = ../packages/squiggle-lang/package.json; packageJSON = ../packages/squiggle-lang/package.json;
yarnLock = ../yarn.lock; yarnLock = ../yarn.lock;
@ -23,8 +23,7 @@ rec {
''; '';
}; };
bisect_ppx = { bisect_ppx = {
buildInputs = buildInputs = common.which;
common.which; # ++ (with pkgs; [ ocaml nodePackages.esy ocamlPackages.bisect_ppx ]);
postInstall = '' postInstall = ''
echo "PATCHELF'ING BISECT_PPX EXECUTABLE" echo "PATCHELF'ING BISECT_PPX EXECUTABLE"
THE_LD=$(patchelf --print-interpreter $(which mkdir)) THE_LD=$(patchelf --print-interpreter $(which mkdir))
@ -39,7 +38,7 @@ rec {
''; '';
}; };
}; };
packageResolutions."@quri/par-cached-monte-carlo" = mcCache.mc-cached; packageResolutions."@quri/squiggle-mc" = mc.webpack-build-pkg;
}; };
lint = pkgs.stdenv.mkDerivation { lint = pkgs.stdenv.mkDerivation {
name = "squiggle-lang-lint"; name = "squiggle-lang-lint";

46
nix/squiggle-mc.nix Normal file
View File

@ -0,0 +1,46 @@
{ pkgs, commonFn }:
rec {
common = commonFn pkgs;
rustPkgs = pkgs.rustBuilder.makePackageSet {
rustVersion = "1.60.0";
packageFun = import ../packages/mc/Cargo.nix;
};
yarn-source = pkgs.mkYarnPackage {
name = "squiggle-mc_yarnsource";
buildInputs = common.buildInputs;
src = ../packages/mc;
packageJSON = ../packages/mc/package.json;
yarnLock = ../yarn.lock;
};
rust-lint = pkgs.stdenv.mkDerivation {
name = "squiggle-mc-lint";
src = yarn-source + "/libexec/@quri/squiggle-mc/deps/@quri/squiggle-mc";
buildInputs = with pkgs; [ rustfmt ];
buildPhase = "rustfmt --check src";
installPhase = "mkdir -p $out";
};
lib = rustPkgs.workspace.quri-squiggle-mc { };
webpack-build-pkg = pkgs.stdenv.mkDerivation {
name = "squiggle-mc-build";
src = yarn-source + "/libexec/@quri/squiggle-mc";
buildInputs = common.buildInputs ++ (with pkgs; [ wasm-pack ]);
buildPhase = ''
pushd deps/@quri/squiggle-mc
sed -i /pkg/d .gitignore
yarn --offline build
popd
'';
installPhase = ''
mkdir -p $out
cp -r deps/@quri/squiggle-mc/. $out
'';
};
firefox-test = pkgs.stdenv.mkDerivation {
name = "squiggle-mc-test";
src = yarn-source + "/libexec/@quri/squiggle-mc/deps/@quri/squiggle-mc";
buildInputs = common.buildInputs ++ (with pkgs; [ geckodriver cargo wasm-pack ]);
buildPhase = "yarn --offline test -- --firefox";
installPhase = "mkdir -p $out";
};
}

View File

@ -1,9 +0,0 @@
{ pkgs }:
rec {
rustPkgs = pkgs.rustBuilder.makePackageSet {
rustVersion = "1.60.0";
packageFun = import ./../packages/squiggle-mc-cached/Cargo.nix;
};
mc-cached = rustPkgs.workspace.squiggle-mc-cached-wasm {};
}

View File

@ -1,8 +1,8 @@
{ pkgs, commonFn, mcCacheFn, langFn, componentsFn }: { pkgs, commonFn, mcFn, langFn, componentsFn }:
rec { rec {
common = commonFn pkgs; common = commonFn pkgs;
mcCache = mcCacheFn pkgs; mc = mcFn pkgs;
lang = langFn pkgs; lang = langFn pkgs;
components = componentsFn pkgs; components = componentsFn pkgs;
websitePackageJson = let websitePackageJson = let
@ -14,13 +14,13 @@ rec {
packageJsonString = builtins.toJSON modified; packageJsonString = builtins.toJSON modified;
in pkgs.writeText "packages/website/patched-package.json" packageJsonString; in pkgs.writeText "packages/website/patched-package.json" packageJsonString;
yarn-source = pkgs.mkYarnPackage { yarn-source = pkgs.mkYarnPackage {
name = "squiggle-website_source"; name = "squiggle-website_yarnsource";
src = ../packages/website; src = ../packages/website;
packageJSON = websitePackageJson; packageJSON = websitePackageJson;
yarnLock = ../yarn.lock; yarnLock = ../yarn.lock;
packageResolutions."@quri/squiggle-mc" = mc.webpack-build-pkg + "/pkg";
packageResolutions."@quri/squiggle-lang" = lang.build; packageResolutions."@quri/squiggle-lang" = lang.build;
packageResolutions."@quri/squiggle-components" = components.package-build; packageResolutions."@quri/squiggle-components" = components.package-build;
workspaceDependencies = [ lang.yarn-source components.yarn-source ];
}; };
lint = pkgs.stdenv.mkDerivation { lint = pkgs.stdenv.mkDerivation {
name = "squiggle-website-lint"; name = "squiggle-website-lint";

5
packages/mc/.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
node_modules
dist
target
pkg
wasm-pack.log

View File

@ -448,6 +448,28 @@ dependencies = [
"proc-macro2 1.0.43", "proc-macro2 1.0.43",
] ]
[[package]]
name = "quri-squiggle-mc"
version = "0.0.1"
dependencies = [
"cached",
"console_error_panic_hook",
"futures 0.1.31",
"getrandom",
"js-sys",
"kernel_density",
"quickcheck",
"quickcheck_macros",
"rand 0.8.5",
"rand_distr",
"statistics",
"wasm-bindgen",
"wasm-bindgen-futures",
"wasm-bindgen-test",
"web-sys",
"wee_alloc",
]
[[package]] [[package]]
name = "rand" name = "rand"
version = "0.3.23" version = "0.3.23"
@ -558,28 +580,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
[[package]]
name = "squiggle-mc-cached-wasm"
version = "0.0.1"
dependencies = [
"cached",
"console_error_panic_hook",
"futures 0.1.31",
"getrandom",
"js-sys",
"kernel_density",
"quickcheck",
"quickcheck_macros",
"rand 0.8.5",
"rand_distr",
"statistics",
"wasm-bindgen",
"wasm-bindgen-futures",
"wasm-bindgen-test",
"web-sys",
"wee_alloc",
]
[[package]] [[package]]
name = "statistics" name = "statistics"
version = "0.4.1" version = "0.4.1"

View File

@ -4,7 +4,7 @@
args@{ args@{
release ? true, release ? true,
rootFeatures ? [ rootFeatures ? [
"squiggle-mc-cached-wasm/default" "quri-squiggle-mc/default"
], ],
rustPackages, rustPackages,
buildRustPackages, buildRustPackages,
@ -38,7 +38,7 @@ in
{ {
cargo2nixVersion = "0.11.0"; cargo2nixVersion = "0.11.0";
workspace = { workspace = {
squiggle-mc-cached-wasm = rustPackages.unknown.squiggle-mc-cached-wasm."0.0.1"; quri-squiggle-mc = rustPackages.unknown.quri-squiggle-mc."0.0.1";
}; };
"registry+https://github.com/rust-lang/crates.io-index".aho-corasick."0.7.18" = overridableMkRustCrate (profileName: rec { "registry+https://github.com/rust-lang/crates.io-index".aho-corasick."0.7.18" = overridableMkRustCrate (profileName: rec {
name = "aho-corasick"; name = "aho-corasick";
@ -659,6 +659,37 @@ in
}; };
}); });
"unknown".quri-squiggle-mc."0.0.1" = overridableMkRustCrate (profileName: rec {
name = "quri-squiggle-mc";
version = "0.0.1";
registry = "unknown";
src = fetchCrateLocal workspaceSrc;
features = builtins.concatLists [
(lib.optional (rootFeatures' ? "quri-squiggle-mc/default") "default")
(lib.optional (rootFeatures' ? "quri-squiggle-mc/default" || rootFeatures' ? "quri-squiggle-mc/wee_alloc") "wee_alloc")
];
dependencies = {
cached = rustPackages."registry+https://github.com/rust-lang/crates.io-index".cached."0.38.0" { inherit profileName; };
${ if false then "console_error_panic_hook" else null } = rustPackages."registry+https://github.com/rust-lang/crates.io-index".console_error_panic_hook."0.1.7" { inherit profileName; };
getrandom = rustPackages."registry+https://github.com/rust-lang/crates.io-index".getrandom."0.2.7" { inherit profileName; };
kernel_density = rustPackages."registry+https://github.com/rust-lang/crates.io-index".kernel_density."0.0.1" { inherit profileName; };
rand = rustPackages."registry+https://github.com/rust-lang/crates.io-index".rand."0.8.5" { inherit profileName; };
rand_distr = rustPackages."registry+https://github.com/rust-lang/crates.io-index".rand_distr."0.4.3" { inherit profileName; };
statistics = rustPackages."registry+https://github.com/rust-lang/crates.io-index".statistics."0.4.1" { inherit profileName; };
wasm_bindgen = rustPackages."registry+https://github.com/rust-lang/crates.io-index".wasm-bindgen."0.2.82" { inherit profileName; };
web_sys = rustPackages."registry+https://github.com/rust-lang/crates.io-index".web-sys."0.3.59" { inherit profileName; };
${ if rootFeatures' ? "quri-squiggle-mc/default" || rootFeatures' ? "quri-squiggle-mc/wee_alloc" then "wee_alloc" else null } = rustPackages."registry+https://github.com/rust-lang/crates.io-index".wee_alloc."0.4.5" { inherit profileName; };
};
devDependencies = {
futures = rustPackages."registry+https://github.com/rust-lang/crates.io-index".futures."0.1.31" { inherit profileName; };
js_sys = rustPackages."registry+https://github.com/rust-lang/crates.io-index".js-sys."0.3.59" { inherit profileName; };
quickcheck = rustPackages."registry+https://github.com/rust-lang/crates.io-index".quickcheck."1.0.3" { inherit profileName; };
quickcheck_macros = buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".quickcheck_macros."1.0.0" { profileName = "__noProfile"; };
wasm_bindgen_futures = rustPackages."registry+https://github.com/rust-lang/crates.io-index".wasm-bindgen-futures."0.3.27" { inherit profileName; };
wasm_bindgen_test = rustPackages."registry+https://github.com/rust-lang/crates.io-index".wasm-bindgen-test."0.2.50" { inherit profileName; };
};
});
"registry+https://github.com/rust-lang/crates.io-index".rand."0.3.23" = overridableMkRustCrate (profileName: rec { "registry+https://github.com/rust-lang/crates.io-index".rand."0.3.23" = overridableMkRustCrate (profileName: rec {
name = "rand"; name = "rand";
version = "0.3.23"; version = "0.3.23";
@ -823,36 +854,6 @@ in
src = fetchCratesIo { inherit name version; sha256 = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"; }; src = fetchCratesIo { inherit name version; sha256 = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"; };
}); });
"unknown".squiggle-mc-cached-wasm."0.0.1" = overridableMkRustCrate (profileName: rec {
name = "squiggle-mc-cached-wasm";
version = "0.0.1";
registry = "unknown";
src = fetchCrateLocal workspaceSrc;
features = builtins.concatLists [
(lib.optional (rootFeatures' ? "squiggle-mc-cached-wasm/wee_alloc") "wee_alloc")
];
dependencies = {
cached = rustPackages."registry+https://github.com/rust-lang/crates.io-index".cached."0.38.0" { inherit profileName; };
${ if false then "console_error_panic_hook" else null } = rustPackages."registry+https://github.com/rust-lang/crates.io-index".console_error_panic_hook."0.1.7" { inherit profileName; };
getrandom = rustPackages."registry+https://github.com/rust-lang/crates.io-index".getrandom."0.2.7" { inherit profileName; };
kernel_density = rustPackages."registry+https://github.com/rust-lang/crates.io-index".kernel_density."0.0.1" { inherit profileName; };
rand = rustPackages."registry+https://github.com/rust-lang/crates.io-index".rand."0.8.5" { inherit profileName; };
rand_distr = rustPackages."registry+https://github.com/rust-lang/crates.io-index".rand_distr."0.4.3" { inherit profileName; };
statistics = rustPackages."registry+https://github.com/rust-lang/crates.io-index".statistics."0.4.1" { inherit profileName; };
wasm_bindgen = rustPackages."registry+https://github.com/rust-lang/crates.io-index".wasm-bindgen."0.2.82" { inherit profileName; };
web_sys = rustPackages."registry+https://github.com/rust-lang/crates.io-index".web-sys."0.3.59" { inherit profileName; };
${ if rootFeatures' ? "squiggle-mc-cached-wasm/wee_alloc" then "wee_alloc" else null } = rustPackages."registry+https://github.com/rust-lang/crates.io-index".wee_alloc."0.4.5" { inherit profileName; };
};
devDependencies = {
futures = rustPackages."registry+https://github.com/rust-lang/crates.io-index".futures."0.1.31" { inherit profileName; };
js_sys = rustPackages."registry+https://github.com/rust-lang/crates.io-index".js-sys."0.3.59" { inherit profileName; };
quickcheck = rustPackages."registry+https://github.com/rust-lang/crates.io-index".quickcheck."1.0.3" { inherit profileName; };
quickcheck_macros = buildRustPackages."registry+https://github.com/rust-lang/crates.io-index".quickcheck_macros."1.0.0" { profileName = "__noProfile"; };
wasm_bindgen_futures = rustPackages."registry+https://github.com/rust-lang/crates.io-index".wasm-bindgen-futures."0.3.27" { inherit profileName; };
wasm_bindgen_test = rustPackages."registry+https://github.com/rust-lang/crates.io-index".wasm-bindgen-test."0.2.50" { inherit profileName; };
};
});
"registry+https://github.com/rust-lang/crates.io-index".statistics."0.4.1" = overridableMkRustCrate (profileName: rec { "registry+https://github.com/rust-lang/crates.io-index".statistics."0.4.1" = overridableMkRustCrate (profileName: rec {
name = "statistics"; name = "statistics";
version = "0.4.1"; version = "0.4.1";
@ -1139,14 +1140,14 @@ in
registry = "registry+https://github.com/rust-lang/crates.io-index"; registry = "registry+https://github.com/rust-lang/crates.io-index";
src = fetchCratesIo { inherit name version; sha256 = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e"; }; src = fetchCratesIo { inherit name version; sha256 = "dbb3b5a6b2bb17cb6ad44a2e68a43e8d2722c997da10e928665c72ec6c0a0b8e"; };
features = builtins.concatLists [ features = builtins.concatLists [
(lib.optional (rootFeatures' ? "squiggle-mc-cached-wasm/wee_alloc") "default") (lib.optional (rootFeatures' ? "quri-squiggle-mc/default" || rootFeatures' ? "quri-squiggle-mc/wee_alloc") "default")
(lib.optional (rootFeatures' ? "squiggle-mc-cached-wasm/wee_alloc") "size_classes") (lib.optional (rootFeatures' ? "quri-squiggle-mc/default" || rootFeatures' ? "quri-squiggle-mc/wee_alloc") "size_classes")
]; ];
dependencies = { dependencies = {
${ if rootFeatures' ? "squiggle-mc-cached-wasm/wee_alloc" then "cfg_if" else null } = rustPackages."registry+https://github.com/rust-lang/crates.io-index".cfg-if."0.1.10" { inherit profileName; }; ${ if rootFeatures' ? "quri-squiggle-mc/default" || rootFeatures' ? "quri-squiggle-mc/wee_alloc" then "cfg_if" else null } = rustPackages."registry+https://github.com/rust-lang/crates.io-index".cfg-if."0.1.10" { inherit profileName; };
${ if rootFeatures' ? "squiggle-mc-cached-wasm/wee_alloc" && hostPlatform.isUnix && !(hostPlatform.parsed.cpu.name == "wasm32") then "libc" else null } = rustPackages."registry+https://github.com/rust-lang/crates.io-index".libc."0.2.132" { inherit profileName; }; ${ if (rootFeatures' ? "quri-squiggle-mc/default" || rootFeatures' ? "quri-squiggle-mc/wee_alloc") && hostPlatform.isUnix && !(hostPlatform.parsed.cpu.name == "wasm32") then "libc" else null } = rustPackages."registry+https://github.com/rust-lang/crates.io-index".libc."0.2.132" { inherit profileName; };
${ if rootFeatures' ? "squiggle-mc-cached-wasm/wee_alloc" then "memory_units" else null } = rustPackages."registry+https://github.com/rust-lang/crates.io-index".memory_units."0.4.0" { inherit profileName; }; ${ if rootFeatures' ? "quri-squiggle-mc/default" || rootFeatures' ? "quri-squiggle-mc/wee_alloc" then "memory_units" else null } = rustPackages."registry+https://github.com/rust-lang/crates.io-index".memory_units."0.4.0" { inherit profileName; };
${ if rootFeatures' ? "squiggle-mc-cached-wasm/wee_alloc" && hostPlatform.parsed.kernel.name == "windows" then "winapi" else null } = rustPackages."registry+https://github.com/rust-lang/crates.io-index".winapi."0.3.9" { inherit profileName; }; ${ if (rootFeatures' ? "quri-squiggle-mc/default" || rootFeatures' ? "quri-squiggle-mc/wee_alloc") && hostPlatform.parsed.kernel.name == "windows" then "winapi" else null } = rustPackages."registry+https://github.com/rust-lang/crates.io-index".winapi."0.3.9" { inherit profileName; };
}; };
}); });
@ -1156,12 +1157,12 @@ in
registry = "registry+https://github.com/rust-lang/crates.io-index"; registry = "registry+https://github.com/rust-lang/crates.io-index";
src = fetchCratesIo { inherit name version; sha256 = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"; }; src = fetchCratesIo { inherit name version; sha256 = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"; };
features = builtins.concatLists [ features = builtins.concatLists [
(lib.optional (rootFeatures' ? "squiggle-mc-cached-wasm/wee_alloc") "memoryapi") (lib.optional (rootFeatures' ? "quri-squiggle-mc/default" || rootFeatures' ? "quri-squiggle-mc/wee_alloc") "memoryapi")
[ "minwindef" ] [ "minwindef" ]
[ "ntsecapi" ] [ "ntsecapi" ]
[ "profileapi" ] [ "profileapi" ]
(lib.optional (rootFeatures' ? "squiggle-mc-cached-wasm/wee_alloc") "synchapi") (lib.optional (rootFeatures' ? "quri-squiggle-mc/default" || rootFeatures' ? "quri-squiggle-mc/wee_alloc") "synchapi")
(lib.optional (rootFeatures' ? "squiggle-mc-cached-wasm/wee_alloc") "winbase") (lib.optional (rootFeatures' ? "quri-squiggle-mc/default" || rootFeatures' ? "quri-squiggle-mc/wee_alloc") "winbase")
[ "winnt" ] [ "winnt" ]
]; ];
dependencies = { dependencies = {

View File

@ -1,6 +1,6 @@
# You must change these to your own details. # You must change these to your own details.
[package] [package]
name = "squiggle-mc-cached-wasm" name = "quri-squiggle-mc"
description = "Cached and parallel Monte Carlo simulations in WebAssembly" description = "Cached and parallel Monte Carlo simulations in WebAssembly"
version = "0.0.1" version = "0.0.1"
authors = ["Quinn <quinn@quantifieduncertainty.org>"] authors = ["Quinn <quinn@quantifieduncertainty.org>"]
@ -20,13 +20,17 @@ lto = true
[features] [features]
# If you uncomment this line, it will enable `wee_alloc`: # If you uncomment this line, it will enable `wee_alloc`:
#default = ["wee_alloc"] default = ["wee_alloc"]
[dependencies] [dependencies]
# The `wasm-bindgen` crate provides the bare minimum functionality needed # The `wasm-bindgen` crate provides the bare minimum functionality needed
# to interact with JavaScript. # to interact with JavaScript.
wasm-bindgen = "0.2.45" wasm-bindgen = "0.2.45"
# The `web-sys` crate allows you to interact with the various browser APIs,
# like the DOM.
web-sys = { version = "0.3.59", features = ["console"] }
# `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size # `wee_alloc` is a tiny allocator for wasm that is only ~1K in code size
# compared to the default allocator's ~10K. However, it is slower than the default # compared to the default allocator's ~10K. However, it is slower than the default
# allocator, so it's not enabled by default. # allocator, so it's not enabled by default.
@ -40,12 +44,6 @@ statistics = "0.4.1"
kernel_density = "0.0.1" kernel_density = "0.0.1"
cached = { version = "0.38.0", features = ["wasm"] } cached = { version = "0.38.0", features = ["wasm"] }
# The `web-sys` crate allows you to interact with the various browser APIs,
# like the DOM.
[dependencies.web-sys]
version = "0.3.22"
features = ["console"]
# The `console_error_panic_hook` crate provides better debugging of panics by # The `console_error_panic_hook` crate provides better debugging of panics by
# logging them with `console.error`. This is great for development, but requires # logging them with `console.error`. This is great for development, but requires
# all the `std::fmt` and `std::panicking` infrastructure, so it's only enabled # all the `std::fmt` and `std::panicking` infrastructure, so it's only enabled

View File

@ -1,8 +1,10 @@
# `@quri/par-cached-monte-carlo` - parallel Monte Carlo with memoization # `@quri/squiggle-mc` - parallel Monte Carlo with memoization for the `@quri/squiggle-lang` javascript interface
## How to install ## How to install
Please run `yarn` at hte monorepo level Please run `yarn` at the monorepo level.
In this subrepo, please run `./cargo-refresh-nix.sh` every time `Cargo.toml`/`Cargo.lock` is modified, it requires nix with flakes.
## How to run in debug mode ## How to run in debug mode
@ -20,6 +22,8 @@ yarn build
## How to run unit tests ## How to run unit tests
These are the headless browser tests, which will attempt to download and install drivers, and may fail.
```sh ```sh
# Runs tests in Firefox # Runs tests in Firefox
yarn test -- --firefox yarn test -- --firefox

View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
nix run github:cargo2nix/cargo2nix

View File

@ -1,6 +1,6 @@
{ {
"author": "Quinn Dougherty <quinnd@riseup.net>", "author": "Quinn Dougherty <quinnd@riseup.net>",
"name": "@quri/par-cached-monte-carlo", "name": "@quri/squiggle-mc",
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"build": "rimraf dist pkg && webpack", "build": "rimraf dist pkg && webpack",

View File

@ -41,7 +41,7 @@
], ],
"author": "Quantified Uncertainty Research Institute", "author": "Quantified Uncertainty Research Institute",
"dependencies": { "dependencies": {
"@quri/par-cached-monte-carlo": "file:../squiggle-mc-cached/pkg", "@quri/squiggle-mc": "^0.0.1",
"@rescript/std": "^9.1.4", "@rescript/std": "^9.1.4",
"@stdlib/stats": "^0.0.13", "@stdlib/stats": "^0.0.13",
"jstat": "^1.9.5", "jstat": "^1.9.5",

View File

@ -1,5 +0,0 @@
node_modules
/dist
/target
/pkg
/wasm-pack.log

View File

@ -1,2 +0,0 @@
#!/usr/bin/env bash
cargo2nix