difftreelog
feat non-interactive run0
7 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -451,9 +451,9 @@
[[package]]
name = "bifrostlink"
-version = "0.2.6"
+version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2fb01af731c11dd31b23783a83a36a29f644cc1972481f6fa4f4fabc709079eb"
+checksum = "0c8ce9dc1425ee2aaffd3324548f114acccd456b9b1ffb33fe9eb9a7be6475a8"
dependencies = [
"async-trait",
"async_fn_traits",
@@ -465,14 +465,13 @@
"serde_json",
"tokio",
"tracing",
- "uuid",
]
[[package]]
name = "bifrostlink-macros"
-version = "0.2.6"
+version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8c4b7a5fb38b36bd81910c17ebf369f9296e508d92b1277a768a63c8a2254fdb"
+checksum = "a7d071add2d3b90486fe141edb2e811f7735155d320aee3936ebd67e535d6ac1"
dependencies = [
"proc-macro2",
"quote",
@@ -481,9 +480,9 @@
[[package]]
name = "bifrostlink-ports"
-version = "0.2.6"
+version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "977acfcb8ed3c24ab7c2f76fb3eeebff1533c72708733ce6020f2501980b7cf2"
+checksum = "ccf6ba32d0ff83b27a242f9d2fca124ad215ddd9bf99144d66b7ca44a885de50"
dependencies = [
"bifrostlink",
"bytes",
@@ -3654,13 +3653,12 @@
[[package]]
name = "remowt-client"
-version = "0.1.7"
+version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "34d59c0ce311b4b3c094b0b196a1004aa438b9947c3eace2ca4d2a0ac08fac59"
+checksum = "af0ab07d961f14fa5c4933899a5253341e2044dec71db6e341f80b16beff2c20"
dependencies = [
"anyhow",
"bifrostlink",
- "bifrostlink-ports",
"bytes",
"camino",
"futures",
@@ -3679,13 +3677,11 @@
[[package]]
name = "remowt-endpoints"
-version = "0.1.7"
+version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cb203856cd5cff27504bd2023c59195b1f1ce1cf5d8ea836598993894eb1b9c0"
+checksum = "9a841eec11d4cc0593188062634f7ee34e87a2052a70c0fa40fbecb4aa8692c0"
dependencies = [
- "anyhow",
"bifrostlink",
- "bifrostlink-macros",
"camino",
"nix",
"serde",
@@ -3693,7 +3689,6 @@
"thiserror 2.0.18",
"tokio",
"tracing",
- "uuid",
"zbus",
]
@@ -3716,9 +3711,9 @@
[[package]]
name = "remowt-link-shared"
-version = "0.1.7"
+version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "98ebba5be028a2dfb7f1858bb0ff74037262753eaae4dc6e5d9ae241c4567668"
+checksum = "d5036c5e2d5f47bb7ecb25542268f865c298c2b747d74269ff6b2b387574071a"
dependencies = [
"bifrostlink",
"bytes",
@@ -3732,9 +3727,9 @@
[[package]]
name = "remowt-plugin"
-version = "0.1.7"
+version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ef73ef3eea5bb6152d01019b5062e51ef258a1ac1c7a6f8cdcdf6fe1eb192cdd"
+checksum = "5ca599e67dc675d8dd59abfe8f08679f7f3c6fd7aa84507ab426839985a142ab"
dependencies = [
"anyhow",
"bifrostlink",
@@ -3742,7 +3737,6 @@
"remowt-link-shared",
"serde_json",
"tokio",
- "tracing",
"tracing-subscriber",
]
@@ -3757,15 +3751,14 @@
[[package]]
name = "remowt-ui-prompt"
-version = "0.1.7"
+version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "acf28ba68e6f8087657157695e9ab42b82a21130e77f6dffd27781062109325d"
+checksum = "2610933566f9b057dc47145b7bfc5876c4139eb766fc2fe9f2ce60baf1856c8c"
dependencies = [
"anyhow",
"bifrostlink",
"bifrostlink-macros",
"serde",
- "serde_json",
"thiserror 2.0.18",
"tokio",
"tracing",
cmds/fleet/src/cmds/rollback.rsdiffbeforeafterboth--- a/cmds/fleet/src/cmds/rollback.rs
+++ b/cmds/fleet/src/cmds/rollback.rs
@@ -62,7 +62,6 @@
warn!("failed to list generations available locally: {e}");
})
.unwrap_or_default();
- dbg!(&stored_locally);
stored_locally.retain(|g| !on_machine_store_paths.contains(&g.store_path));
for ele in stored_locally.iter_mut() {
ele.current = false;
crates/fleet-base/src/host.rsdiffbeforeafterboth--- a/crates/fleet-base/src/host.rs
+++ b/crates/fleet-base/src/host.rs
@@ -250,7 +250,7 @@
}
let bundle = agent_bundle()?;
let conn = if self.local {
- Remowt::connect_local(&bundle)
+ Remowt::connect_local(&bundle, "remowt-fleet".to_owned())
.await
.context("starting local remowt agent")?
} else {
@@ -259,7 +259,7 @@
.get()
.cloned()
.unwrap_or_else(|| self.name.clone());
- Remowt::connect(&dest, &bundle)
+ Remowt::connect(&dest, &bundle, "remowt-fleet".to_owned())
.await
.map_err(|e| anyhow!("remowt error while connecting to {}: {e:#?}", self.name))?
};
crates/nix-eval/src/drv.rsdiffbeforeafterboth1use std::collections::{HashMap, HashSet, VecDeque};23use anyhow::{Result, bail};4use camino::{Utf8Component, Utf8Path, Utf8PathBuf};5use serde::Deserialize;67use crate::nix_raw::{derivation_free, derivation_to_json, store_drv_from_store_path};8use crate::{Store, copy_nix_str, with_default_context};910pub struct Derivation(*mut crate::nix_raw::derivation);11unsafe impl Send for Derivation {}1213impl Derivation {14 pub fn from_path(store: &Store, drv_path: &Utf8Path) -> Result<Self> {15 let store_path = store.parse_path(drv_path)?;16 let drv = with_default_context(|c, _| unsafe {17 store_drv_from_store_path(c, store.as_ptr(), store_path.as_ptr())18 });19 let drv = drv?;20 if drv.is_null() {21 bail!("failed to read derivation from {drv_path}");22 }23 Ok(Self(drv))24 }2526 pub fn to_json_string(&self) -> Result<String> {27 let mut out = String::new();28 with_default_context(|c, _| unsafe {29 derivation_to_json(c, self.0, Some(copy_nix_str), (&raw mut out).cast())30 })?;31 Ok(out)32 }3334 pub fn parsed(&self) -> Result<DrvParsed> {35 let s = self.to_json_string()?;36 Ok(serde_json::from_str(&s)?)37 }38}3940impl Drop for Derivation {41 fn drop(&mut self) {42 unsafe { derivation_free(self.0) };43 }44}4546#[derive(Debug, Deserialize)]47pub struct DrvParsed {48 pub inputs: DrvInputs,49 pub outputs: HashMap<String, DrvParsedOutput>,50}5152#[derive(Debug, Deserialize)]53pub struct DrvParsedOutput {54 #[serde(default)]55 pub path: Option<String>,56}5758#[derive(Debug, Deserialize)]59pub struct DrvInputs {60 #[serde(default)]61 pub srcs: Vec<Utf8PathBuf>,62 #[serde(default)]63 pub drvs: HashMap<Utf8PathBuf, DrvInputEntry>,64}6566#[derive(Debug, Deserialize)]67pub struct DrvInputEntry {68 pub outputs: Vec<String>,69}7071#[derive(Debug, Clone)]72pub struct DrvGraph {73 pub root: Utf8PathBuf,74 pub nodes: HashMap<Utf8PathBuf, DrvNode>,75}7677#[derive(Debug, Clone)]78pub struct DrvNode {79 pub name: String,80 pub input_drvs: HashMap<Utf8PathBuf, Vec<String>>,81 pub input_srcs: Vec<Utf8PathBuf>,82 // TODO: CA outputs without a known paths are skipped83 pub outputs: HashMap<String, Utf8PathBuf>,84}8586impl DrvGraph {87 pub fn resolve(store: &Store, drv_path: &Utf8Path) -> Result<Self> {88 let sd = store.store_dir()?;89 let root = sd.join(drv_path);9091 let mut nodes = HashMap::new();92 let mut queue = VecDeque::new();93 let mut visited = HashSet::new();94 queue.push_back(root.clone());95 visited.insert(root.clone());9697 while let Some(path) = queue.pop_front() {98 let drv = Derivation::from_path(store, &path)?;99 let parsed = drv.parsed()?;100101 let input_drvs: HashMap<Utf8PathBuf, Vec<String>> = parsed102 .inputs103 .drvs104 .into_iter()105 .map(|(k, v)| (sd.join(&k), v.outputs))106 .collect();107 let input_srcs: Vec<Utf8PathBuf> = parsed108 .inputs109 .srcs110 .into_iter()111 .map(|k| sd.join(&k))112 .collect();113114 for dep_path in input_drvs.keys() {115 if visited.insert(dep_path.clone()) {116 queue.push_back(dep_path.clone());117 }118 }119120 let outputs: HashMap<String, Utf8PathBuf> = parsed121 .outputs122 .into_iter()123 .filter_map(|(name, out)| out.path.map(|p| (name, sd.join(&p))))124 .collect();125126 nodes.insert(127 path.clone(),128 DrvNode {129 name: extract_drv_name(&path),130 input_drvs,131 input_srcs,132 outputs,133 },134 );135 }136137 Ok(Self { root, nodes })138 }139140 pub fn wanted_outputs(&self, root_outputs: &[String]) -> HashMap<Utf8PathBuf, Vec<String>> {141 let mut wanted: HashMap<Utf8PathBuf, HashSet<String>> = HashMap::new();142 wanted.insert(self.root.clone(), root_outputs.iter().cloned().collect());143144 let mut queue: VecDeque<Utf8PathBuf> = VecDeque::new();145 queue.push_back(self.root.clone());146 while let Some(path) = queue.pop_front() {147 let Some(node) = self.nodes.get(&path) else {148 continue;149 };150 for (dep_path, dep_outputs) in &node.input_drvs {151 let entry = wanted.entry(dep_path.clone()).or_default();152 let mut changed = false;153 for o in dep_outputs {154 if entry.insert(o.clone()) {155 changed = true;156 }157 }158 if changed {159 queue.push_back(dep_path.clone());160 }161 }162 }163164 wanted165 .into_iter()166 .map(|(k, v)| {167 let mut v: Vec<_> = v.into_iter().collect();168 v.sort();169 (k, v)170 })171 .collect()172 }173}174175pub fn extract_drv_name(drv_path: &Utf8Path) -> String {176 let comp = drv_path177 .components()178 .rev()179 .next()180 .expect("drv path is at least one component");181 let Utf8Component::Normal(n) = comp else {182 panic!("drv path is normal");183 };184185 let n = n.strip_suffix(".drv").unwrap_or(n);186187 let n = n.split_once(' ').map(|(_, n)| n).unwrap_or(n);188189 n.to_owned()190}flake.lockdiffbeforeafterboth--- a/flake.lock
+++ b/flake.lock
@@ -188,9 +188,9 @@
]
},
"locked": {
- "lastModified": 1781471358,
- "rev": "c69dddc33f8e2081ef685ae20a7278f92cfcd32e",
- "revCount": 37,
+ "lastModified": 1781491431,
+ "rev": "c8dca760c1f13e8b65677bac7b21abb487d745c0",
+ "revCount": 40,
"type": "git",
"url": "file:/home/lach/build/remowt-agents"
},
modules/nixos/module-list.nixdiffbeforeafterboth--- a/modules/nixos/module-list.nix
+++ b/modules/nixos/module-list.nix
@@ -4,5 +4,6 @@
./rollback.nix
./nix-sign.nix
./online.nix
+ ./polkit.nix
./top-level.nix
]
modules/nixos/polkit.nixdiffbeforeafterboth--- /dev/null
+++ b/modules/nixos/polkit.nix
@@ -0,0 +1,15 @@
+{ ... }:
+{
+ users.groups.fleet-pusher = { };
+
+ security.polkit.extraConfig = ''
+ polkit.addRule(function(action, subject) {
+ if (action.id == "org.freedesktop.systemd1.manage-units" && subject.isInGroup("fleet-pusher")) {
+ const unit = action.lookup("unit");
+ if (unit && unit.indexOf("remowt-fleet-") == 0) {
+ return polkit.Result.YES;
+ }
+ }
+ });
+ '';
+}