Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

namida: init at 0.5.0 #346285

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9839,6 +9839,13 @@
github = "jdupak";
githubId = 22683640;
};
jebriggsy = {
name = "Jacob Briggs";
email = "jebriggsy@protonmail.com";
github = "jebriggsy";
githubId = 319954;
keys = [ { fingerprint = "2F83 B9C6 3175 AFC1 9DD6 5A53 4AB1 0A34 202A 2D04"; } ];
};
jecaro = {
email = "jeancharles.quillet@gmail.com";
github = "jecaro";
Expand Down
12 changes: 12 additions & 0 deletions pkgs/by-name/na/namida/client_get_mem_size_of.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
diff --git a/src/client/get.rs b/src/client/get.rs
index 5e38e02..27355fa 100644
--- a/src/client/get.rs
+++ b/src/client/get.rs
@@ -3,6 +3,7 @@ use std::{
path::{Path, PathBuf},
sync::Arc,
time::Instant,
+ mem::size_of,
};

use anyhow::bail;
45 changes: 45 additions & 0 deletions pkgs/by-name/na/namida/make_deterministic.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
diff --git a/build.rs b/build.rs
index 799ec48..ed12e68 100644
--- a/build.rs
+++ b/build.rs
@@ -1,17 +1,27 @@
-use std::process::Command;
+use std::{
+ process::Command,
+ env,
+};

fn main() {
- // https://stackoverflow.com/a/44407625
- let output = Command::new("git")
- .args(["rev-parse", "HEAD"])
- .output()
- .unwrap();
- let git_hash = String::from_utf8(output.stdout).unwrap();
- println!("cargo:rustc-env=GIT_HASH={}", git_hash);
+ // Check if we are in a Nix environment
+ // Nix does not work well with with variable compile-time outputs
+ match env::var("NIX_BUILD_TOP"){
+ Ok(..) => println!("Nix builder detected, disabling non-deterministic compile time operations"),
+ Err(..) => {
+ // https://stackoverflow.com/a/44407625
+ let output = Command::new("git")
+ .args(["rev-parse", "HEAD"])
+ .output()
+ .unwrap();
+ let git_hash = String::from_utf8(output.stdout).unwrap();
+ println!("cargo:rustc-env=GIT_HASH={}", git_hash);

- // Get compilation date / time
- let dt_local = chrono::Local::now();
- let naive_utc = dt_local.naive_utc();
- let formatted = naive_utc.format("%Y-%m-%d %H:%M:%S");
- println!("cargo:rustc-env=NAMIDA_COMPILE_DT={} UTC", formatted);
+ // Get compilation date / time
+ let dt_local = chrono::Local::now();
+ let naive_utc = dt_local.naive_utc();
+ let formatted = naive_utc.format("%Y-%m-%d %H:%M:%S");
+ println!("cargo:rustc-env=NAMIDA_COMPILE_DT={} UTC", formatted);
+ },
+ };
}
58 changes: 58 additions & 0 deletions pkgs/by-name/na/namida/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
lib,
fetchFromGitHub,
rustPlatform,
}:

rustPlatform.buildRustPackage rec {
pname = "namida";
version = "0.5.0";

src = fetchFromGitHub {
owner = "meew0";
repo = "namida";
rev = "782ab6baf679f830c4242bf071d8e85743fe77f7";
hash = "sha256-pflucKCzfM3Fc2+M8GNq3fsTCln+9bHBGb7/mv/GKVs=";
};
cargoHash = "sha256-FT5pxu40A8CSPL0pd1EVK+Ti80F3pdNvh5ojKNlz9Rc=";

patches = [
# Needed for rustc/cargo < 1.80
# std::mem::size_of
./client_get_mem_size_of.patch

# Removes checking git for revision and generating build-time timestamp
# Provided by environment variables in this nixpkg instead
./make_deterministic.patch
];

# Set the git revision and build datetime declaritively
env = {
GIT_HASH = src.rev;
NAMIDA_COMPILE_DT = "1970-01-01 00:00:00";
};

meta = {
description = "Client/server for fast file transfer over high-latency connections via UDP";
longDescription = ''
namida is a tool for fast file downloads over high-latency and/or unreliable networks.
It uses UDP for bulk data transmission, together with a minimal TCP control stream to mediate retransmission of lost data.

namida is based upon Tsunami, a 2000s-era protocol and software suite for UDP-based file transmission. While Tsunami is still usable today,
it has essentially not been updated since 2009, and has several problems that make it annoying to use nowadays. So, namida was created by
first converting Tsunami's source code to Rust using C2Rust, manually converting the generated unsafe code to safe, more idiomatic Rust,
and then making various improvements.

In the process some parts of Tsunami were also removed. In particular, after 2006 Tsunami was primarily maintained by Finnish VLBI scientists
(primarily Jan Wagner at Metsähovi Radio Observatory), who added support for VLBI-specific real-time networking hardware. The project does not
have access to any of this hardware, so porting is unfeasible. Presumably, the VLBI people are either still happily using Tsunami or have their
own updated tools anyway.
'';
homepage = "https://github.com/meew0/namida";
license = lib.licenses.free;
sourceProvenance = with lib.sourceTypes; [ fromSource ];
maintainers = with lib.maintainers; [ jebriggsy ];
platforms = lib.platforms.linux;
mainProgram = "namida";
};
}