From patchwork Tue Jan 25 19:21:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: pukkamustard X-Patchwork-Id: 36810 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 510D827BBEA; Tue, 25 Jan 2022 19:26:10 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 0887F27BBE9 for ; Tue, 25 Jan 2022 19:26:10 +0000 (GMT) Received: from localhost ([::1]:48536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCRSC-0004nL-UE for patchwork@mira.cbaines.net; Tue, 25 Jan 2022 14:26:09 -0500 Received: from eggs.gnu.org ([209.51.188.92]:37980) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCRPD-000475-Jz for guix-patches@gnu.org; Tue, 25 Jan 2022 14:23:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:57253) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCRPD-0000B6-9i for guix-patches@gnu.org; Tue, 25 Jan 2022 14:23:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nCRPD-0001Eo-6o for guix-patches@gnu.org; Tue, 25 Jan 2022 14:23:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#52555] [RFC PATCH v2 3/5] Add (guix eris). Resent-From: pukkamustard Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Tue, 25 Jan 2022 19:23:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52555 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 52555@debbugs.gnu.org Cc: pukkamustard , ~pukkamustard/eris@lists.sr.ht Received: via spool by 52555-submit@debbugs.gnu.org id=B52555.16431385634679 (code B ref 52555); Tue, 25 Jan 2022 19:23:03 +0000 Received: (at 52555) by debbugs.gnu.org; 25 Jan 2022 19:22:43 +0000 Received: from localhost ([127.0.0.1]:50148 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nCROs-0001DI-BI for submit@debbugs.gnu.org; Tue, 25 Jan 2022 14:22:43 -0500 Received: from mout01.posteo.de ([185.67.36.65]:36957) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nCROb-0001CE-9T for 52555@debbugs.gnu.org; Tue, 25 Jan 2022 14:22:26 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id B5880240027 for <52555@debbugs.gnu.org>; Tue, 25 Jan 2022 20:22:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1643138539; bh=fVwvh/6zrIV6B6hs8ZwDshihybQDuGkAoOjNHeNPWh0=; h=From:To:Cc:Subject:Date:From; b=fTYsV4CtQohwGGN+e0QsRfHniRoyA+0SWQRTT2GBxL7YZcRXo45y1ErrC2zwJvy2O PGflmXpSURrMEQnNriXAl/8Fe66gU++bDKN2+VC6DAoPKaStR8NStByTW+aOSYcv9M 1RhQ0Dlcw1kCPXpJe5qJQPaaTSkGLhFm+xPuNLbXFDxvatMP82Jpmr3917yYvi91eF ClknkBsjLiwHbFnA8oALpQ9uES/59k4i08LYdruI8+2X31Vvoyfx+Wq0DXtlDy8BHk fDTxGjJKyQ+J0yTlRGW+3TvbKzVlwtKrvFq8oB+7h4iYVwfFXgu16tYk8114pkHRo3 lRS+RrCvPAw3Q== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4JjxZ25J44z9rxF; Tue, 25 Jan 2022 20:22:18 +0100 (CET) From: pukkamustard Date: Tue, 25 Jan 2022 19:21:59 +0000 Message-Id: <20220125192201.7582-4-pukkamustard@posteo.net> In-Reply-To: <20220125192201.7582-1-pukkamustard@posteo.net> References: <20220125192201.7582-1-pukkamustard@posteo.net> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * guix/ipfs.scm: New file. * Makefile.am (MODULES): Add it. --- Makefile.am | 1 + guix/eris.scm | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 guix/eris.scm diff --git a/Makefile.am b/Makefile.am index a10aeb817b..7219386361 100644 --- a/Makefile.am +++ b/Makefile.am @@ -131,6 +131,7 @@ MODULES = \ guix/cve.scm \ guix/workers.scm \ guix/ipfs.scm \ + guix/eris.scm \ guix/build-system.scm \ guix/build-system/android-ndk.scm \ guix/build-system/ant.scm \ diff --git a/guix/eris.scm b/guix/eris.scm new file mode 100644 index 0000000000..163bbe05ac --- /dev/null +++ b/guix/eris.scm @@ -0,0 +1,55 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2022 pukkamustard +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (guix eris) + #:use-module (eris) + #:use-module (eris blocks ipfs) + #:use-module (web client) + #:use-module (web response) + #:use-module (srfi srfi-71) + + #:export (guix-eris-block-reducer)) + +(define (ipfs-daemon-alive?) + "Attempt to connect to the IPFS daemon. Returns #t if the daemon is alive +and #f else." + (with-exception-handler + (const #f) + (lambda _ + (let ((response _ + (http-post (string-append (%ipfs-base-url) + "/api/v0/version")))) + (equal? 200 (response-code response)))) + #:unwind? #t)) + +(define guix-eris-block-reducer + (case-lambda + + ;; Check if IPFS Daemon is running. + (() (if (ipfs-daemon-alive?) + (eris-blocks-ipfs-reducer) + #f)) + + ;; Completion. Nothing to do. + ((_) #t) + + ((ipfs ref-block) + ;; If IPFS has been initialized store block there + (if ipfs + (eris-blocks-ipfs-reducer ipfs ref-block) + ipfs))))