-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- <Await> doesn't handle errors, so use <Suspense> in conjunction with <ErrorBoundary> - implement IntoView for data types, so they can be directly rendered. Introduce nix::info module, containing only nix information. We'll add other nix::* modules latter.
- Loading branch information
Showing
4 changed files
with
52 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use leptos::*; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)] | ||
/// Information about the user's Nix installation | ||
pub struct NixInfo { | ||
/// Nix version string | ||
pub nix_version: String, | ||
} | ||
|
||
#[server(GetNixInfo, "/api")] | ||
pub async fn get_nix_info() -> Result<NixInfo, ServerFnError> { | ||
use tokio::process::Command; | ||
let out = Command::new("nix").arg("--version").output().await?.stdout; | ||
// TODO: Parse the version string | ||
let nix_version = String::from_utf8(out) | ||
.map_err(|e| <std::string::FromUtf8Error as Into<ServerFnError>>::into(e))?; | ||
Ok(NixInfo { nix_version }) | ||
} | ||
|
||
impl IntoView for NixInfo { | ||
fn into_view(self, cx: Scope) -> View { | ||
view! {cx, | ||
<div class="p-2 bg-blue-100 border-2 border-black rounded shadow-md"> | ||
<b>Nix Version:</b> | ||
<pre>{self.nix_version}</pre> | ||
</div> | ||
} | ||
.into_view(cx) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub mod info; |