Compare commits

...

3 Commits

Author SHA1 Message Date
876fa8fb33 wip: flake updates 2025-07-21 19:28:15 -04:00
d4fce72333 chore: update some cert stuff 2025-07-21 19:28:09 -04:00
e59eff8ae7 fix: plan creation was broken 2025-06-02 17:30:48 -04:00
10 changed files with 87 additions and 62 deletions

70
flake.lock generated
View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -15,5 +15,5 @@ EXAMPLES=${EXAMPLES:-../examples}
echo Starting server serving ${EXAMPLES} echo Starting server serving ${EXAMPLES}
mkdir -p .session_store mkdir -p .session_store
make kitchen make kitchen
./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 $@ ./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 $@
# This is ghetto but I'm doing it anyway # This is ghetto but I'm doing it anyway

2
run.sh
View File

@ -14,5 +14,5 @@
EXAMPLES=${EXAMPLES:-../examples} EXAMPLES=${EXAMPLES:-../examples}
echo Starting server serving ${EXAMPLES} echo Starting server serving ${EXAMPLES}
mkdir .session_store mkdir .session_store
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 $@ 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 $@
# This is ghetto but I'm doing it anyway # This is ghetto but I'm doing it anyway

View File

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