Compare commits

..

No commits in common. "876fa8fb33c49847173e177e669b36d49a2621cf" and "cda5b02a3704fbaf920d837ee9afa26ab12f1043" have entirely different histories.

10 changed files with 62 additions and 87 deletions

70
flake.lock generated
View File

@ -16,28 +16,6 @@
"type": "github"
}
},
"fenix": {
"inputs": {
"nixpkgs": [
"naersk",
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1752475459,
"narHash": "sha256-z6QEu4ZFuHiqdOPbYss4/Q8B0BFhacR8ts6jO/F/aOU=",
"owner": "nix-community",
"repo": "fenix",
"rev": "bf0d6f70f4c9a9cf8845f992105652173f4b617f",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
@ -87,15 +65,14 @@
},
"naersk": {
"inputs": {
"fenix": "fenix",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1752689277,
"narHash": "sha256-uldUBFkZe/E7qbvxa3mH1ItrWZyT6w1dBKJQF/3ZSsc=",
"lastModified": 1671096816,
"narHash": "sha256-ezQCsNgmpUHdZANDCILm3RvtO1xH8uujk/+EqNvzIOg=",
"owner": "nix-community",
"repo": "naersk",
"rev": "0e72363d0938b0208d6c646d10649164c43f4d64",
"rev": "d998160d6a076cfe8f9741e56aeec7e267e3e114",
"type": "github"
},
"original": {
@ -106,27 +83,25 @@
},
"nixpkgs": {
"locked": {
"lastModified": 1752077645,
"narHash": "sha256-HM791ZQtXV93xtCY+ZxG1REzhQenSQO020cu6rHtAPk=",
"lastModified": 1678987615,
"narHash": "sha256-lF4agoB7ysQGNHRXvOqxtSKIZrUZwClA85aASahQlYM=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "be9e214982e20b8310878ac2baa063a961c1bdf6",
"rev": "194c2aa446b2b059886bb68be15ef6736d5a8c31",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
"id": "nixpkgs",
"type": "indirect"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1753135609,
"narHash": "sha256-//xMo8MwSw1HoTnIk455J7NIJpsDqwVyD69MOXb7gZM=",
"lastModified": 1719152388,
"narHash": "sha256-pHg0nzAa2ZM+zFamfsY7ZvVaB19pMr5wl4G5nO0J7eU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5d9316e7fb2d6395818d506ef997530eba1545b7",
"rev": "be54c7d931a68ba6a79f097ce979288e90a74288",
"type": "github"
},
"original": {
@ -146,23 +121,6 @@
"rust-overlay": "rust-overlay"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1752428706,
"narHash": "sha256-EJcdxw3aXfP8Ex1Nm3s0awyH9egQvB2Gu+QEnJn2Sfg=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "591e3b7624be97e4443ea7b5542c191311aa141d",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
},
"rust-overlay": {
"inputs": {
"nixpkgs": [
@ -170,11 +128,11 @@
]
},
"locked": {
"lastModified": 1750964660,
"narHash": "sha256-YQ6EyFetjH1uy5JhdhRdPe6cuNXlYpMAQePFfZj4W7M=",
"lastModified": 1718681902,
"narHash": "sha256-E/T7Ge6ayEQe7FVKMJqDBoHyLhRhjc6u9CmU8MyYfy0=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "04f0fcfb1a50c63529805a798b4b5c21610ff390",
"rev": "16c8ad83297c278eebe740dea5491c1708960dd1",
"type": "github"
},
"original": {

View File

@ -2,16 +2,16 @@
description = "kitchen";
# Pin nixpkgs
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
gitignore = { url = "github:hercules-ci/gitignore.nix"; flake = false; };
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay?ref=stable";
inputs.nixpkgs.follows = "nixpkgs";
};
naersk.url = "github:nix-community/naersk";
flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
cargo-wasm2map-src = { url = "github:mtolmacs/wasm2map"; flake = false; };
nixpkgs.url = "github:NixOS/nixpkgs";
gitignore = { url = "github:hercules-ci/gitignore.nix"; flake = false; };
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay?ref=stable";
inputs.nixpkgs.follows = "nixpkgs";
};
naersk.url = "github:nix-community/naersk";
flake-compat = { url = "github:edolstra/flake-compat"; flake = false; };
cargo-wasm2map-src = { url = "github:mtolmacs/wasm2map"; flake = false; };
};
outputs = {nixpkgs, flake-utils, rust-overlay, naersk, cargo-wasm2map-src, ...}:
let
@ -26,7 +26,7 @@
let
overlays = [ rust-overlay.overlays.default ];
pkgs = import nixpkgs { inherit system overlays; };
rust-wasm = pkgs.rust-bin.stable."1.87.0".default.override {
rust-wasm = pkgs.rust-bin.stable."1.77.0".default.override {
extensions = [ "rust-src" ];
# Add wasm32 as an extra target besides the native target.
targets = [ "wasm32-unknown-unknown" ];

View File

@ -1,5 +1,8 @@
let
lib = import ../lib/lib.nix;
in
{ pkgs, rust-wasm, wasm-pack-hermetic, wasm-bindgen, cargo-wasm2map }:
with pkgs;
mkShell {
buildInputs = (with pkgs; [wasm-bindgen wasm-pack-hermetic llvm clang rust-wasm binaryen cargo-wasm2map]);
buildInputs = (lib.darwin-sdk pkgs) ++ (with pkgs; [wasm-bindgen wasm-pack-hermetic llvm clang rust-wasm binaryen cargo-wasm2map]);
}

View File

@ -1,3 +1,6 @@
let
lib = import ../lib/lib.nix;
in
{pkgs ? (import <nixpkgs>) {},
# Because it's a workspace we need the other crates available as source
root,
@ -12,7 +15,7 @@ with pkgs;
inherit version;
buildInputs = [ rust-wasm libclang ];
# However the crate we are building has it's root in specific crate.
nativeBuildInputs = [llvm clang rust-bindgen];
nativeBuildInputs = (lib.darwin-sdk pkgs) ++ [llvm clang rust-bindgen];
src = root;
cargoBuildOptions = opts: opts ++ ["-p" "${pname}" ];
postPatch = ''
@ -22,4 +25,4 @@ with pkgs;
'';
# We have to tell libproc where the libclang.dylib lives
LIBCLANG_PATH="${libclang.lib}/lib/";
})
})

7
nix/lib/lib.nix Normal file
View File

@ -0,0 +1,7 @@
{
darwin-sdk = pkgs: with pkgs; (if stdenv.isDarwin then (with darwin.apple_sdk.frameworks; [
xcbuild
Security
fixDarwinDylibNames
]) else [ ]);
}

View File

@ -1,3 +1,6 @@
let
my-lib = import ../lib/lib.nix;
in
{ pkgs
, lib
, rustPlatform
@ -22,15 +25,14 @@ rustPlatform.buildRustPackage rec {
sha256 = "sha256-IPxP68xtNSpwJjV2yNMeepAS0anzGl02hYlSTvPocz8=";
};
cargoHash = "sha256-EsGFW1f9+E5NnMadP/0rRzFCxVJQb0mlTLz/3zYQ5Ac=";
cargoSha256 = "sha256-pBeQaG6i65uJrJptZQLuIaCb/WCQMhba1Z1OhYqA8Zc=";
nativeBuildInputs = [ pkg-config ];
buildInputs = [ openssl curl ];
buildInputs = [ openssl curl ] ++ (my-lib.darwin-sdk pkgs);
nativeCheckInputs = [ nodejs ];
# other tests require it to be ran in the wasm-bindgen monorepo
#cargoTestFlags = [ "--test=reference" ];
doCheck = false;
cargoTestFlags = [ "--test=reference" ];
}

View File

@ -1,3 +1,6 @@
let
my-lib = import ../lib/lib.nix;
in
{pkgs,
naersk-lib,
rust-wasm,
@ -7,7 +10,7 @@ with pkgs;
pname = "wasm-pack";
version = "v0.12.1";
buildInputs = [ rust-wasm pkgs.openssl curl];
nativeBuildInputs =[llvm clang pkg-config];
nativeBuildInputs = (my-lib.darwin-sdk pkgs) ++ [llvm clang pkg-config];
OPENSSL_NO_VENDOR=1;
# The checks use network so disable them here
doCheck = false;

View File

@ -15,5 +15,5 @@ EXAMPLES=${EXAMPLES:-../examples}
echo Starting server serving ${EXAMPLES}
mkdir -p .session_store
make kitchen
./target/debug/kitchen --verbose debug serve --listen 127.0.0.1:3030 --session_dir .session_store --dir ${EXAMPLES} --tls --cert ~/tls-certs/localhost+1.pem --cert_key ~/tls-certs/localhost+1-key.pem $@
./target/debug/kitchen --verbose debug serve --listen 0.0.0.0:3030 --session_dir .session_store --dir ${EXAMPLES} --tls --cert ~/tls-certs/localhost+2.pem --cert_key ~/tls-certs/localhost+2-key.pem $@
# This is ghetto but I'm doing it anyway

2
run.sh
View File

@ -14,5 +14,5 @@
EXAMPLES=${EXAMPLES:-../examples}
echo Starting server serving ${EXAMPLES}
mkdir .session_store
nix run .\#kitchenDebug -- --verbose debug serve --session_dir .session_store --dir ${EXAMPLES} --tls --cert ~/tls-certs/localhost+1.pem --cert_key ~/tls-certs/localhost+1-key.pem $@
nix run .\#kitchenDebug -- --verbose debug serve --session_dir .session_store --dir ${EXAMPLES} --tls --cert ~/tls-certs/localhost+2.pem --cert_key ~/tls-certs/localhost+2-key.pem $@
# This is ghetto but I'm doing it anyway

View File

@ -466,25 +466,24 @@ impl MessageMapper<Message, AppState> for StateMachine {
let store = self.store.clone();
let local_store = self.local_store.clone();
spawn_local_scoped(cx, async move {
if let Ok(Some(mut plan)) = store
if let Some(mut plan) = store
.fetch_plan_for_date(&date)
.await
.expect("Failed to fetch plan for date")
{
// Note(jwall): This is a little unusual but because this
// is async code we can't rely on the set below.
original_copy.recipe_counts =
BTreeMap::from_iter(plan.drain(0..).map(|(k, v)| (k, v as u32)));
let (filtered, modified, extras) = store
.fetch_inventory_for_date(&date)
.await
.expect("Failed to fetch inventory_data for date");
original_copy.modified_amts = modified;
original_copy.filtered_ingredients = filtered;
original_copy.extras = extras;
} else {
store.store_plan_for_date(Vec::new(), &date).await.expect("failed to set plan on server");
}
let (filtered, modified, extras) = store
.fetch_inventory_for_date(&date)
.await
.expect("Failed to fetch inventory_data for date");
original_copy.plan_dates.insert(date.clone());
original_copy.modified_amts = modified;
original_copy.filtered_ingredients = filtered;
original_copy.extras = extras;
original_copy.selected_plan_date = Some(date.clone());
store
.store_plan_for_date(vec![], &date)