git.delta.rocks / jrsonnet / refs/commits / ca5174b8c4a4

difftreelog

feat prefetch command

Yaroslav Bolyukin2023-07-09parent: #eee08d5.patch.diff
in: trunk

3 files changed

modifiedcmds/fleet/src/cmds/build_systems.rsdiffbeforeafterboth
--- a/cmds/fleet/src/cmds/build_systems.rs
+++ b/cmds/fleet/src/cmds/build_systems.rs
@@ -120,6 +120,9 @@
 				"--json",
 				// "--show-trace",
 				"--no-link",
+				"--option",
+				"log-lines",
+				"200",
 			])
 			.comparg("--out-link", &built)
 			.arg(
modifiedcmds/fleet/src/command.rsdiffbeforeafterboth
--- a/cmds/fleet/src/command.rs
+++ b/cmds/fleet/src/command.rs
@@ -254,9 +254,12 @@
 							NixLog::Start { text, level: 1, typ: 111, .. } if text.starts_with("waiting for a machine to build ") => {
 								// Useless repeating notification about build
 							}
-							NixLog::Start { text, level: 3, typ: 111, .. } if text.starts_with("resolved derivation:  ") => {
+							NixLog::Start { text, level: 3, typ: 111, .. } if text.starts_with("resolved derivation: ") => {
 								// CA resolved
 							}
+							NixLog::Start { text, level: 1, typ: 111, .. } if text.starts_with("waiting for lock on ") => {
+								// Concurrent build of the same message
+							}
 							NixLog::Stop { .. } => {},
 							NixLog::Result { .. } => {},
 							_ => warn!("unknown log: {:?}", log)
modifiedcmds/fleet/src/main.rsdiffbeforeafterboth
55
6mod fleetdata;6mod fleetdata;
77
8use std::ffi::OsString;
8use std::io;9use std::io;
910
10use anyhow::{anyhow, Result};11use anyhow::{anyhow, bail, Result};
11use clap::Parser;12use clap::Parser;
1213
13use cmds::{build_systems::BuildSystems, info::Info, secrets::Secrets};14use cmds::{build_systems::BuildSystems, info::Info, secrets::Secrets};
14use host::{Config, FleetOpts};15use host::{Config, FleetOpts};
16use tokio::fs;
17use tokio::process::Command;
15use tracing::{info, metadata::LevelFilter};18use tracing::{info, metadata::LevelFilter};
16use tracing_subscriber::EnvFilter;19use tracing_subscriber::EnvFilter;
20
21#[derive(Parser)]
22struct Prefetch {}
23impl Prefetch {
24 async fn run(&self, config: &Config) -> Result<()> {
25 let mut prefetch_dir = config.directory.to_path_buf();
26 prefetch_dir.push("prefetch");
27 if !prefetch_dir.is_dir() {
28 info!("nothing to prefetch: no prefetch directory");
29 return Ok(());
30 }
31 for entry in std::fs::read_dir(&prefetch_dir)? {
32 let entry = entry?;
33 if !entry.metadata()?.is_file() {
34 bail!("only files should exist in prefetch directory");
35 }
36 info!("prefetching {:?}", entry.file_name());
37 let mut path = OsString::new();
38 path.push("file://");
39 path.push(entry.path());
40 let status = Command::new("nix-prefetch-url").arg(path).status().await?;
41 if !status.success() {
42 bail!("failed with {status}");
43 }
44 }
45 Ok(())
46 }
47}
1748
18#[derive(Parser)]49#[derive(Parser)]
19enum Opts {50enum Opts {
22 /// Secret management53 /// Secret management
23 #[clap(subcommand)]54 #[clap(subcommand)]
24 Secrets(Secrets),55 Secrets(Secrets),
56 /// Upload prefetch directory to the nix store
57 Prefetch(Prefetch),
25 /// Config parsing58 /// Config parsing
26 Info(Info),59 Info(Info),
27}60}
40 Opts::BuildSystems(c) => c.run(config).await?,73 Opts::BuildSystems(c) => c.run(config).await?,
41 Opts::Secrets(s) => s.run(config).await?,74 Opts::Secrets(s) => s.run(config).await?,
42 Opts::Info(i) => i.run(config).await?,75 Opts::Info(i) => i.run(config).await?,
76 Opts::Prefetch(p) => p.run(config).await?,
43 };77 };
44 Ok(())78 Ok(())
45}79}