155 lines
5.0 KiB
Nix
155 lines
5.0 KiB
Nix
{
|
|
description = "SymClaw — symbolic mathematics engine";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
|
rust-overlay = {
|
|
url = "github:oxalica/rust-overlay";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
crane.url = "github:ipetkov/crane";
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
};
|
|
|
|
outputs = { self, nixpkgs, rust-overlay, crane, flake-utils }:
|
|
let
|
|
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
|
meta = {
|
|
description = "SymClaw symbolic mathematics engine";
|
|
homepage = "https://github.com/symclaw/symclaw";
|
|
license = with nixpkgs.lib; [ licenses.mit licenses.asl20 ];
|
|
};
|
|
in
|
|
flake-utils.lib.eachSystem supportedSystems (system:
|
|
let
|
|
overlays = [ (import rust-overlay) ];
|
|
pkgs = import nixpkgs { inherit system overlays; };
|
|
|
|
rustToolchain = pkgs.rust-bin.stable."1.93.0".default.override {
|
|
extensions = [ "rustfmt" "clippy" "rust-src" ];
|
|
targets = [ "wasm32-unknown-unknown" ];
|
|
};
|
|
|
|
craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain;
|
|
|
|
src = pkgs.lib.cleanSourceWith {
|
|
src = craneLib.path ./.;
|
|
filter = path: type:
|
|
(craneLib.filterCargoSources path type)
|
|
|| (builtins.match ".*\.md$" path != null);
|
|
};
|
|
|
|
commonArgs = {
|
|
inherit src;
|
|
strictDeps = true;
|
|
buildInputs = [ pkgs.openssl ]
|
|
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
|
|
pkgs.darwin.apple_sdk.frameworks.Security
|
|
pkgs.darwin.apple_sdk.frameworks.SystemConfiguration
|
|
pkgs.libiconv
|
|
];
|
|
nativeBuildInputs = [ pkgs.pkg-config ];
|
|
};
|
|
|
|
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
|
|
|
buildCrate = name: craneLib.buildPackage (commonArgs // {
|
|
inherit cargoArtifacts meta;
|
|
cargoExtraArgs = "-p ${name}";
|
|
});
|
|
|
|
in {
|
|
packages = {
|
|
symclaw-cli = buildCrate "symclaw-cli";
|
|
symclaw-skill = buildCrate "symclaw-skill";
|
|
|
|
symclaw-wasm = craneLib.buildPackage (commonArgs // {
|
|
inherit cargoArtifacts meta;
|
|
cargoExtraArgs = "-p symclaw-wasm";
|
|
CARGO_BUILD_TARGET = "wasm32-unknown-unknown";
|
|
buildInputs = [];
|
|
nativeBuildInputs = [];
|
|
doCheck = false;
|
|
installPhaseCommand = ''
|
|
mkdir -p $out/lib
|
|
cp target/wasm32-unknown-unknown/release/*.wasm $out/lib/ 2>/dev/null || true
|
|
'';
|
|
});
|
|
|
|
default = self.packages.${system}.symclaw-cli;
|
|
};
|
|
|
|
checks = {
|
|
workspace-test = craneLib.cargoTest (commonArgs // {
|
|
inherit cargoArtifacts;
|
|
});
|
|
|
|
workspace-clippy = craneLib.cargoClippy (commonArgs // {
|
|
inherit cargoArtifacts;
|
|
cargoClippyExtraArgs = "--all-targets -- -D warnings";
|
|
});
|
|
|
|
workspace-fmt = craneLib.cargoFmt {
|
|
inherit src;
|
|
};
|
|
};
|
|
|
|
devShells.default = craneLib.devShell {
|
|
checks = self.checks.${system};
|
|
packages = with pkgs; [
|
|
cargo-watch
|
|
cargo-expand
|
|
wasm-bindgen-cli
|
|
wasm-pack
|
|
pkg-config
|
|
openssl
|
|
];
|
|
};
|
|
}
|
|
) // {
|
|
nixosModules.symclaw = { config, lib, pkgs, ... }: {
|
|
options.services.symclaw = {
|
|
enable = lib.mkEnableOption "SymClaw symbolic math engine";
|
|
port = lib.mkOption {
|
|
type = lib.types.port;
|
|
default = 18789;
|
|
description = "Port for the SymClaw skill service";
|
|
};
|
|
engineMode = lib.mkOption {
|
|
type = lib.types.enum [ "native" "wasm" ];
|
|
default = "native";
|
|
description = "Execution engine mode";
|
|
};
|
|
logLevel = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "info";
|
|
description = "RUST_LOG level";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf config.services.symclaw.enable {
|
|
systemd.services.symclaw = {
|
|
description = "SymClaw Symbolic Mathematics Engine";
|
|
wantedBy = [ "multi-user.target" ];
|
|
serviceConfig = {
|
|
ExecStart = "${self.packages.${pkgs.system}.symclaw-skill}/bin/symclaw-skill";
|
|
Restart = "on-failure";
|
|
DynamicUser = true;
|
|
Environment = [
|
|
"RUST_LOG=${config.services.symclaw.logLevel}"
|
|
"SYMCLAW_PORT=${toString config.services.symclaw.port}"
|
|
"SYMCLAW_ENGINE=${config.services.symclaw.engineMode}"
|
|
];
|
|
};
|
|
};
|
|
};
|
|
};
|
|
|
|
overlays.default = final: prev: {
|
|
symclaw-cli = self.packages.${final.system}.symclaw-cli;
|
|
symclaw-skill = self.packages.${final.system}.symclaw-skill;
|
|
symclaw-wasm = self.packages.${final.system}.symclaw-wasm;
|
|
};
|
|
};
|
|
}
|