mirror of
https://github.com/MarkusZoppelt/stahl.git
synced 2026-11-27 06:43:49 +01:00
Replaces the Tauri and React app with a native Rust app on Rune, with no web view, and moves to portfolio_rs 0.10.1. CI covers Linux, macOS and Windows.
152 lines
4.2 KiB
Nix
152 lines
4.2 KiB
Nix
{
|
|
description = "Stahl Capital — native desktop app for portfolio_rs, built on Rune, runs on macOS, Linux, and NixOS";
|
|
|
|
nixConfig = {
|
|
extra-substituters = [
|
|
"https://nix-community.cachix.org"
|
|
];
|
|
extra-trusted-public-keys = [
|
|
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
|
|
];
|
|
};
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-26.05";
|
|
crane.url = "github:ipetkov/crane";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
rust-overlay = {
|
|
url = "github:oxalica/rust-overlay";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
};
|
|
|
|
outputs = {
|
|
self,
|
|
nixpkgs,
|
|
crane,
|
|
flake-utils,
|
|
rust-overlay,
|
|
}:
|
|
flake-utils.lib.eachDefaultSystem (
|
|
system: let
|
|
pkgs = import nixpkgs {
|
|
inherit system;
|
|
overlays = [(import rust-overlay)];
|
|
};
|
|
|
|
# Rune needs a newer compiler than nixpkgs ships. rust-toolchain.toml
|
|
# is the single pin, shared with rustup and the release workflow.
|
|
rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
|
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
|
|
|
|
isLinux = pkgs.stdenv.isLinux;
|
|
|
|
# Rune links xkbcommon and wayland. winit and wgpu dlopen the rest at
|
|
# runtime, so linking alone does not find them.
|
|
linuxRuntimeLibs = with pkgs; [
|
|
libxkbcommon
|
|
vulkan-loader
|
|
wayland
|
|
libx11
|
|
libxcursor
|
|
libxi
|
|
libxrandr
|
|
libxcb
|
|
];
|
|
|
|
commonArgs = {
|
|
src = craneLib.cleanCargoSource ./.;
|
|
strictDeps = true;
|
|
|
|
nativeBuildInputs = with pkgs;
|
|
[
|
|
pkg-config
|
|
# aws-lc-sys, behind the TLS stack, builds C with it.
|
|
cmake
|
|
]
|
|
++ pkgs.lib.optionals isLinux [
|
|
makeWrapper
|
|
];
|
|
|
|
buildInputs =
|
|
pkgs.lib.optionals isLinux linuxRuntimeLibs
|
|
# stdenv's default apple-sdk provides the frameworks on macOS.
|
|
++ pkgs.lib.optionals pkgs.stdenv.isDarwin (with pkgs; [
|
|
libiconv
|
|
]);
|
|
};
|
|
|
|
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
|
|
|
stahl = craneLib.buildPackage (
|
|
commonArgs
|
|
// {
|
|
inherit cargoArtifacts;
|
|
# Tests run in the `stahl-test` check.
|
|
doCheck = false;
|
|
|
|
postFixup = pkgs.lib.optionalString isLinux ''
|
|
wrapProgram $out/bin/stahl \
|
|
--prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath linuxRuntimeLibs}
|
|
'';
|
|
|
|
meta = with pkgs.lib; {
|
|
description = "Stahl Capital — native desktop app for portfolio_rs";
|
|
homepage = "https://github.com/MarkusZoppelt/stahl";
|
|
license = licenses.mit;
|
|
mainProgram = "stahl";
|
|
maintainers = [maintainers.MarkusZoppelt];
|
|
platforms = platforms.linux ++ platforms.darwin;
|
|
};
|
|
}
|
|
);
|
|
in {
|
|
packages = {
|
|
default = stahl;
|
|
stahl = stahl;
|
|
};
|
|
|
|
apps.default = flake-utils.lib.mkApp {
|
|
drv = stahl;
|
|
};
|
|
|
|
devShells.default = craneLib.devShell {
|
|
inputsFrom = [stahl];
|
|
packages = with pkgs; [
|
|
cargo-watch
|
|
alejandra
|
|
];
|
|
LD_LIBRARY_PATH = pkgs.lib.optionalString isLinux (pkgs.lib.makeLibraryPath linuxRuntimeLibs);
|
|
};
|
|
|
|
checks = {
|
|
inherit stahl;
|
|
|
|
stahl-clippy = craneLib.cargoClippy (
|
|
commonArgs
|
|
// {
|
|
inherit cargoArtifacts;
|
|
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
|
|
}
|
|
);
|
|
|
|
stahl-fmt = craneLib.cargoFmt commonArgs;
|
|
|
|
# Includes tests/e2e.rs: Rune's headless runtime needs no display or GPU.
|
|
stahl-test = craneLib.cargoTest (
|
|
commonArgs
|
|
// {
|
|
inherit cargoArtifacts;
|
|
}
|
|
);
|
|
};
|
|
|
|
formatter = pkgs.alejandra;
|
|
}
|
|
)
|
|
// {
|
|
overlays.default = final: prev: {
|
|
stahl = self.packages.${final.system}.stahl;
|
|
};
|
|
};
|
|
}
|