From c7ec9892418f7f02799bc0dc74249c93f85e7a1b Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 13 Nov 2026 15:46:17 +0000 Subject: populate: deliver sources other than flakes with the Rust program The program delivers derivation, file, git, pass, passage, pipe, and symlink sources, makes backups, and prunes, as the shell implementation does, with the same messages. Commands on the target are fixed shell snippets in src/sh.rs, which get values as positional parameters, run directly for local targets and over ssh, sharing one master connection, for remote ones. rsync's transfers and its check for .rsync-filter files it can't read are in src/rsync.rs. Given flake or flake-input sources, or sources drawing inputs from others, the program fails before changing anything, saying that these aren't implemented yet. SIGHUP, SIGINT, and SIGTERM make populate stop once the command it waits for ends, stop the ssh master, remove its temporary directory, and exit with 128 plus the signal's number. The spec's target gets local, which rust.nix sets during evaluation, like the other functions of krops decide, and which the program decides when it runs if it's null. The spec comes on file descriptor 3, so the commands populate runs keep standard input, and the tools populate runs come first in PATH. --- pkgs/populate/src/spec.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'pkgs/populate/src/spec.rs') diff --git a/pkgs/populate/src/spec.rs b/pkgs/populate/src/spec.rs index 089d330..8fc74fc 100644 --- a/pkgs/populate/src/spec.rs +++ b/pkgs/populate/src/spec.rs @@ -1,8 +1,5 @@ //! The spec: populate's arguments as JSON, as docs/design.md describes them. -// Delivering sources isn't implemented yet, so most of the spec is unused. -#![allow(dead_code)] - use serde::Deserialize; use serde_json::{Map, Value}; use std::collections::BTreeMap; @@ -26,6 +23,8 @@ pub const SOURCE_TYPES: &[&str] = &[ #[derive(Debug, Deserialize)] #[serde(deny_unknown_fields)] pub struct Spec { + /// Checked before the rest, so it's only part of the shape here. + #[allow(dead_code)] pub version: u64, #[serde(default)] pub backup: bool, @@ -37,7 +36,7 @@ pub struct Spec { pub target: Target, } -#[derive(Debug, Deserialize)] +#[derive(Clone, Debug, Deserialize)] #[serde(deny_unknown_fields, rename_all = "camelCase")] pub struct Target { #[serde(default)] @@ -50,6 +49,10 @@ pub struct Target { pub sudo: bool, #[serde(default)] pub extra_options: Vec, + /// Whether the target is the machine populate runs on, or null to + /// decide that when it runs. + #[serde(default)] + pub local: Option, } /// A source: its type, and the settings of that type, under the type's name. -- cgit v1.3.1