feat(*): init Rust port
This is a Rust port of the original Perl script, legacy cruft is removed and it focuses on a modern Hydra deployment. Nonetheless, it knows how to perform migrations based on the channel versions. Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
This commit is contained in:
parent
809d960f49
commit
8288bad70e
5
.gitignore
vendored
5
.gitignore
vendored
|
@ -1 +1,6 @@
|
||||||
result
|
result
|
||||||
|
|
||||||
|
|
||||||
|
# Added by cargo
|
||||||
|
|
||||||
|
/target
|
||||||
|
|
1787
Cargo.lock
generated
Normal file
1787
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
8
Cargo.toml
Normal file
8
Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
[package]
|
||||||
|
name = "nixos-channel-scripts"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
clap = { version = "4.5.13", features = [ "derive" ] }
|
||||||
|
object_store = { version = "0.10.2", features = [ "aws" ] }
|
27
src/actions.rs
Normal file
27
src/actions.rs
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
enum HydraProductType {
|
||||||
|
BrotliJson,
|
||||||
|
SourceDistribution,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ToString for HydraProductType {
|
||||||
|
fn to_string(&self) -> String {
|
||||||
|
match self {
|
||||||
|
Self::BrotliJson => "json-br".to_string(),
|
||||||
|
Self::SourceDistribution => "source-dist".to_string(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Action {
|
||||||
|
WriteFile {
|
||||||
|
dst_path: PathBuf,
|
||||||
|
contents: String
|
||||||
|
},
|
||||||
|
WriteHydraProduct {
|
||||||
|
dst_path: PathBuf,
|
||||||
|
product_name: String,
|
||||||
|
product_type: Option<HydraProductType>,
|
||||||
|
}
|
||||||
|
}
|
12
src/config.rs
Normal file
12
src/config.rs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
struct MirrorConfig {
|
||||||
|
/// URI to Hydra instance
|
||||||
|
hydra_uri: String,
|
||||||
|
/// URI to the binary cache
|
||||||
|
binary_cache_uri: String,
|
||||||
|
/// A path to a checkout of nixpkgs
|
||||||
|
nixpkgs_dir: PathBuf,
|
||||||
|
/// S3 releases bucket URL
|
||||||
|
s3_release_bucket_uri: String,
|
||||||
|
}
|
30
src/main.rs
Normal file
30
src/main.rs
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
mod config;
|
||||||
|
mod actions;
|
||||||
|
|
||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
use clap::Parser;
|
||||||
|
|
||||||
|
#[derive(Parser, Debug)]
|
||||||
|
#[command(version, about, long_about = None)]
|
||||||
|
struct Args {
|
||||||
|
/// Channel name to update
|
||||||
|
channel_name: String,
|
||||||
|
/// Job name to fetch from Hydra instance
|
||||||
|
job_name: String,
|
||||||
|
/// TOML configuration file for channel updates
|
||||||
|
#[arg(short, long)]
|
||||||
|
config_file: PathBuf,
|
||||||
|
/// Whether to execute no remote side effects (S3 uploads, redirections), etc.
|
||||||
|
#[arg(short, long, default_value_t = false)]
|
||||||
|
dry_run: bool,
|
||||||
|
/// If a channel rollback is detected, do not bail out and proceed to rollback the channel
|
||||||
|
#[arg(short, long, default_value_t = false)]
|
||||||
|
ignore_rollback_protection: bool
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let args = Args::parse();
|
||||||
|
|
||||||
|
println!("Hello, world!");
|
||||||
|
}
|
Loading…
Reference in a new issue