-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
fetchipfs: support api/v0/get #136688
fetchipfs: support api/v0/get #136688
Conversation
a small test script #!/usr/bin/env bash
# test nixos fetchipfs
# requires ../fetchipfs from
# https://github.com/NixOS/nixpkgs/tree/0d35cc9d2b393f5e700f508ed859a2406884311b/pkgs/build-support/fetchipfs
# TODO use ipfs http api to add tarchive files
# https://docs.ipfs.io/reference/http/api/#api-v0-tar-add
set -e # exit on first error
set -o xtrace # print all commands
pidof ipfs || { echo start ipfs daemon; ipfs daemon & sleep 5; }
test() {
local path="$1"
out="$(ipfs add --recursive "$path" 2>/dev/null)"
ipfs_hash=$(echo "$out" | tail -n1 | cut -d' ' -f2)
sha256recursive=$(nix-hash --type sha256 "$path" | cut -d' ' -f1)
cat >fetchipfs-test.nix <<EOF
{ curl, stdenv }:
let fetchipfs = import ../fetchipfs { inherit curl stdenv; }; in
fetchipfs { ipfs = "${ipfs_hash}"; sha256 = "${sha256recursive}"; }
EOF
nix-build -E 'with import <nixpkgs> { }; callPackage ./fetchipfs-test.nix { }'
}
dd if=/dev/urandom bs=1024 count=1 status=none | base64 >random.txt
test random.txt
rm random.txt
mkdir random || true # allow to fail
dd if=/dev/urandom bs=1024 count=1 status=none | base64 >random/a.txt
dd if=/dev/urandom bs=1024 count=1 status=none | base64 >random/b.txt
test random
rm -rf random
echo pass |
if you want to make tests then this will be useful #136022 |
The fetcher test pr has been merged |
I marked this as stale due to inactivity. → More info |
What's the status of this PR? I'd like to get this merged if it doesn't break anything. Adding a test would be ideal. |
abandoned by OP |
theres 0 uses of fetchipfs in nixpkgs so i don't want to merge this without tests |
I tried to do that (there are two commits) but gave up because I felt it was too difficult to preserve the hashes if I remember correctly. I think I also couldn't reproduce the hash of the source code from the hello package from when fetchipfs was first introduced, so maybe There are many problems with the current state of things (even after applying this PR): I think the whole concept of how things are fetched and unpacked in Nixpkgs needs to be reworked. But I fear this idea is too crazy and complicated to ever be implemented. So now I am in a state where I dislike how ugly things are currently but don't really know how to improve them without too much effort and without breaking backwards compatibility. |
sounds like metalink
then the first request succeeds with http 200.
deprecated in favor of /api/v0/add and /api/v0/get, see ipfs/kubo#7951
use
yepp. i needed this to build ipfs-desktop, where assets (images, etc) are stored in ipfs |
Motivation for this change
the old fetchipfs only works, when the object is an "IPFS tarchive"
when the object is a directory, the api method
tar/cat
fails:instead, we must use the api method
get
this patch will also
Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)test
todo
ipfs-
before the ipfs hash, so its easier to find ipfs objects in the store