Files
dioxus/flake.nix
T
Evan AlmloffandJonathan Kelley c977cc125e Switch const serialize to use CBOR (#4932)
* implement const cbor encoding + decoding for basic types

* implement map encoding and decoding

* fix map test

* all tests passing

* dynamically sized arrays

* smaller str encoding

* swap array and list and add more documentation

* move serialization and deserialization for each struct together

* support both legacy and new assets

* bump const serialize version

* fix asset conversion code

* pull out manganis symbol struct from tuble

* test reading old asset versions

* more list/array cleanup and bump rust version

* fix clippy

* switch cli opt port

* install playwright deps

* split cli-optimization package to avoid two dioxus' in the same crate

* fix clippy

* force the toast.png asset to be included in the linker stage #[used] has platform depedant behavior

* bundle both formats in the link section and only use the asset the cli changed

* remove sudo which doesn't exist on windows

* add binstall to the playwright workflow

* separate bin target for the old cli

* lockfile

* cargo update to get versions shaken out

* notes on binstalls, add back `.read()` for compat

* use 0.8.0-alpha.0 for const-serialize instead of 0.8

this ensures we can still publish breaking changes on 0.8 without taking over the full version

* fix clippy in example

* small debug nits

* update rust-overlay in nix

* fix flake?

* migrate to new structure

* just comment out binstalls

* just remove old test harness

---------

Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
2025-12-28 21:49:34 -05:00

122 lines
3.5 KiB
Nix

{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
systems.url = "github:nix-systems/default";
rust-overlay.url = "github:oxalica/rust-overlay";
# crane.url = "github:ipetkov/crane";
# crane.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;
perSystem =
{
config,
self',
pkgs,
lib,
system,
...
}:
let
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
extensions = [
"rust-src"
"rust-analyzer"
"clippy"
];
};
rustBuildInputs = [
pkgs.openssl
pkgs.libiconv
pkgs.pkg-config
]
++ lib.optionals pkgs.stdenv.isLinux [
pkgs.glib
pkgs.gtk3
pkgs.libsoup_3
pkgs.webkitgtk_4_1
pkgs.xdotool
]
++ lib.optionals pkgs.stdenv.isDarwin [
pkgs.apple-sdk
pkgs.libiconv
];
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
rustPackage =
package:
{
binary ? package,
features ? [ ],
}:
(pkgs.makeRustPlatform {
cargo = rustToolchain;
rustc = rustToolchain;
}).buildRustPackage
{
pname = package;
version = cargoToml.package.version;
src = pkgs.lib.cleanSource ./.;
cargoLock.lockFile = ./Cargo.lock;
buildInputs = rustBuildInputs;
nativeBuildInputs = [
rustToolchain
pkgs.pkg-config
];
buildPhase = ''
mkdir -p .cargo
cp ${./Cargo.lock} Cargo.lock
cargo build --release --package ${package} ${
lib.concatStringsSep " " (map (f: "--features ${f}") features)
}
'';
installPhase = ''
mkdir -p $out/bin
ls -alR target/release
cp target/release/${binary} $out/bin/
'';
doCheck = false; # Disable tests to avoid building deps for them
};
# This is useful when building crates as packages
# Note that it does require a `Cargo.lock` which this repo does not have
# craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rustToolchain;
in
{
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
inputs.rust-overlay.overlays.default
];
};
packages.dioxus-cli = (
rustPackage "dioxus-cli" {
binary = "dx";
features = [ "no-downloads" ];
}
);
devShells.default = pkgs.mkShell {
name = "dioxus-dev";
buildInputs = rustBuildInputs;
nativeBuildInputs = [
# Add shell dependencies here
rustToolchain
];
shellHook = ''
# For rust-analyzer 'hover' tooltips to work.
export RUST_SRC_PATH="${rustToolchain}/lib/rustlib/src/rust/library";
'';
};
};
};
}