build.rs builds the string (git, or SLINUXM_* env for builds without .git) and the lib exposes it as VERSION. --version, /healthz, /api/v1/ping, MCP server info and OTel service.version use it; OpenAPI info.version stays on the semver so docs/openapi.json does not change per commit. The flake passes the commit date and short rev to the package.
60 lines
1.6 KiB
Nix
60 lines
1.6 KiB
Nix
{ lib
|
|
, rustPlatform
|
|
, pkg-config
|
|
, cmake
|
|
, systemd
|
|
# The build sandbox has no .git, so build.rs gets the stamp from here
|
|
# (YYYY.MM.DD-<branch>-<sha>). The flake fills these in; a flake has no
|
|
# branch name, hence the placeholder.
|
|
, gitSha ? "unknown"
|
|
, gitBranch ? "nix"
|
|
, buildDate ? "1970.01.01"
|
|
}:
|
|
|
|
rustPlatform.buildRustPackage {
|
|
pname = "skyg-linux-tracker";
|
|
version = "${buildDate}-${gitBranch}-${gitSha}";
|
|
|
|
src = lib.fileset.toSource {
|
|
root = ../.;
|
|
fileset = lib.fileset.unions [
|
|
../Cargo.toml
|
|
../Cargo.lock
|
|
../build.rs
|
|
../config.example.toml
|
|
../migrations
|
|
../src
|
|
../tests
|
|
../examples
|
|
../docs/openapi.json
|
|
];
|
|
};
|
|
|
|
cargoLock.lockFile = ../Cargo.lock;
|
|
|
|
env = {
|
|
SLINUXM_GIT_SHA = gitSha;
|
|
SLINUXM_GIT_BRANCH = gitBranch;
|
|
SLINUXM_BUILD_DATE = buildDate;
|
|
};
|
|
|
|
# cmake: aws-lc-sys. Live-journal tests are #[ignore], so the sandbox runs
|
|
# the rest of the suite.
|
|
nativeBuildInputs = [ pkg-config cmake ];
|
|
buildInputs = [ systemd ];
|
|
|
|
# These two need host state the build sandbox lacks: a root-owned /usr, and a
|
|
# CA bundle for the reqwest client. They run under cargo test outside Nix.
|
|
checkFlags = [
|
|
"--skip=db::tests::cli_owner_check_uses_file_then_parent_and_allows_missing_dir"
|
|
"--skip=telemetry::tests::exporters_build_for_both_protocols"
|
|
];
|
|
|
|
meta = {
|
|
description = "Read-only Linux system monitor: systemd, journald and Docker over REST, MCP and OpenTelemetry";
|
|
license = lib.licenses.mit;
|
|
mainProgram = "slinuxm";
|
|
platforms = lib.platforms.linux;
|
|
};
|
|
}
|