nixpkgs/pkgs/applications/networking/ipfs/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

59 lines
2.0 KiB
Nix
Raw Normal View History

{ lib, buildGoModule, fetchurl, nixosTests }:
2016-06-06 00:46:06 +00:00
buildGoModule rec {
pname = "ipfs";
version = "0.12.2"; # When updating, also check if the repo version changed and adjust repoVersion below
2017-10-02 18:35:45 +00:00
rev = "v${version}";
2016-06-06 00:46:06 +00:00
repoVersion = "12"; # Also update ipfs-migrator when changing the repo version
ipfs-migrator: 1.7.1 -> 2.0.2 https://github.com/ipfs/fs-repo-migrations/releases/tag/v2.0.2 This is pretty much a complete rewrite of the ipfs-migrator package. In version 2.0.0 a major change was made to the way the migrator works. Before, there was one binary that contained every migration. Now every migration has its own binary. If fs-repo-migrations can't find a required binary in the PATH, it will download it off the internet. To prevent that, build every migration individually, symlink them all into one package and then wrap fs-repo-migrations so it finds the package with all the migrations. The change to the IPFS NixOS module and the IPFS package is needed because without explicitly specifying a repo version to migrate to, fs-repo-migrations will query the internet to find the latest version. This fails in the sandbox, for example when testing the ipfs passthru tests. While it may seem like the repoVersion and IPFS version are in sync and the code could be simplified, this is not the case. See https://github.com/ipfs/fs-repo-migrations#when-should-i-migrate for a table with the IPFS versions and corresponding repo versions. Go 1.17 breaks the migrations, so use Go 1.16 instead. This is also the Go version used in their CI, see https://github.com/ipfs/fs-repo-migrations/blob/3dc218e3006adac25e1cb5e969d7c9d961f15ddd/.github/workflows/test.yml#L4. See https://github.com/ipfs/fs-repo-migrations/pull/140#issuecomment-982715907 for a previous mention of this issue. The issue manifests itself when doing anything with a migration, for example `fs-repo-11-to-12 --help`: ``` panic: qtls.ClientHelloInfo doesn't match goroutine 1 [running]: github.com/marten-seemann/qtls-go1-15.init.0() github.com/marten-seemann/qtls-go1-15@v0.1.1/unsafe.go:20 +0x132 ``` Also add myself as a maintainer for this package. This fixes the test failure discovered in https://github.com/NixOS/nixpkgs/pull/160914. See https://github.com/ipfs/fs-repo-migrations/issues/148 to read some of my struggles with updating this package.
2022-01-13 12:01:17 +00:00
2020-05-11 07:03:30 +00:00
# go-ipfs makes changes to it's source tarball that don't match the git source.
src = fetchurl {
url = "https://github.com/ipfs/go-ipfs/releases/download/${rev}/go-ipfs-source.tar.gz";
sha256 = "sha256-66NNLMSfeBHQh/QlnETB/ssra9CKbD+jtaJuX+14x00=";
2016-06-06 00:46:06 +00:00
};
2020-05-11 07:03:30 +00:00
# tarball contains multiple files/directories
postUnpack = ''
mkdir ipfs-src
shopt -s extglob
mv !(ipfs-src) ipfs-src || true
2020-05-11 07:03:30 +00:00
cd ipfs-src
2020-05-07 14:26:09 +00:00
'';
2020-05-11 07:03:30 +00:00
sourceRoot = ".";
subPackages = [ "cmd/ipfs" ];
2020-03-13 19:37:56 +00:00
2020-05-08 09:49:10 +00:00
passthru.tests.ipfs = nixosTests.ipfs;
2020-05-08 08:34:42 +00:00
2020-05-11 07:03:30 +00:00
vendorSha256 = null;
outputs = [ "out" "systemd_unit" "systemd_unit_hardened" ];
postPatch = ''
substituteInPlace 'misc/systemd/ipfs.service' \
--replace '/usr/bin/ipfs' "$out/bin/ipfs"
substituteInPlace 'misc/systemd/ipfs-hardened.service' \
--replace '/usr/bin/ipfs' "$out/bin/ipfs"
'';
postInstall = ''
install --mode=444 -D 'misc/systemd/ipfs-api.socket' "$systemd_unit/etc/systemd/system/ipfs-api.socket"
install --mode=444 -D 'misc/systemd/ipfs-gateway.socket' "$systemd_unit/etc/systemd/system/ipfs-gateway.socket"
install --mode=444 -D 'misc/systemd/ipfs.service' "$systemd_unit/etc/systemd/system/ipfs.service"
install --mode=444 -D 'misc/systemd/ipfs-api.socket' "$systemd_unit_hardened/etc/systemd/system/ipfs-api.socket"
install --mode=444 -D 'misc/systemd/ipfs-gateway.socket' "$systemd_unit_hardened/etc/systemd/system/ipfs-gateway.socket"
install --mode=444 -D 'misc/systemd/ipfs-hardened.service' "$systemd_unit_hardened/etc/systemd/system/ipfs.service"
'';
meta = with lib; {
2016-06-06 00:46:06 +00:00
description = "A global, versioned, peer-to-peer filesystem";
homepage = "https://ipfs.io/";
2016-06-06 00:46:06 +00:00
license = licenses.mit;
2016-10-29 03:19:41 +00:00
platforms = platforms.unix;
maintainers = with maintainers; [ fpletz ];
2016-06-06 00:46:06 +00:00
};
}