91 lines
2.6 KiB
Nix
91 lines
2.6 KiB
Nix
{
|
|
description = "Wordle-Solver";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
|
rust-overlay = {
|
|
url = "github:oxalica/rust-overlay";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
crate2nix = {
|
|
url = "github:nix-community/crate2nix";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
};
|
|
|
|
outputs = inputs @ {
|
|
flake-parts,
|
|
crate2nix,
|
|
rust-overlay,
|
|
...
|
|
}:
|
|
flake-parts.lib.mkFlake {inherit inputs;} {
|
|
systems = [
|
|
"aarch64-linux"
|
|
"aarch64-darwin"
|
|
"x86_64-darwin"
|
|
"x86_64-linux"
|
|
];
|
|
|
|
perSystem = {
|
|
pkgs,
|
|
system,
|
|
self',
|
|
...
|
|
}: let
|
|
# Use rust-bin to generate the toolchain from rust-toolchain.toml
|
|
rust-toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
|
|
|
cross-pkgs = pkgs.pkgsCross.wasm32-unknown-none;
|
|
|
|
toolchain = pkgs.callPackage ./nix/with-toolchain.nix {
|
|
cargo = rust-toolchain;
|
|
rustc = rust-toolchain;
|
|
};
|
|
crossToolchain = cross-pkgs.callPackage ./nix/with-toolchain.nix {
|
|
cargo = rust-toolchain;
|
|
rustc = rust-toolchain;
|
|
};
|
|
|
|
wasm-bindgen = toolchain.pkgs.callPackage ./nix/wasm-bindgen.nix {};
|
|
|
|
root-crate = pkgs.callPackage ./nix/root-crate.nix {
|
|
cargo = rust-toolchain;
|
|
rustc = rust-toolchain;
|
|
inherit crate2nix;
|
|
};
|
|
in {
|
|
# Overlay pkgs with rust-bin
|
|
_module.args.pkgs = import inputs.nixpkgs {
|
|
inherit system;
|
|
overlays = [(import rust-overlay)];
|
|
config.allowUnsupportedSystem = true;
|
|
};
|
|
|
|
packages = {
|
|
wordle-solver-web = pkgs.callPackage ./nix/wordle-solver-web.nix {inherit (self'.packages) wordle-solver-wasm-pkg;};
|
|
wordle-solver-wasm = crossToolchain.pkgs.callPackage ./nix/wordle-solver-wasm.nix {};
|
|
wordle-solver-wasm-pkg = pkgs.callPackage ./nix/wordle-solver-wasm-pkg.nix {
|
|
inherit wasm-bindgen root-crate;
|
|
inherit (self'.packages) wordle-solver-wasm;
|
|
};
|
|
wordle-solver = root-crate.build;
|
|
default = self'.packages.wordle-solver;
|
|
};
|
|
|
|
devShells.default = pkgs.mkShell {
|
|
buildInputs = [
|
|
rust-toolchain
|
|
wasm-bindgen
|
|
pkgs.wasm-pack
|
|
pkgs.nodejs
|
|
pkgs.typescript-language-server
|
|
pkgs.vscode-langservers-extracted
|
|
pkgs.yarn
|
|
];
|
|
};
|
|
};
|
|
};
|
|
}
|