aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock68
-rw-r--r--Cargo.toml8
-rw-r--r--README.md10
-rw-r--r--flake.nix46
-rw-r--r--src/errors.rs2
-rw-r--r--src/handlers/mod.rs2
-rw-r--r--src/handlers/planets.rs (renamed from src/handlers/waifus.rs)10
-rw-r--r--src/main.rs2
8 files changed, 73 insertions, 75 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 8d1497e..e3ec1e5 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -842,6 +842,40 @@ dependencies = [
]
[[package]]
+name = "solard"
+version = "0.3.0"
+dependencies = [
+ "axum",
+ "color-eyre",
+ "eyre",
+ "hyper",
+ "kankyo",
+ "serde",
+ "solarlib",
+ "thiserror",
+ "tokio",
+ "tower",
+ "tower-http 0.3.0",
+ "tracing",
+ "tracing-subscriber",
+]
+
+[[package]]
+name = "solarlib"
+version = "1.2.1"
+source = "git+https://git.carathe.dev/muirrum/solarlib?branch=master#c8ab6337d26d606ce003fe747af3eff6e57f4c03"
+dependencies = [
+ "mac_address",
+ "rand",
+ "ructe",
+ "serde",
+ "thiserror",
+ "tokio",
+ "uuid",
+ "virt",
+]
+
+[[package]]
name = "syn"
version = "1.0.91"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1109,40 +1143,6 @@ dependencies = [
]
[[package]]
-name = "waifud"
-version = "0.2.0"
-dependencies = [
- "axum",
- "color-eyre",
- "eyre",
- "hyper",
- "kankyo",
- "serde",
- "thiserror",
- "tokio",
- "tower",
- "tower-http 0.3.0",
- "tracing",
- "tracing-subscriber",
- "waifulib",
-]
-
-[[package]]
-name = "waifulib"
-version = "0.1.0"
-source = "git+https://git.carathe.dev/muirrum/waifulib?branch=master#013a7488c8d2d11daf2cb6184f7fe2d25f6da8a4"
-dependencies = [
- "mac_address",
- "rand",
- "ructe",
- "serde",
- "thiserror",
- "tokio",
- "uuid",
- "virt",
-]
-
-[[package]]
name = "want"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/Cargo.toml b/Cargo.toml
index 5d12238..5da2d83 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
-name = "waifud"
-version = "0.2.0"
+name = "solard"
+version = "0.3.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -19,8 +19,8 @@ thiserror = "1"
kankyo = "0.3"
-[dependencies.waifulib]
-git = "https://git.carathe.dev/muirrum/waifulib"
+[dependencies.solarlib]
+git = "https://git.carathe.dev/muirrum/solarlib"
branch = "master"
[dependencies.serde]
diff --git a/README.md b/README.md
index 17f47fa..e011f9b 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,15 @@
-# Waifud
+# solard
-Providing a RESTful interface to a machine's virtual machines (waifus).
+`solard` provides a REST API for managing virtual machines across a network.
## Flake Options
-Example:
-
```nix
{ config, pkgs, ... }:
{
- cara.services.waifud = {
+ cara.services.solard = {
enable = true;
- environmentFileLocation = "/var/lib/waifud/.env";
+ environmentFileLocation = "/var/lib/solard/.env";
port = 3000;
};
}
diff --git a/flake.nix b/flake.nix
index 9963206..714b863 100644
--- a/flake.nix
+++ b/flake.nix
@@ -15,61 +15,61 @@
in
rec {
# `nix build`
- packages.waifud = naersk-lib.buildPackage {
- pname = "waifud";
+ packages.solard = naersk-lib.buildPackage {
+ pname = "solard";
root = ./.;
nativeBuildInputs = deps;
buildInputs = deps;
};
- defaultPackage = packages.waifud;
+ defaultPackage = packages.solard;
# `nix run`
- apps.waifud = flake-utils.lib.mkApp {
- drv = packages.waifud;
+ apps.solard = flake-utils.lib.mkApp {
+ drv = packages.solard;
};
- defaultApp = apps.waifud;
+ defaultApp = apps.solard;
- nixosModules.waifud = { config, lib, ... }: {
+ nixosModules.solard = { config, lib, ... }: {
options = with lib; {
- cara.services.waifud.enable = mkEnableOption "enable waifud";
- cara.services.waifud.environmentFileLocation = mkOption {
+ cara.services.solard.enable = mkEnableOption "enable solard";
+ cara.services.solard.environmentFileLocation = mkOption {
type = types.str;
- default = "/var/lib/waifud/.env";
+ default = "/var/lib/solard/.env";
description = "The location of the environment file";
};
- cara.services.waifud.port = mkOption {
+ cara.services.solard.port = mkOption {
type = types.port;
default = 3000;
description = "port to bind to";
};
};
- config = lib.mkIf config.cara.services.waifud.enable {
- users.groups.waifud = {
- members = [ "waifud" ];
+ config = lib.mkIf config.cara.services.solard.enable {
+ users.groups.solard = {
+ members = [ "solard" ];
};
- users.users.waifud = {
+ users.users.solard = {
createHome = true;
isSystemUser = true;
- home = "/var/lib/waifud";
- group = "waifud";
+ home = "/var/lib/solard";
+ group = "solard";
extraGroups = [ "libvirtd" ];
};
- systemd.services.waifud = {
+ systemd.services.solard = {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
- User = "waifud";
- Group = "waifud";
+ User = "solard";
+ Group = "solard";
Restart = "always";
WorkingDirectory = "${defaultPackage}";
- ExecStart = "${defaultPackage}/bin/waifud";
- EnvironmentFIle = "${config.cara.services.waifud.environmentFileLocation}";
+ ExecStart = "${defaultPackage}/bin/solard";
+ EnvironmentFIle = "${config.cara.services.solard.environmentFileLocation}";
};
};
- networking.firewall.allowedTCPPorts = [ config.cara.services.waifud.port ];
+ networking.firewall.allowedTCPPorts = [ config.cara.services.solard.port ];
};
};
diff --git a/src/errors.rs b/src/errors.rs
index a538e4a..06a0233 100644
--- a/src/errors.rs
+++ b/src/errors.rs
@@ -8,7 +8,7 @@ use axum::Json;
#[derive(Debug, Error)]
pub enum ServiceError {
#[error("Waifulib error: {0}")]
- Waifulib(#[from] waifulib::errors::Error),
+ Solarlib(#[from] solarlib::errors::Error),
#[error("Axum error: {0}")]
Axum(#[from] axum::Error),
diff --git a/src/handlers/mod.rs b/src/handlers/mod.rs
index addf742..591f76e 100644
--- a/src/handlers/mod.rs
+++ b/src/handlers/mod.rs
@@ -1 +1 @@
-pub mod waifus;
+pub mod planets;
diff --git a/src/handlers/waifus.rs b/src/handlers/planets.rs
index 117ba15..e80e7fe 100644
--- a/src/handlers/waifus.rs
+++ b/src/handlers/planets.rs
@@ -2,16 +2,16 @@ use axum::{response::IntoResponse, Json};
use tracing::{error, instrument};
-use waifulib::house::House;
-use waifulib::waifu::Waifu;
+use solarlib::star::Star;
+use solarlib::planet::Planet;
use crate::errors::*;
-pub async fn list() -> JsonResult<Json<Vec<Waifu>>> {
+pub async fn list() -> JsonResult<Json<Vec<Planet>>> {
let con_url = std::env::var("QEMU_URL").unwrap_or("qemu:///system".to_string());
- let mut house: House = House::new(con_url)?;
+ let mut star = Star::new(con_url)?;
- let inhabitants = house.inhabitants()?;
+ let inhabitants = star.inhabitants()?;
Ok(Json(inhabitants))
}
diff --git a/src/main.rs b/src/main.rs
index ba319d9..8fbd0ff 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -32,7 +32,7 @@ async fn main() {
let app = Router::new()
.route("/health", get(health_check))
- .route("/waifus/list", get(handlers::waifus::list))
+ .route("/planets/list", get(handlers::planets::list))
.layer( ServiceBuilder::new()
.layer(HandleErrorLayer::new(|error: BoxError| async move {
if error.is::<tower::timeout::error::Elapsed>() {