cursor-mover-app/flake.nix

181 lines
4.9 KiB
Nix
Raw Normal View History

2026-02-27 21:30:42 +01:00
{
description = "Description for the project";
inputs = {
devenv-root = {
url = "file+file:///dev/null";
flake = false;
};
nixpkgs.url = "github:cachix/devenv-nixpkgs/rolling";
flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
devenv.url = "github:cachix/devenv";
nix2container.url = "github:nlewo/nix2container";
nix2container.inputs.nixpkgs.follows = "nixpkgs";
mk-shell-bin.url = "github:rrbutani/nix-mk-shell-bin";
fenix.url = "github:nix-community/fenix/monthly";
fenix.inputs.nixpkgs.follows = "nixpkgs";
};
nixConfig = {
extra-trusted-public-keys = [
"devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
extra-substituters = [
"https://devenv.cachix.org"
"https://nix-community.cachix.org"
];
};
outputs =
inputs@{ flake-parts, devenv-root, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.devenv.flakeModule
];
systems = [
"x86_64-linux"
"i686-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];
perSystem =
{
2026-03-03 18:08:02 +01:00
#config,
2026-03-07 18:33:15 +01:00
self',
2026-02-27 21:30:42 +01:00
inputs',
pkgs,
2026-03-03 18:08:02 +01:00
#system,
2026-02-27 21:30:42 +01:00
...
}:
2026-03-07 18:33:15 +01:00
let
fnx = inputs'.fenix.packages;
rustToolchain = fnx.combine [
fnx.complete.cargo
fnx.complete.clippy
fnx.complete.rust-src
fnx.complete.rustc
fnx.complete.rustfmt
fnx.targets.wasm32-unknown-unknown.latest.rust-std
];
wasmBindgen =
with pkgs;
rustPlatform.buildRustPackage rec {
pname = "wasm-bindgen-cli";
version = "0.2.114";
src = fetchCrate {
pname = pname;
version = version;
hash = "sha256-xrCym+rFY6EUQFWyWl6OPA+LtftpUAE5pIaElAIVqW0=";
};
2026-02-28 22:24:42 +01:00
2026-03-07 18:33:15 +01:00
cargoDeps = rustPlatform.fetchCargoVendor {
inherit src;
inherit (src) pname version;
hash = "sha256-Z8+dUXPQq7S+Q7DWNr2Y9d8GMuEdSnq00quUR0wDNPM=";
2026-03-02 22:06:15 +01:00
};
2026-03-07 18:33:15 +01:00
nativeBuildInputs = [ pkg-config ];
buildInputs = [
openssl
]
++ lib.optionals stdenv.hostPlatform.isDarwin [
curl
2026-02-27 21:30:42 +01:00
];
2026-03-07 18:33:15 +01:00
nativeCheckInputs = [ nodejs_latest ];
# tests require it to be ran in the wasm-bindgen monorepo
doCheck = false;
};
in
{
packages.default = self'.packages.cursor-mover-app;
packages.cursor-mover-app =
(pkgs.makeRustPlatform {
cargo = rustToolchain;
rustc = rustToolchain;
}).buildRustPackage
{
pname = "cursor-mover-app";
version = "0.1.0";
src = ./.;
2026-02-27 21:30:42 +01:00
2026-03-07 18:33:15 +01:00
nativeBuildInputs = with pkgs; [
wasmBindgen
binaryen
dioxus-cli
breakpointHook
makeWrapper
];
2026-03-03 18:08:02 +01:00
2026-03-07 18:33:15 +01:00
buildPhase = ''
dx bundle --debug-symbols=false --release --web --package cursor-move-webapp
'';
2026-03-03 18:08:02 +01:00
2026-03-07 18:33:15 +01:00
checkPhase = "";
installPhase = "
mkdir -p $out/bin
mkdir -p $out/share
cp -r target/dx/cursor-move-webapp/release/web $out/share/web
makeWrapper $out/share/web/cursor-move-webapp $out/bin/cursor-move-app --chdir $out/share/web
";
cargoLock.lockFile = ./Cargo.lock;
};
devenv.shells.default = {
name = "my-project";
env = {
LIBCLANG_PATH = "${pkgs.libclang.lib}/lib";
2026-02-27 21:30:42 +01:00
};
2026-03-07 18:33:15 +01:00
packages = [
pkgs.dioxus-cli
pkgs.cargo-expand
pkgs.cargo-deny
pkgs.cargo-nextest
pkgs.typos
pkgs.binaryen # wasm-opt
rustToolchain
fnx.rust-analyzer
wasmBindgen
pkgs.libxkbcommon
];
scripts.checkall.exec = ''
set -xeuo pipefail
cargo clippy --workspace --all-targets --all-features -- -D warnings
cargo deny check all -D warnings
cargo fmt --all -- --check
cargo nextest run --workspace --all-targets --all-features --status-level all --no-tests warn
# TODO Doctests
echo "==== checkall success ===="
'';
# DO NOT ENABLE RUST because devenv messes up the ability
# to build rust-src
# languages.rust = {};
};
2026-02-27 21:30:42 +01:00
};
flake = { };
};
}