2023-10-27 20:20:19 +03:00
|
|
|
{ lib
|
|
|
|
, buildGoModule
|
|
|
|
, fetchurl
|
|
|
|
, nixosTests
|
|
|
|
, callPackage
|
|
|
|
}:
|
2022-06-18 16:17:08 +03:00
|
|
|
|
2023-10-27 20:20:19 +03:00
|
|
|
buildGoModule rec {
|
|
|
|
pname = "kubo";
|
|
|
|
version = "0.23.0"; # When updating, also check if the repo version changed and adjust repoVersion below
|
2022-06-18 16:17:08 +03:00
|
|
|
rev = "v${version}";
|
|
|
|
|
2023-10-27 20:20:19 +03:00
|
|
|
passthru.repoVersion = "15"; # Also update kubo-migrator when changing the repo version
|
2022-06-18 16:17:08 +03:00
|
|
|
|
2023-10-27 20:20:19 +03:00
|
|
|
# Kubo makes changes to its source tarball that don't match the git source.
|
2022-06-18 16:17:08 +03:00
|
|
|
src = fetchurl {
|
2022-09-23 22:52:15 +03:00
|
|
|
url = "https://github.com/ipfs/kubo/releases/download/${rev}/kubo-source.tar.gz";
|
2023-10-27 20:20:19 +03:00
|
|
|
hash = "sha256-ycXn8h8sFGJXVMldneN51lZgXoPaZ/XeXLtqqJ4w6H0=";
|
2022-06-18 16:17:08 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
# tarball contains multiple files/directories
|
|
|
|
postUnpack = ''
|
2023-10-27 20:20:19 +03:00
|
|
|
mkdir kubo-src
|
2022-06-18 16:17:08 +03:00
|
|
|
shopt -s extglob
|
2023-10-27 20:20:19 +03:00
|
|
|
mv !(kubo-src) kubo-src || true
|
|
|
|
cd kubo-src
|
2022-06-18 16:17:08 +03:00
|
|
|
'';
|
|
|
|
|
2023-10-27 20:20:19 +03:00
|
|
|
patches = [
|
|
|
|
./ipfs-allow-publish-with-ipns-mounted.patch
|
|
|
|
./ipfs-fuse-nuke-getxattr.patch
|
|
|
|
];
|
|
|
|
|
2022-06-18 16:17:08 +03:00
|
|
|
sourceRoot = ".";
|
|
|
|
|
|
|
|
subPackages = [ "cmd/ipfs" ];
|
|
|
|
|
2023-10-27 20:20:19 +03:00
|
|
|
passthru.tests = {
|
|
|
|
inherit (nixosTests) kubo;
|
|
|
|
repoVersion = callPackage ./test-repoVersion.nix {};
|
|
|
|
};
|
2022-06-18 16:17:08 +03:00
|
|
|
|
2023-10-27 20:20:19 +03:00
|
|
|
vendorHash = null;
|
2022-06-18 16:17:08 +03:00
|
|
|
|
|
|
|
outputs = [ "out" "systemd_unit" "systemd_unit_hardened" ];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace 'misc/systemd/ipfs.service' \
|
2023-10-27 20:20:19 +03:00
|
|
|
--replace '/usr/local/bin/ipfs' "$out/bin/ipfs"
|
2022-06-18 16:17:08 +03:00
|
|
|
substituteInPlace 'misc/systemd/ipfs-hardened.service' \
|
2023-10-27 20:20:19 +03:00
|
|
|
--replace '/usr/local/bin/ipfs' "$out/bin/ipfs"
|
2022-06-18 16:17:08 +03:00
|
|
|
'';
|
|
|
|
|
|
|
|
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; {
|
2023-10-27 20:20:19 +03:00
|
|
|
description = "An IPFS implementation in Go";
|
2022-06-18 16:17:08 +03:00
|
|
|
homepage = "https://ipfs.io/";
|
|
|
|
license = licenses.mit;
|
|
|
|
platforms = platforms.unix;
|
2023-10-27 20:20:19 +03:00
|
|
|
mainProgram = "ipfs";
|
|
|
|
maintainers = with maintainers; [ Luflosi fpletz ];
|
2022-06-18 16:17:08 +03:00
|
|
|
};
|
|
|
|
}
|