start messing with ructe for templating libvirt xml
Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
parent
9014ce32bf
commit
430fb20f57
File diff suppressed because it is too large
Load Diff
26
Cargo.toml
26
Cargo.toml
|
@ -1,9 +1,33 @@
|
||||||
[package]
|
[package]
|
||||||
name = "waifud"
|
name = "waifud"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Christine Dodrill <me@christine.website>"]
|
authors = [ "Christine Dodrill <me@christine.website>" ]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
build = "src/build.rs"
|
||||||
|
repository = "https://github.com/Xe/waifud"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
r2d2_redis = "0.14.0"
|
||||||
|
serde_json = "1"
|
||||||
|
uuid = "0.8"
|
||||||
|
|
||||||
|
[dependencies.rocket]
|
||||||
|
version = "0.5.0-rc.1"
|
||||||
|
features = [ "secrets", "json", "uuid" ]
|
||||||
|
|
||||||
|
[dependencies.rocket_sync_db_pools]
|
||||||
|
version = "0.1.0-rc.1"
|
||||||
|
features = [ "diesel_sqlite_pool" ]
|
||||||
|
|
||||||
|
[dependencies.serde]
|
||||||
|
version = "1"
|
||||||
|
features = [ "derive" ]
|
||||||
|
|
||||||
|
[dependencies.tokio]
|
||||||
|
version = "1"
|
||||||
|
features = [ "full" ]
|
||||||
|
|
||||||
|
[build-dependencies]
|
||||||
|
ructe = { version = "0.13" }
|
||||||
|
|
|
@ -17,5 +17,17 @@
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://github.com/Xe/gruvbox-css/archive/0e78b4332ead8635697b990f309608d99b46967e.tar.gz",
|
"url": "https://github.com/Xe/gruvbox-css/archive/0e78b4332ead8635697b990f309608d99b46967e.tar.gz",
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
|
},
|
||||||
|
"naersk": {
|
||||||
|
"branch": "master",
|
||||||
|
"description": "Build rust crates in Nix. No configuration, no code generation, no IFD. Sandbox friendly.",
|
||||||
|
"homepage": "",
|
||||||
|
"owner": "nmattia",
|
||||||
|
"repo": "naersk",
|
||||||
|
"rev": "e09c320446c5c2516d430803f7b19f5833781337",
|
||||||
|
"sha256": "0k1pk2ixnxl6njjrgy750gm6m1nkkdsah383n3wp4ybrzacnav5h",
|
||||||
|
"type": "tarball",
|
||||||
|
"url": "https://github.com/nmattia/naersk/archive/e09c320446c5c2516d430803f7b19f5833781337.tar.gz",
|
||||||
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
13
shell.nix
13
shell.nix
|
@ -7,10 +7,13 @@ in pkgs.mkShell {
|
||||||
buildInputs = with pkgs; [
|
buildInputs = with pkgs; [
|
||||||
# rust
|
# rust
|
||||||
rustc
|
rustc
|
||||||
|
rustfmt
|
||||||
|
rust-analyzer
|
||||||
cargo
|
cargo
|
||||||
cargo-watch
|
cargo-watch
|
||||||
pkg-config
|
pkg-config
|
||||||
sqliteInteractive
|
sqliteInteractive
|
||||||
|
diesel-cli
|
||||||
|
|
||||||
# dhall
|
# dhall
|
||||||
dhall
|
dhall
|
||||||
|
@ -27,8 +30,10 @@ in pkgs.mkShell {
|
||||||
redis
|
redis
|
||||||
];
|
];
|
||||||
|
|
||||||
shellHook = ''
|
# shellHook = ''
|
||||||
ln -s ${gcss}/gruvbox.css ./public/static/gruvbox.css
|
# rm ./public/static/gruvbox.css
|
||||||
ln -s ${sources.alpinejs} ./public/static/alpine.js
|
# ln -s ${gcss}/gruvbox.css ./public/static/gruvbox.css
|
||||||
'';
|
# rm ./public/static/alpine.js
|
||||||
|
# ln -s ${sources.alpinejs} ./public/static/alpine.js
|
||||||
|
# '';
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
#[macro_use] extern crate rocket;
|
||||||
|
|
||||||
|
#[get("/")]
|
||||||
|
fn hello() -> &'static str {
|
||||||
|
"Hello, world!"
|
||||||
|
}
|
||||||
|
|
||||||
|
#[launch]
|
||||||
|
fn rocket() -> _ {
|
||||||
|
rocket::build().mount("/", routes![hello])
|
||||||
|
}
|
|
@ -0,0 +1,5 @@
|
||||||
|
use ructe::{Result, Ructe};
|
||||||
|
|
||||||
|
fn main() -> Result<()> {
|
||||||
|
Ructe::from_env()?.compile_templates("templates")
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub struct NetworkConfig {
|
||||||
|
pub name: String,
|
||||||
|
pub uuid: uuid::Uuid,
|
||||||
|
pub iface: String,
|
||||||
|
pub mac_address: String,
|
||||||
|
pub domain: String,
|
||||||
|
pub ipv4_addr_base: String,
|
||||||
|
pub ipv4_mask: String,
|
||||||
|
pub ipv4_dstart: String,
|
||||||
|
pub ipv4_dend: String,
|
||||||
|
pub ipv6: Option<(String, u16)>,
|
||||||
|
}
|
||||||
|
|
||||||
|
include!(concat!(env!("OUT_DIR"), "/templates.rs"));
|
|
@ -1,3 +0,0 @@
|
||||||
fn main() {
|
|
||||||
println!("Hello, world!");
|
|
||||||
}
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
@use crate::NetworkConfig;
|
||||||
|
|
||||||
|
@(ncfg: NetworkConfig):
|
||||||
|
<network>
|
||||||
|
<name>@ncfg.name</name>
|
||||||
|
<uuid>@ncfg.uuid</uuid>
|
||||||
|
<forward mode="nat">
|
||||||
|
<nat>
|
||||||
|
<port start="1024" end="65535"/>
|
||||||
|
</nat>
|
||||||
|
</forward>
|
||||||
|
<bridge name="@ncfg.iface" stp="on" delay="0"/>
|
||||||
|
<mac address="@ncfg.mac_address"/>
|
||||||
|
<domain name="@ncfg.domain"/>
|
||||||
|
<ip address="@(ncfg.ipv4_addr_base).1" netmask="@ncfg.ipv4_mask">
|
||||||
|
<dhcp>
|
||||||
|
<range start="@(ncfg.ipv4_addr_base).2" end="@(ncfg.ipv4_addr_base).254"/>
|
||||||
|
</dhcp>
|
||||||
|
</ip>
|
||||||
|
@if let Some((address, prefix)) = ncfg.ipv6 {
|
||||||
|
<ip family="ipv6" address="@address" prefix="@prefix">
|
||||||
|
</ip>
|
||||||
|
}
|
||||||
|
</network>
|
|
@ -1,19 +0,0 @@
|
||||||
<network>
|
|
||||||
<name>{{.Name}}</name>
|
|
||||||
<uuid>{{.UUID}}</uuid>
|
|
||||||
<forward mode="nat">
|
|
||||||
<nat>
|
|
||||||
<port start="1024" end="65535"/>
|
|
||||||
</nat>
|
|
||||||
</forward>
|
|
||||||
<bridge name="{{.Iface}}" stp="on" delay="0"/>
|
|
||||||
<mac address="{{.MACAddress}}"/>
|
|
||||||
<domain name="{{.SearchDomain}}"/>
|
|
||||||
<ip address="{{.IPv4Net}}" netmask="{{.IPv4Mask}}">
|
|
||||||
<dhcp>
|
|
||||||
<range start="{{.IPv4DHCPStart}}" end="{{.IPv4DHCPEnd}}"/>
|
|
||||||
</dhcp>
|
|
||||||
</ip>
|
|
||||||
<ip family="ipv6" address="{{.IPv6Net}}" prefix="64">
|
|
||||||
</ip>
|
|
||||||
</network>
|
|
Loading…
Reference in New Issue