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

consider a torrent for build inputs #16953

Closed
knupfer opened this issue Jul 14, 2016 · 5 comments
Closed

consider a torrent for build inputs #16953

knupfer opened this issue Jul 14, 2016 · 5 comments

Comments

@knupfer
Copy link
Contributor

knupfer commented Jul 14, 2016

In a lot of cases, upstream sources or releases become unavailable (e.g. grsecurity) or even get modified (e.g. texlive) which breaks the package in older versions of nixpkgs.

It would be nice to duplicate the sources via a torrent. This doesn't involve any trust, because the hash of the sources is known beforehand and would allow older nixpkgs to work as long as someone uses the desired package.

@copumpkin
Copy link
Member

We've discussed a fetchTorrent before but have mostly resisted because unless we build deep support for it into a persistent Nix daemon, fetchTorrent as we could implement today would be a terrible "torrent citizen", and would never seed.

Probably more promising is to build support for IPFS into Nix itself. See discussion at NixOS/nix#859 and ipfs/notes#51.

Either way, I don't think most of the work would happen inside nixpkgs, so if you think the above issues don't cover what you want, I'd suggest posting more information on the Nix issue tracker rather than in here.

@abbradar
Copy link
Member

FWIW I had an experimental fetchTorrent via aria2 but dropped it because of the same reasons -- it'd be an awful "torrent citizen".

@knupfer
Copy link
Contributor Author

knupfer commented Jul 18, 2016

Actually, the ipfs issue seems to be exactly what I wanted, so I'll close this issue.

@knupfer knupfer closed this as completed Jul 18, 2016
andir added a commit to andir/nixpkgs that referenced this issue Feb 9, 2018
Update to latest stable version from the 5.1 branch. Also fixes
compilation of the host driver on 4.15.

Changelog:

 * GUI: mouse events did not reach host windows behind the transparent VM window (Mac OS X hosts only; bug NixOS#16246)
 * Audio: fixed accidental crashes when using the AC'97 sound emulation (bug NixOS#16959)
 * Audio: fixed crash when default input or output devices have changed (bugs NixOS#16968, NixOS#16969, NixOS#17004)
 * Audio: fixed recording when using the ALSA backend
 * Audio: fixed handle leak when using the OSS backend
 * E1000: fixed a crash related to VLAN traffic over internal network (5.1.26 regression; bug NixOS#16960)
 * NAT: apply --natbindip1 to TCP connections (bug NixOS#16478)
 * OVF: when importing an appliance with XHCI controller, don't add an OHCI controller.
 * Mac OS X hosts: fixed a GUI crash if Spotlight is used from file dialogs (5.1.20 regression; bugs NixOS#16935, NixOS#16953)
 * Linux hosts: fixed creating fixed sized VDI images (bug NixOS#17010)
 * Linux hosts / guests: fixes for Linux 4.4 of openSUSE Leap 42.3 (bug NixOS#16966)
 * Bridged networking: align outgoing packet at word boundary, preventing Windows host crash in MsLbfoProvider.
 * Linux Additions: kernel drm driver support for custom EL7 Linux 3.10 kernel
 * Solaris Additions: hide an informational message on the bootup console
 * GUI: translation updates
 * GUI: Fixed double mouse cursor when using mouse integration without Guest Additions, actually a Qt 5.6 bug fixed with QT 5.6.3 (Mac OS X hosts only; bug NixOS#15610)
 * Solaris hosts: allow increasing MTU size for host-only adapter to 9706 bytes to support jumbo frames
 * Linux hosts: glibc 2.26 compile fix
 * Windows Additions: 3D related crash fix (bugs NixOS#17082, NixOS#17092)
 * GUI: fixed occasional screen corruption when host screen resolution is changed
 * User interface: increase proposed disk size when creating new VMs for Windows 7 and newer
 * Serial: fixed broken communication with certain devices on Linux hosts
 * VMM: Fixed problems using 256MB VRAM in raw-mode VMs
 * Audio: added HDA support for more exotic guests (e.g. Haiku)
 * Audio: fixed playback with ALSA backend (5.1.28 regression)
 * USB/OHCI: fixed a problem where OHCI emulation might sporadically drop data transfers
 * Windows hosts: VirtualBoxManager in the Python API no longer calls CoUninitialize when destroyed
 * Linux hosts: fixed VBoxNetFlt kernel module compilation failure with Linux kernel 4.14
 * Linux guests: fixed kernel module compilation and other problems with Linux kernel 4.14
@Renha
Copy link

Renha commented Dec 10, 2019

@abbradar, can you share your fetchTorrent please? I'm currently thinking about packaging the program where using aria2c for install is an official way to install

@milahu
Copy link
Contributor

milahu commented Feb 18, 2023

moved to PR

{
  src = fetchBitTorrent {
    btih = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
    sha256 = "";
  };

pkgs/build-support/fetchbittorrent/default.nix

{ stdenvNoCC
, fetchFromGitHub
, aria2
, cacert
}:

{
  btih,
  sha256 ? null,
  hash ? null,
  name ? null,
  # TODO implement "flat" mode = produce a single file in $out
  outputHashMode ? "recursive", # "recursive" or "flat"
  outputHashAlgo ? "sha256",
  dontUpload ? false,
  # TODO implement partial download, similar to git sparse checkout
  # https://github.com/NixOS/nixpkgs/pull/135881
  #files ? null,
} @ attrs: stdenvNoCC.mkDerivation {
  name = attrs.name or "btih-${btih}";
  trackerlist = (fetchFromGitHub {
    # https://github.com/ngosang/trackerslist
    # using trackers by IP address to avoid DNS blocking
    owner = "ngosang";
    repo = "trackerslist";
    rev = "8ba874e69da0532166644922ea207da3084dff66"; # 2023-02-18
    sha256 = "sha256-QCE7gDtDBLLpFgGWa3r/1YOz16dTXKx6rYy8m0DCH8k=";
  }) + "/trackers_best_ip.txt"; # 16 trackers
  #}) + "/trackers_all_ip.txt"; # 97 trackers
  nativeBuildInputs = [
    # FIXME aria2c has no manpage in nixpkgs
    # https://aria2.github.io/manual/en/html/aria2c.html
    aria2
  ];
  inherit btih outputHashMode outputHashAlgo;
  outputHash = attrs.sha256 or attrs.hash or (throw "sha256 or hash is required");
  buildCommand = ''
    export HOME=$TMP
    mkdir $HOME/.aria2

    # create empty dht.dat file to hide warning
    # TODO file path?
    mkdir -p $HOME/.cache/aria2
    touch $HOME/.cache/aria2/dht.dat
    # /build/.cache/aria2/dht.dat
    # $XDG_CACHE_HOME/aria2/dht.dat
    # $XDG_CACHE_HOME/aria2/dht6.dat

    cat >$HOME/.aria2/aria2.conf <<EOF
    bt-tracker=$(cat $trackerlist | xargs printf "%s,")
    seed-time=0
    ca-certificate=${cacert}/etc/ssl/certs/ca-bundle.crt
    # TODO? use impure env for dht-listen-port
    listen-port=6881
    dht-listen-port=6881
    enable-dht=true
    check-integrity=true
    file-allocation=prealloc
    download-result=hide
    summary-interval=10
    ${if !dontUpload then "" else ''
      # TODO disable seeding completely
      # this will limit upload to 1 byte/sec
      max-upload-limit=1
    ''}
    EOF

    mkdir $out
    cd $out
    echo fetching bittorrent $btih ...
    aria2c "magnet:?xt=urn:btih:$btih"
  '';
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants