Something went wrong. Try again.
Nix-based distributed command runner now.dev.br
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100// now: Nix-based distributed command runner// Copyright (C) 2026 Eric Rodrigues Pires//// This program is free software: you can redistribute it and/or modify it under// the terms of the GNU Affero General Public License as published by the Free// Software Foundation, either version 3 of the License, or (at your option)// any later version.//// This program is distributed in the hope that it will be useful, but WITHOUT// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS// FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for// more details.//// You should have received a copy of the GNU Affero General Public License along// with this program. If not, see <https://www.gnu.org/licenses/>.
use std::path::{Path, PathBuf};
use smol::{ channel, lock::futures::{Acquire, Read, Write}, process::Child,};
use async_trait::async_trait;use serde::Deserialize;
use crate::{job::JobError, workflow::NowCheckout};
pub(crate) mod local;pub(crate) mod remote;
#[async_trait(?Send)]pub(crate) trait NowBuilder { fn acquire(&self) -> (Acquire<'_>, Read<'_, ()>, &channel::Receiver<()>);
fn acquire_exclusive(&self) -> (Write<'_, ()>, &channel::Receiver<()>);
fn get_name(&self) -> String;
fn is_remote(&self) -> bool;
async fn create_tempdir( &self, checkout: NowCheckout, cancellation: &channel::Receiver<()>, ) -> Result<Option<PathBuf>, JobError>;
async fn checkout( &self, checkout: NowCheckout, tempdir: Option<PathBuf>, cancellation: &channel::Receiver<()>, ) -> Result<PathBuf, JobError>;
async fn copy_derivations( &self, job_name: &str, derivations: &[PathBuf], cancellation: &channel::Receiver<()>, ) -> Result<(), JobError>;
async fn realize_derivation( &self, derivation: &Path, cancellation: &channel::Receiver<()>, ) -> Result<PathBuf, JobError>;
async fn download( &self, downloads: &[PathBuf], cancellation: &channel::Receiver<()>, ) -> Result<(), JobError>;
fn run_derivation(&self, cwdir: &Path, derivation: PathBuf) -> Result<Child, JobError>;
async fn fetch_derivation( &self, derivation: &Path, cancellation: &channel::Receiver<()>, ) -> Result<(), JobError>;
async fn undo_checkout(&self, checkout: NowCheckout, path: &Path) -> Result<(), JobError>;}
#[derive(Deserialize, Debug)]pub(crate) struct NixConfigValue<T> { value: T,}
#[derive(Deserialize, Debug)]pub(crate) struct NixConfig { builders: NixConfigValue<String>, #[serde(rename = "extra-platforms")] extra_platforms: NixConfigValue<Vec<String>>, system: NixConfigValue<String>, #[serde(rename = "system-features")] system_features: NixConfigValue<Vec<String>>,}