nix + web stuff
This commit is contained in:
parent
4c9def194e
commit
5e01e1762f
1860
Cargo.lock
generated
1860
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
14
Cargo.toml
14
Cargo.toml
@ -33,17 +33,17 @@ strip = false
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
parsing = { path = "./parsing" }
|
parsing = { path = "./parsing" }
|
||||||
eframe = { git = "https://github.com/titaniumtown/egui.git", default-features = false, features = [
|
eframe = { git = "https://github.com/titaniumtown/egui.git", rev = "b088efb9fa917845ecb54729a0d2fc592d2399e7", default-features = false, features = [
|
||||||
"glow",
|
"glow",
|
||||||
] }
|
] }
|
||||||
egui = { git = "https://github.com/titaniumtown/egui.git", default-features = false, features = [
|
egui = { git = "https://github.com/titaniumtown/egui.git", rev = "b088efb9fa917845ecb54729a0d2fc592d2399e7", default-features = false, features = [
|
||||||
"serde",
|
"serde",
|
||||||
] }
|
] }
|
||||||
epaint = { git = "https://github.com/titaniumtown/egui.git", default-features = false , features = [
|
epaint = { git = "https://github.com/titaniumtown/egui.git", rev = "b088efb9fa917845ecb54729a0d2fc592d2399e7", default-features = false , features = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
] }
|
] }
|
||||||
emath = { git = "https://github.com/titaniumtown/egui.git", default-features = false }
|
emath = { git = "https://github.com/titaniumtown/egui.git", rev = "b088efb9fa917845ecb54729a0d2fc592d2399e7", default-features = false }
|
||||||
egui_plot = { git = "https://github.com/titaniumtown/egui.git", default-features = false }
|
egui_plot = { git = "https://github.com/titaniumtown/egui.git", rev = "b088efb9fa917845ecb54729a0d2fc592d2399e7", default-features = false }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -62,10 +62,10 @@ benchmarks = { path = "./benchmarks" }
|
|||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
shadow-rs = "0.12"
|
shadow-rs = "0.12"
|
||||||
epaint = { git = "https://github.com/titaniumtown/egui.git", default-features = false, features = [
|
epaint = { git = "https://github.com/titaniumtown/egui.git", rev = "b088efb9fa917845ecb54729a0d2fc592d2399e7", default-features = false, features = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
] }
|
] }
|
||||||
egui = { git = "https://github.com/titaniumtown/egui.git", default-features = false, features = [
|
egui = { git = "https://github.com/titaniumtown/egui.git", rev = "b088efb9fa917845ecb54729a0d2fc592d2399e7", default-features = false, features = [
|
||||||
"serde",
|
"serde",
|
||||||
] }
|
] }
|
||||||
bincode = "1.3"
|
bincode = "1.3"
|
||||||
|
|||||||
100
flake.lock
generated
Normal file
100
flake.lock
generated
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-utils": {
|
||||||
|
"inputs": {
|
||||||
|
"systems": "systems"
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1731533236,
|
||||||
|
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1764517877,
|
||||||
|
"narHash": "sha256-pp3uT4hHijIC8JUK5MEqeAWmParJrgBVzHLNfJDZxg4=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "2d293cbfa5a793b4c50d17c05ef9e385b90edf6c",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"rust-overlay": "rust-overlay",
|
||||||
|
"simon-egui": "simon-egui"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust-overlay": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1764729618,
|
||||||
|
"narHash": "sha256-z4RA80HCWv2los1KD346c+PwNPzMl79qgl7bCVgz8X0=",
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"rev": "52764074a85145d5001bf0aa30cb71936e9ad5b8",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"simon-egui": {
|
||||||
|
"flake": false,
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1764730109,
|
||||||
|
"narHash": "sha256-vNETC0oq6tKJKF8KOGQKKIWRom38m0RwGgi3MPBrRx8=",
|
||||||
|
"owner": "Titaniumtown",
|
||||||
|
"repo": "egui",
|
||||||
|
"rev": "b63c21d70150f1b414370f0f9a8af56e886662f4",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "Titaniumtown",
|
||||||
|
"repo": "egui",
|
||||||
|
"rev": "b63c21d70150f1b414370f0f9a8af56e886662f4",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"systems": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1681028828,
|
||||||
|
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nix-systems",
|
||||||
|
"repo": "default",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
214
flake.nix
Normal file
214
flake.nix
Normal file
@ -0,0 +1,214 @@
|
|||||||
|
{
|
||||||
|
description = "YTBN Graphing Software - Web-compatible graphing calculator";
|
||||||
|
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
rust-overlay = {
|
||||||
|
url = "github:oxalica/rust-overlay";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
simon-egui = {
|
||||||
|
url = "github:Titaniumtown/egui/b63c21d70150f1b414370f0f9a8af56e886662f4";
|
||||||
|
flake = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs =
|
||||||
|
{
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
flake-utils,
|
||||||
|
rust-overlay,
|
||||||
|
simon-egui,
|
||||||
|
}:
|
||||||
|
flake-utils.lib.eachDefaultSystem (
|
||||||
|
system:
|
||||||
|
let
|
||||||
|
overlays = [ (import rust-overlay) ];
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
inherit system overlays;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Use nightly rust with wasm32 target
|
||||||
|
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
|
||||||
|
targets = [ "wasm32-unknown-unknown" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
rustPlatform = pkgs.makeRustPlatform {
|
||||||
|
cargo = rustToolchain;
|
||||||
|
rustc = rustToolchain;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Create a combined source with the main project and dependencies
|
||||||
|
combinedSrc = pkgs.stdenv.mkDerivation {
|
||||||
|
name = "ytbn-combined-src";
|
||||||
|
phases = [ "installPhase" ];
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/integral_site_rust
|
||||||
|
mkdir -p $out/simon-egui
|
||||||
|
|
||||||
|
cp -r ${./.}/* $out/integral_site_rust/
|
||||||
|
cp -r ${simon-egui}/* $out/simon-egui/
|
||||||
|
|
||||||
|
chmod -R u+w $out
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
# Build the wasm library using rustPlatform
|
||||||
|
wasmLib = rustPlatform.buildRustPackage {
|
||||||
|
pname = "ytbn-graphing-software-wasm";
|
||||||
|
version = "0.1.0";
|
||||||
|
|
||||||
|
src = combinedSrc;
|
||||||
|
sourceRoot = "${combinedSrc.name}/integral_site_rust";
|
||||||
|
|
||||||
|
cargoLock = {
|
||||||
|
lockFile = ./Cargo.lock;
|
||||||
|
outputHashes = {
|
||||||
|
"ecolor-0.25.0" = "sha256-9s5LCngwvIIL43txT6sBs4JlRXqmYt1Kw8hlDnwx+DI=";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
python3Packages.fonttools
|
||||||
|
pkg-config
|
||||||
|
clang
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
openssl
|
||||||
|
zstd
|
||||||
|
];
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
|
||||||
|
export HOME=$TMPDIR
|
||||||
|
|
||||||
|
cargo build \
|
||||||
|
--release \
|
||||||
|
--lib \
|
||||||
|
--target wasm32-unknown-unknown
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
mkdir -p $out/lib
|
||||||
|
cp target/wasm32-unknown-unknown/release/*.wasm $out/lib/
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
|
||||||
|
doCheck = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
# Final web package with wasm-bindgen processing
|
||||||
|
ytbn-graphing-software-web = pkgs.stdenv.mkDerivation {
|
||||||
|
pname = "ytbn-graphing-software-web";
|
||||||
|
version = "0.1.0";
|
||||||
|
|
||||||
|
src = ./.;
|
||||||
|
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
wasm-bindgen-cli
|
||||||
|
binaryen
|
||||||
|
];
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
|
||||||
|
# Generate JS bindings
|
||||||
|
wasm-bindgen ${wasmLib}/lib/ytbn_graphing_software.wasm \
|
||||||
|
--out-dir out \
|
||||||
|
--out-name ytbn_graphing_software \
|
||||||
|
--target web \
|
||||||
|
--no-typescript
|
||||||
|
|
||||||
|
# Optimize wasm (enable features used by modern rust wasm targets)
|
||||||
|
wasm-opt out/ytbn_graphing_software_bg.wasm \
|
||||||
|
-O2 --fast-math \
|
||||||
|
--enable-bulk-memory \
|
||||||
|
--enable-nontrapping-float-to-int \
|
||||||
|
--enable-sign-ext \
|
||||||
|
--enable-mutable-globals \
|
||||||
|
-o out/ytbn_graphing_software_bg.wasm
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
runHook preInstall
|
||||||
|
|
||||||
|
mkdir -p $out
|
||||||
|
|
||||||
|
# Copy wasm and js files
|
||||||
|
cp out/ytbn_graphing_software_bg.wasm $out/
|
||||||
|
cp out/ytbn_graphing_software.js $out/
|
||||||
|
|
||||||
|
# Copy static web assets
|
||||||
|
cp www/index.html $out/
|
||||||
|
cp www/manifest.json $out/
|
||||||
|
cp www/sw.js $out/
|
||||||
|
|
||||||
|
# Copy logo
|
||||||
|
cp assets/logo.svg $out/
|
||||||
|
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
|
||||||
|
meta = with pkgs.lib; {
|
||||||
|
description = "Web-compatible graphing calculator similar to Desmos";
|
||||||
|
homepage = "https://github.com/Titaniumtown/YTBN-Graphing-Software";
|
||||||
|
license = licenses.agpl3Only;
|
||||||
|
platforms = platforms.all;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
packages = {
|
||||||
|
default = ytbn-graphing-software-web;
|
||||||
|
web = ytbn-graphing-software-web;
|
||||||
|
wasm = wasmLib;
|
||||||
|
};
|
||||||
|
|
||||||
|
devShells.default = pkgs.mkShell {
|
||||||
|
nativeBuildInputs = with pkgs; [
|
||||||
|
rustToolchain
|
||||||
|
wasm-bindgen-cli
|
||||||
|
binaryen
|
||||||
|
python3Packages.fonttools
|
||||||
|
rust-analyzer
|
||||||
|
pkg-config
|
||||||
|
clang
|
||||||
|
|
||||||
|
# Runtime deps for native builds
|
||||||
|
libxkbcommon
|
||||||
|
libGL
|
||||||
|
wayland
|
||||||
|
xorg.libX11
|
||||||
|
xorg.libXcursor
|
||||||
|
xorg.libXi
|
||||||
|
];
|
||||||
|
|
||||||
|
buildInputs = with pkgs; [
|
||||||
|
openssl
|
||||||
|
zstd
|
||||||
|
];
|
||||||
|
|
||||||
|
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (
|
||||||
|
with pkgs;
|
||||||
|
[
|
||||||
|
libxkbcommon
|
||||||
|
libGL
|
||||||
|
wayland
|
||||||
|
xorg.libX11
|
||||||
|
xorg.libXcursor
|
||||||
|
xorg.libXi
|
||||||
|
]
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user