generated from Patagia/template-nix
Compare commits
3 commits
911c531d5c
...
3a73207175
Author | SHA1 | Date | |
---|---|---|---|
3a73207175 | |||
a5e3170d37 | |||
5d79274cd6 |
13 changed files with 1034 additions and 44 deletions
967
Cargo.lock
generated
967
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -2,11 +2,13 @@
|
|||
resolver = "2"
|
||||
members = [
|
||||
"agent",
|
||||
"client",
|
||||
"controller",
|
||||
"xtask",
|
||||
]
|
||||
default-members = [
|
||||
"agent",
|
||||
"client",
|
||||
"controller",
|
||||
"xtask",
|
||||
]
|
||||
|
@ -36,9 +38,11 @@ opentelemetry-otlp = { version = "0.27.0", features = ["grpc-tonic", "trace"] }
|
|||
opentelemetry_sdk = { version = "0.27.1", features = ["metrics", "rt-tokio"] }
|
||||
opentelemetry-semantic-conventions = "0.27.0"
|
||||
opentelemetry-stdout = "0.27.0"
|
||||
progenitor = "0.8.0"
|
||||
reqwest = { version = "0.12.9", features = ["json", "stream", "rustls-tls"] }
|
||||
schemars = "0.8.21"
|
||||
semver = "1.0.23"
|
||||
serde = "1.0.215"
|
||||
serde = { version = "1.0.215", features = ["derive"] }
|
||||
slog = "2.7.0"
|
||||
slog-async = "2.8.0"
|
||||
tokio = { version = "1.41.1", features = ["full"] }
|
||||
|
@ -53,3 +57,4 @@ tracing-subscriber = { version = "0.3.18", default-features = false, features =
|
|||
"env-filter",
|
||||
"fmt",
|
||||
] }
|
||||
uuid = { version = "1", features = [ "serde", "v4" ] }
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
:toc: left
|
||||
:icons: font
|
||||
|
||||
= Patagia Run - Control Plane
|
||||
= Patagia Control Plane
|
||||
|
||||
[link=https://ci.patagia.dev/repos/5,window=_blank]
|
||||
image::https://ci.patagia.dev/api/badges/5/status.svg[Build Status]
|
||||
|
|
|
@ -7,6 +7,7 @@ license = "MPL-2.0"
|
|||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
clap.workspace = true
|
||||
patagia-client = { path = "../client" }
|
||||
tokio.workspace = true
|
||||
tracing.workspace = true
|
||||
tracing-chrome.workspace = true
|
||||
|
|
|
@ -19,6 +19,10 @@ async fn main() -> Result<()> {
|
|||
|
||||
tracing::info!("Patagia Agent");
|
||||
|
||||
let client = patagia_client::Client::new("http://localhost:9474");
|
||||
let result = client.version().await?;
|
||||
tracing::info!("Result: {:?}", result);
|
||||
|
||||
sleep(Duration::from_secs(3)).await;
|
||||
Ok(())
|
||||
}
|
||||
|
|
2
api.json
2
api.json
|
@ -8,7 +8,7 @@
|
|||
"/version": {
|
||||
"get": {
|
||||
"summary": "Fetch version info.",
|
||||
"operationId": "api_version",
|
||||
"operationId": "version",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "successful operation",
|
||||
|
|
13
client/Cargo.toml
Normal file
13
client/Cargo.toml
Normal file
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "patagia-client"
|
||||
version = "0.0.1"
|
||||
license = "MPL-2.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
anyhow.workspace = true
|
||||
chrono = { version = "0.4.0", default-features = false, features = ["serde"] }
|
||||
progenitor.workspace = true
|
||||
reqwest.workspace = true
|
||||
schemars.workspace = true
|
||||
serde.workspace = true
|
3
client/src/lib.rs
Normal file
3
client/src/lib.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
use progenitor::generate_api;
|
||||
|
||||
generate_api!(spec = "../api.json", derives = [schemars::JsonSchema]);
|
|
@ -10,6 +10,6 @@ type ControllerApiDescription = ApiDescription<Arc<ControllerContext>>;
|
|||
|
||||
pub fn api() -> Result<ControllerApiDescription> {
|
||||
let mut api = ControllerApiDescription::new();
|
||||
api.register(version::api_version)?;
|
||||
api.register(version::version)?;
|
||||
Ok(api)
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ struct VersionInfo {
|
|||
),
|
||||
err(Debug),
|
||||
)]
|
||||
pub async fn api_version(
|
||||
pub(crate) async fn version(
|
||||
rqctx: RequestContext<Arc<ControllerContext>>,
|
||||
) -> Result<HttpResponseOk<VersionInfo>, HttpError> {
|
||||
let ver = VersionInfo {
|
||||
|
|
38
flake.lock
38
flake.lock
|
@ -3,11 +3,11 @@
|
|||
"advisory-db": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1731808107,
|
||||
"narHash": "sha256-HSx5EDsO07KULW4bNPVeGVAfpQqzwwS005vqISdOzNg=",
|
||||
"lastModified": 1733749954,
|
||||
"narHash": "sha256-2Ug80Uf/oUujxgh02Iy5vTG0V+Ab9+YUHuRLRY0ayiY=",
|
||||
"owner": "rustsec",
|
||||
"repo": "advisory-db",
|
||||
"rev": "8e353a172f1baf11c0c917cfc9ae3c5eff8b9d06",
|
||||
"rev": "ec9ce28714bb38d77a2223e7266df705500a7f11",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -18,11 +18,11 @@
|
|||
},
|
||||
"crane": {
|
||||
"locked": {
|
||||
"lastModified": 1731974733,
|
||||
"narHash": "sha256-enYSSZVVl15FI5p+0Y5/Ckf5DZAvXe6fBrHxyhA/njc=",
|
||||
"lastModified": 1733688869,
|
||||
"narHash": "sha256-KrhxxFj1CjESDrL5+u/zsVH0K+Ik9tvoac/oFPoxSB8=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "3cb338ce81076ce5e461cf77f7824476addb0e1c",
|
||||
"rev": "604637106e420ad99907cae401e13ab6b452e7d9",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -66,16 +66,16 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1731797254,
|
||||
"narHash": "sha256-df3dJApLPhd11AlueuoN0Q4fHo/hagP75LlM5K1sz9g=",
|
||||
"lastModified": 1734083684,
|
||||
"narHash": "sha256-5fNndbndxSx5d+C/D0p/VF32xDiJCJzyOqorOYW4JEo=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e8c38b73aeb218e27163376a2d617e61a2ad9b59",
|
||||
"rev": "314e12ba369ccdb9b352a4db26ff419f7c49fa84",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-24.05",
|
||||
"ref": "nixos-24.11",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
|
@ -98,11 +98,11 @@
|
|||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1731890469,
|
||||
"narHash": "sha256-D1FNZ70NmQEwNxpSSdTXCSklBH1z2isPR84J6DQrJGs=",
|
||||
"lastModified": 1733097829,
|
||||
"narHash": "sha256-9hbb1rqGelllb4kVUCZ307G2k3/UhmA8PPGBoyuWaSw=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "5083ec887760adfe12af64830a66807423a859a7",
|
||||
"rev": "2c15aa59df0017ca140d9ba302412298ab4bf22a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -128,11 +128,11 @@
|
|||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1732328983,
|
||||
"narHash": "sha256-RHt12f/slrzDpSL7SSkydh8wUE4Nr4r23HlpWywed9E=",
|
||||
"lastModified": 1734230139,
|
||||
"narHash": "sha256-zsp0Mz8VgyIAnU8UhP/YT1g+zlsl+NIJTBMAbY+RifQ=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "ed8aa5b64f7d36d9338eb1d0a3bb60cf52069a72",
|
||||
"rev": "150fbc8aa2bc501041810bbc1dbfe73694a861be",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -161,11 +161,11 @@
|
|||
"nixpkgs": "nixpkgs_3"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1732292307,
|
||||
"narHash": "sha256-5WSng844vXt8uytT5djmqBCkopyle6ciFgteuA9bJpw=",
|
||||
"lastModified": 1733761991,
|
||||
"narHash": "sha256-s4DalCDepD22jtKL5Nw6f4LP5UwoMcPzPZgHWjAfqbQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "705df92694af7093dfbb27109ce16d828a79155f",
|
||||
"rev": "0ce9d149d99bc383d1f2d85f31f6ebd146e46085",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
29
flake.nix
29
flake.nix
|
@ -7,7 +7,7 @@
|
|||
crane.url = "github:ipetkov/crane";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
nix-filter.url = "github:numtide/nix-filter";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
treefmt-nix.url = "github:numtide/treefmt-nix";
|
||||
};
|
||||
|
@ -26,7 +26,7 @@
|
|||
flake-utils.lib.eachDefaultSystem (
|
||||
system:
|
||||
let
|
||||
rustVersion = "1.81.0"; # Skipping 1.82 because of https://github.com/rust-lang/rust/issues/132064
|
||||
rustVersion = "1.83.0";
|
||||
|
||||
overlays = [
|
||||
(import rust-overlay)
|
||||
|
@ -49,6 +49,7 @@
|
|||
nativeBuildInputs = with pkgs; [
|
||||
clang_18
|
||||
mold
|
||||
openssl
|
||||
];
|
||||
|
||||
sourceAndFixtures = path: type: (craneLib.filterCargoSources path type);
|
||||
|
@ -91,6 +92,7 @@
|
|||
./Cargo.toml
|
||||
./Cargo.lock
|
||||
(craneLib.fileset.commonCargoSources ./agent)
|
||||
(craneLib.fileset.commonCargoSources ./client)
|
||||
(craneLib.fileset.commonCargoSources ./controller)
|
||||
(craneLib.fileset.commonCargoSources ./xtask)
|
||||
(craneLib.fileset.commonCargoSources crate)
|
||||
|
@ -142,7 +144,7 @@
|
|||
}
|
||||
);
|
||||
|
||||
fmt = craneLib.cargoFmt (commonArgs // { inherit src; });
|
||||
# fmt = craneLib.cargoFmt (commonArgs // { inherit src; });
|
||||
|
||||
audit = craneLib.cargoAudit (commonArgs // { inherit src advisory-db; });
|
||||
|
||||
|
@ -156,11 +158,16 @@
|
|||
);
|
||||
|
||||
openapi =
|
||||
pkgs.runCommand "openapi" (commonArgs // {
|
||||
src = fileSetForCrate ./xtask;
|
||||
}) ''
|
||||
${self.packages.${system}.xtask}/bin/xtask open-api | ${pkgs.diffutils}/bin/diff -u $src/api.json - | tee $out
|
||||
'';
|
||||
pkgs.runCommand "openapi"
|
||||
(
|
||||
commonArgs
|
||||
// {
|
||||
src = fileSetForCrate ./xtask;
|
||||
}
|
||||
)
|
||||
''
|
||||
${self.packages.${system}.xtask}/bin/xtask open-api | ${pkgs.diffutils}/bin/diff -u $src/api.json - | tee $out
|
||||
'';
|
||||
};
|
||||
|
||||
# For `nix fmt`
|
||||
|
@ -179,13 +186,15 @@
|
|||
cargo-watch
|
||||
hyperfine
|
||||
just
|
||||
pkg-config
|
||||
rust-dev-toolchain
|
||||
watchexec
|
||||
];
|
||||
RUST_BACKTRACE = 1;
|
||||
RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc; # Required for rust-analyzer
|
||||
shellHook = ''
|
||||
export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc} # Required for rust-analyzer
|
||||
echo
|
||||
echo "✨ Welcome to the Patagia development environment! ✨"
|
||||
echo "✨🛠️ Welcome to the Patagia development environment 🛠️✨"
|
||||
echo "Run 'just' to see available commands."
|
||||
echo
|
||||
'';
|
||||
|
|
8
justfile
8
justfile
|
@ -12,6 +12,14 @@ run-controller $RUST_LOG="debug,h2=info,hyper_util=info,tower=info":
|
|||
dev-controller:
|
||||
watchexec --clear --restart --stop-signal INT --debounce 300ms -- just run-controller
|
||||
|
||||
# Run agent
|
||||
run-agent $RUST_LOG="debug,h2=info,hyper_util=info,tower=info":
|
||||
cargo run --package patagia-agent
|
||||
|
||||
# Run agent local development
|
||||
dev-agent:
|
||||
watchexec --clear --restart --stop-signal INT --debounce 300ms -- just run-agent
|
||||
|
||||
# Lint all source code
|
||||
lint:
|
||||
cargo clippy
|
||||
|
|
Loading…
Reference in a new issue