diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 723f7611268bc..48531bb3d4d82 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -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"; diff --git a/pkgs/by-name/na/namida/client_get_mem_size_of.patch b/pkgs/by-name/na/namida/client_get_mem_size_of.patch new file mode 100644 index 0000000000000..f9261768d7d7c --- /dev/null +++ b/pkgs/by-name/na/namida/client_get_mem_size_of.patch @@ -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; diff --git a/pkgs/by-name/na/namida/make_deterministic.patch b/pkgs/by-name/na/namida/make_deterministic.patch new file mode 100644 index 0000000000000..08725c5631035 --- /dev/null +++ b/pkgs/by-name/na/namida/make_deterministic.patch @@ -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); ++ }, ++ }; + } diff --git a/pkgs/by-name/na/namida/package.nix b/pkgs/by-name/na/namida/package.nix new file mode 100644 index 0000000000000..98f8117356fb6 --- /dev/null +++ b/pkgs/by-name/na/namida/package.nix @@ -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"; + }; +}