2021-12-31 13:30:27 -05:00
|
|
|
{
|
|
|
|
description = "kitchen";
|
2022-01-03 19:13:42 -05:00
|
|
|
# Pin nixpkgs
|
2022-02-25 19:10:55 -05:00
|
|
|
inputs = {
|
2025-06-02 17:43:10 -04:00
|
|
|
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; };
|
2022-02-25 19:10:55 -05:00
|
|
|
};
|
2024-07-12 00:18:35 -04:00
|
|
|
outputs = {nixpkgs, flake-utils, rust-overlay, naersk, cargo-wasm2map-src, ...}:
|
2021-12-31 13:30:27 -05:00
|
|
|
let
|
2022-02-28 14:28:21 -05:00
|
|
|
kitchenGen = (import ./nix/kitchen/default.nix);
|
2022-02-25 19:10:55 -05:00
|
|
|
kitchenWasmGen = (import ./nix/kitchenWasm/default.nix);
|
2022-02-28 17:18:55 -05:00
|
|
|
moduleGen = (import ./nix/kitchen/module.nix);
|
2023-03-21 17:24:11 -04:00
|
|
|
wasm-packGen = (import ./nix/wasm-pack/default.nix);
|
2023-03-22 17:54:04 -04:00
|
|
|
wasm-bindgenGen = (import ./nix/wasm-bindgen/default.nix);
|
2023-03-29 19:44:09 -04:00
|
|
|
version = "0.2.25";
|
2021-12-31 13:30:27 -05:00
|
|
|
in
|
|
|
|
flake-utils.lib.eachDefaultSystem (system:
|
2022-02-25 19:10:55 -05:00
|
|
|
let
|
2022-08-07 16:24:47 -04:00
|
|
|
overlays = [ rust-overlay.overlays.default ];
|
2022-03-06 15:16:30 -05:00
|
|
|
pkgs = import nixpkgs { inherit system overlays; };
|
2025-06-02 17:43:10 -04:00
|
|
|
rust-wasm = pkgs.rust-bin.stable."1.87.0".default.override {
|
2022-03-06 15:16:30 -05:00
|
|
|
extensions = [ "rust-src" ];
|
2022-08-07 16:24:47 -04:00
|
|
|
# Add wasm32 as an extra target besides the native target.
|
2022-03-06 15:16:30 -05:00
|
|
|
targets = [ "wasm32-unknown-unknown" ];
|
|
|
|
};
|
2022-08-07 16:24:47 -04:00
|
|
|
# make sure to use our rust-wasm build target as the rust toolchain
|
|
|
|
# in naersk.
|
|
|
|
naersk-lib = pkgs.callPackage naersk {
|
|
|
|
rustc = rust-wasm;
|
|
|
|
cargo = rust-wasm;
|
|
|
|
};
|
2023-03-22 16:20:28 -04:00
|
|
|
# TODO(jwall): Do the same thing for wasm-bindgen as well?
|
2023-03-21 17:24:11 -04:00
|
|
|
# We've run into a few problems with the bundled wasm-pack in nixpkgs.
|
|
|
|
# Better to just control this part of our toolchain directly.
|
|
|
|
wasm-pack = wasm-packGen {
|
|
|
|
inherit rust-wasm naersk-lib pkgs;
|
|
|
|
};
|
2024-07-12 00:18:35 -04:00
|
|
|
cargo-wasm2map = naersk-lib.buildPackage {
|
|
|
|
pname = "cargo-wasm2map";
|
|
|
|
version = "v0.1.0";
|
|
|
|
build-inputs = [ rust-wasm ];
|
|
|
|
src = cargo-wasm2map-src;
|
|
|
|
cargoBuildOptions = opts: opts ++ ["-p" "cargo-wasm2map" ];
|
|
|
|
};
|
2023-03-22 17:54:04 -04:00
|
|
|
wasm-bindgen = pkgs.callPackage wasm-bindgenGen { inherit pkgs; };
|
2022-02-25 19:10:55 -05:00
|
|
|
kitchenWasm = kitchenWasmGen {
|
2024-07-12 00:18:35 -04:00
|
|
|
inherit pkgs rust-wasm wasm-bindgen version cargo-wasm2map;
|
2024-06-30 20:31:47 -05:00
|
|
|
lockFile = ./Cargo.lock;
|
|
|
|
outputHashes = {
|
|
|
|
# I'm maintaining some patches for these so the lockfile hashes are a little
|
|
|
|
# incorrect. We override those here.
|
|
|
|
"wasm-web-component-0.2.0" = "sha256-quuPgzGb2F96blHmD3BAUjsWQYbSyJGZl27PVrwL92k=";
|
|
|
|
"sycamore-0.8.2" = "sha256-D968+8C5EelGGmot9/LkAlULZOf/Cr+1WYXRCMwb1nQ=";
|
|
|
|
};
|
2022-02-25 19:10:55 -05:00
|
|
|
};
|
2022-02-28 14:28:21 -05:00
|
|
|
kitchen = (kitchenGen {
|
2022-08-07 16:24:47 -04:00
|
|
|
inherit pkgs version naersk-lib kitchenWasm rust-wasm;
|
2022-02-28 14:28:21 -05:00
|
|
|
# Because it's a workspace we need the other crates available as source
|
2022-10-11 16:49:12 -04:00
|
|
|
# TODO(jwall): gitignoreSource is broken right now due to being impure.
|
|
|
|
#root = (pkgs.callPackage gitignore { }).gitignoreSource ./.;
|
|
|
|
root = ./.;
|
2022-02-28 14:28:21 -05:00
|
|
|
});
|
2023-01-07 17:48:46 -05:00
|
|
|
kitchenWasmDebug = kitchenWasmGen {
|
2024-09-23 20:05:43 -04:00
|
|
|
inherit pkgs rust-wasm wasm-bindgen version cargo-wasm2map;
|
|
|
|
lockFile = ./Cargo.lock;
|
|
|
|
outputHashes = {
|
|
|
|
# I'm maintaining some patches for these so the lockfile hashes are a little
|
|
|
|
# incorrect. We override those here.
|
|
|
|
"wasm-web-component-0.2.0" = "sha256-quuPgzGb2F96blHmD3BAUjsWQYbSyJGZl27PVrwL92k=";
|
|
|
|
"sycamore-0.8.2" = "sha256-D968+8C5EelGGmot9/LkAlULZOf/Cr+1WYXRCMwb1nQ=";
|
|
|
|
};
|
|
|
|
#features = "--features debug_logs";
|
2023-01-07 17:48:46 -05:00
|
|
|
};
|
|
|
|
kitchenDebug = (kitchenGen {
|
|
|
|
inherit pkgs version naersk-lib rust-wasm;
|
|
|
|
kitchenWasm = kitchenWasmDebug;
|
|
|
|
# Because it's a workspace we need the other crates available as source
|
|
|
|
# TODO(jwall): gitignoreSource is broken right now due to being impure.
|
|
|
|
#root = (pkgs.callPackage gitignore { }).gitignoreSource ./.;
|
|
|
|
root = ./.;
|
|
|
|
});
|
2022-02-28 17:18:55 -05:00
|
|
|
module = moduleGen {inherit kitchen;};
|
2022-02-25 19:10:55 -05:00
|
|
|
in
|
2021-12-31 13:30:27 -05:00
|
|
|
{
|
2022-02-25 19:10:55 -05:00
|
|
|
packages = {
|
2022-07-21 18:35:09 -04:00
|
|
|
inherit kitchenWasm
|
2022-02-28 14:28:21 -05:00
|
|
|
kitchen
|
2023-01-07 17:48:46 -05:00
|
|
|
kitchenWasmDebug
|
|
|
|
kitchenDebug
|
2022-02-25 19:10:55 -05:00
|
|
|
;
|
|
|
|
};
|
2022-02-28 14:28:21 -05:00
|
|
|
defaultPackage = kitchen;
|
2022-02-28 17:18:55 -05:00
|
|
|
nixosModules.kitchen = module;
|
2022-03-06 15:16:30 -05:00
|
|
|
defaultApp = {
|
|
|
|
type = "app";
|
|
|
|
program = "${kitchen}/bin/kitchen";
|
|
|
|
};
|
2023-03-21 17:24:11 -04:00
|
|
|
devShell = pkgs.callPackage ./nix/devShell/default.nix {
|
2024-07-12 00:18:35 -04:00
|
|
|
inherit rust-wasm wasm-bindgen cargo-wasm2map;
|
2023-03-21 17:24:11 -04:00
|
|
|
wasm-pack-hermetic = wasm-pack;
|
|
|
|
};
|
2021-12-31 13:30:27 -05:00
|
|
|
}
|
|
|
|
);
|
2023-11-25 22:09:03 -05:00
|
|
|
}
|