Torrenting is the best way I know to do p2p file sharing. Dependencies hosted on a single website I would fear might run the risk of eventually having lost dependencies and/or at the very least being less generally resilient.
Lets say I wanted to write a flake which took a torrent as a source for my programs project files. How might I accomplish that end?
Like this?
{
description = "Download assets via torrent.";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
};
outputs = { self, nixpkgs }:
let sys = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${sys};
in
{
packages.${sys}.moon = pkgs.runCommandLocal "fetch-the-moon" {
outputHashAlgo = "sha256";
outputHashMode = "recursive";
outputHash = "sha256-74JJ50kULWtfO85BRkDVlunVr0pKJgsPoV4TNC4pPUI=";
} ''
mkdir -p $out
${pkgs.lib.getExe pkgs.aria2} --dht-file-path=./dht.dat --seed-time=0 --select-file=1 https://archive.org/download/MSFC-6901249/MSFC-6901249_archive.torrent -O 1=./moon.jpg
cp moon.jpg $out/.
'';
};
}
ls -al $(nix build --print-out-paths .#moon)
1 Like