mirror of
https://github.com/MarkusZoppelt/portfolio_rs.git
synced 2026-11-28 13:02:12 +01:00
Turn portfolio_rs into a library + CLI/TUI for the AI era: - Agent-friendly analysis: context, review, simulate, and validate commands with Markdown and camelCase JSON output - Machine-readable investment policy (portfolio/policy.toml) with strategy templates, policy-aware reviews, and rebalance simulations - Durable financial memory: finance workspaces (init-workspace, doctor, agent init) with decision records, weekly reports, and a .gitignore that protects private data - Decision records and weekly reports refuse to overwrite existing files in both the CLI and AppState layers, matching the workspace's never-overwrite contract (prevents GUI/CLI data loss) - Portable agent skill (agent skill show/export) and an experimental MCP server preview (JSON-RPC over stdio) - Local HTTP API (axum): positions CRUD, analysis endpoints, file persistence, short-TTL quote caching, JSON error responses, and a loud warning on non-loopback binds (no auth; local use only) - Library facade (state::AppState + camelCase DTOs) consumed by the HTTP API and the external GUI app - Robustness: consistent non-zero exit codes, no panics on missing subcommands or broken pipes, gpg failures surfaced, and decrypted data never written to disk - Tests: offline e2e suite for the CLI surface, offline HTTP API tests, and network tests kept behind #[ignore] Bump version to 0.8.0. chore: init AGENTS.md
144 lines
4.1 KiB
Nix
144 lines
4.1 KiB
Nix
{
|
|
description = "A command line tool with interactive TUI for managing financial investment portfolios written in Rust";
|
|
|
|
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";
|
|
};
|
|
|
|
outputs = {
|
|
self,
|
|
nixpkgs,
|
|
crane,
|
|
flake-utils,
|
|
}:
|
|
flake-utils.lib.eachDefaultSystem (
|
|
system: let
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
craneLib = crane.mkLib pkgs;
|
|
|
|
commonArgs = {
|
|
src = pkgs.lib.cleanSourceWith {
|
|
src = ./.;
|
|
filter = path: type:
|
|
(craneLib.filterCargoSources path type)
|
|
|| (pkgs.lib.hasSuffix ".json" path)
|
|
|| (pkgs.lib.hasSuffix ".md" path);
|
|
};
|
|
strictDeps = true;
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
pkg-config
|
|
];
|
|
|
|
buildInputs = with pkgs;
|
|
[
|
|
openssl
|
|
]
|
|
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
|
|
libiconv
|
|
];
|
|
};
|
|
|
|
# Build just the dependencies (for faster incremental builds)
|
|
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
|
|
|
# Build the actual package
|
|
portfolio_rs = craneLib.buildPackage (commonArgs
|
|
// {
|
|
inherit cargoArtifacts;
|
|
|
|
doCheck = false; # Tests are run via the separate portfolio_rs-test check
|
|
|
|
meta = with pkgs.lib; {
|
|
description = "Command line tool for managing financial investment portfolios";
|
|
homepage = "https://github.com/MarkusZoppelt/portfolio_rs";
|
|
license = licenses.mit;
|
|
maintainers = [maintainers.MarkusZoppelt];
|
|
mainProgram = "portfolio_rs";
|
|
};
|
|
});
|
|
in {
|
|
packages = {
|
|
default = portfolio_rs;
|
|
portfolio_rs = portfolio_rs;
|
|
};
|
|
|
|
# App for `nix run`
|
|
apps.default = flake-utils.lib.mkApp {
|
|
drv = portfolio_rs;
|
|
};
|
|
|
|
# Development shell
|
|
devShells.default = craneLib.devShell {
|
|
packages = with pkgs;
|
|
[
|
|
# Rust tooling
|
|
rust-analyzer
|
|
rustfmt
|
|
clippy
|
|
cargo-watch
|
|
cargo-audit
|
|
|
|
# Formatters
|
|
alejandra # Nix formatter
|
|
|
|
# Build dependencies
|
|
pkg-config
|
|
openssl
|
|
]
|
|
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
|
|
libiconv
|
|
];
|
|
};
|
|
|
|
# Checks for `nix flake check`
|
|
checks = {
|
|
inherit portfolio_rs;
|
|
|
|
portfolio_rs-clippy = craneLib.cargoClippy (commonArgs
|
|
// {
|
|
inherit cargoArtifacts;
|
|
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
|
|
});
|
|
|
|
portfolio_rs-fmt = craneLib.cargoFmt {
|
|
inherit (commonArgs) src;
|
|
};
|
|
|
|
portfolio_rs-test = craneLib.cargoTest (commonArgs
|
|
// {
|
|
inherit cargoArtifacts;
|
|
# assert_cmd::cargo_bin resolves the binary via this env var,
|
|
# which `cargo test` sets but crane's cargoTest does not.
|
|
# Point it at the Nix-built binary so e2e_offline tests pass.
|
|
preCheck = ''
|
|
export CARGO_BIN_EXE_portfolio_rs="${portfolio_rs}/bin/portfolio_rs"
|
|
# confy writes config to $HOME/.config on startup; give it a
|
|
# writable home so the sandbox doesn't break every e2e test.
|
|
export HOME=$(mktemp -d)
|
|
'';
|
|
});
|
|
};
|
|
|
|
# Nix formatter for `nix fmt`
|
|
formatter = pkgs.alejandra;
|
|
}
|
|
)
|
|
// {
|
|
# Overlay for easy integration
|
|
overlays.default = final: prev: {
|
|
portfolio_rs = self.packages.${final.system}.portfolio_rs;
|
|
};
|
|
};
|
|
}
|