diff --git a/ofborg/src/bin/builder.rs b/ofborg/src/bin/builder.rs index 006e2ce..1504625 100644 --- a/ofborg/src/bin/builder.rs +++ b/ofborg/src/bin/builder.rs @@ -16,7 +16,6 @@ use ofborg::config; use ofborg::checkout; use ofborg::worker; use ofborg::tasks; -use ofborg::nix; fn main() { @@ -48,7 +47,7 @@ fn main() { let mut channel = session.open_channel(2).unwrap(); let cloner = checkout::cached_cloner(Path::new(&cfg.checkout.root)); - let nix = nix::new(cfg.nix.system.clone(), cfg.nix.remote.clone()); + let nix = cfg.nix(); channel.basic_consume( worker::new(tasks::build::BuildWorker::new(cloner, nix, cfg.nix.system.clone())), diff --git a/ofborg/src/bin/mass-rebuilder.rs b/ofborg/src/bin/mass-rebuilder.rs index 695ff20..2b080df 100644 --- a/ofborg/src/bin/mass-rebuilder.rs +++ b/ofborg/src/bin/mass-rebuilder.rs @@ -10,7 +10,6 @@ use std::path::Path; use ofborg::tasks; use ofborg::config; use ofborg::checkout; -use ofborg::nix; use ofborg::worker; use amqp::Session; @@ -46,7 +45,7 @@ fn main() { let mut channel = session.open_channel(2).unwrap(); let cloner = checkout::cached_cloner(Path::new(&cfg.checkout.root)); - let nix = nix::new(cfg.nix.system.clone(), cfg.nix.remote.clone()); + let nix = cfg.nix(); let mrw = tasks::massrebuilder::MassRebuildWorker::new( diff --git a/ofborg/src/config.rs b/ofborg/src/config.rs index 1454993..f4aa3f5 100644 --- a/ofborg/src/config.rs +++ b/ofborg/src/config.rs @@ -6,7 +6,7 @@ use hyper::Client; use hyper::net::HttpsConnector; use hyper_native_tls::NativeTlsClient; use hubcaps::{Credentials, Github}; - +use nix::Nix; use ofborg::acl; @@ -32,6 +32,7 @@ pub struct RabbitMQConfig { pub struct NixConfig { pub system: String, pub remote: String, + pub build_timeout_seconds: u16, } @@ -76,6 +77,21 @@ impl Config { Credentials::Token(self.github.clone().unwrap().token) ) } + + pub fn nix(&self) -> Nix { + if self.nix.build_timeout_seconds < 1200 { + error!("Note: {} is way too low for build_timeout_seconds!", + self.nix.build_timeout_seconds + ); + error!("Please set build_timeout_seconds to at least 1200"); + panic!(); + } + + return Nix::new(self.nix.system.clone(), + self.nix.remote.clone(), + self.nix.build_timeout_seconds + ); + } } diff --git a/ofborg/src/nix.rs b/ofborg/src/nix.rs index d8be6c8..88b9469 100644 --- a/ofborg/src/nix.rs +++ b/ofborg/src/nix.rs @@ -9,21 +9,24 @@ use std::io::SeekFrom; #[derive(Clone, Debug, PartialEq)] pub struct Nix { system: String, - remote: String -} - -pub fn new(system: String, remote: String) -> Nix { - return Nix{ - system: system, - remote: remote, - } + remote: String, + build_timeout: u16 } impl Nix { + pub fn new(system: String, remote: String, build_timeout: u16) -> Nix { + return Nix{ + system: system, + remote: remote, + build_timeout: build_timeout, + } + } + pub fn with_system(&self, system: String) -> Nix { return Nix{ system: system, remote: self.remote.clone(), + build_timeout: self.build_timeout, }; } @@ -58,6 +61,7 @@ impl Nix { .env("NIX_PATH", nixpath) .env("NIX_REMOTE", &self.remote) .args(&["--option", "restrict-eval", "true"]) + .args(&["--option", "build-timeout", &format!("{}", self.build_timeout)]) .args(&["--argstr", "system", &self.system]) .args(args) .status()