all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nicolas Graves via "Development of GNU Guix and the GNU System distribution." <guix-devel@gnu.org>
To: guix-devel@gnu.org, zimoun.toutoune@gmail.com,
	"Ludovic Courtès" <ludo@gnu.org>
Subject: Re: (almost) deterministic patchsets
Date: Fri, 10 May 2024 13:46:02 +0200	[thread overview]
Message-ID: <87a5kxga9x.fsf@ngraves.fr> (raw)
In-Reply-To: <87ttlxh39x.fsf@ngraves.fr>


One possible use would be to make `guix download` options, such as
`--patchset=70XXX -v3`

This could help with patch apply and review. We will have to also take
care of not making guix dependent on b4, but maybe that's possible with
lazy resolving the b4 package?

WDYT?

On 2024-02-25 00:05, Nicolas Graves wrote:

> This is basically done in
> https://git.sr.ht/~ngraves/dotfiles/commit/bd542512dfad2beccb4a6cdb2468f79aa869a55b
>
> Maybe some things need some polish, but the PoC is definitely here.
> Feel free to reuse this in upstream guix if you want.
>
> On 2024-02-13 14:35, Nicolas Graves wrote:
>
>> Hi !
>>
>> I've written this (gpl3+) that should be able to fetch patchsets for
>> both guix and rde. This should be robust enough for guix/rde use IMO.
>>
>> (define-module (guix mbox-download)
>>   #:use-module (guix packages)
>>   #:use-module ((guix self) #:select (make-config.scm))
>>   #:use-module (guix modules)
>>   #:use-module (guix monads)
>>   #:use-module (gnu packages guile)
>>   #:use-module (gnu packages tls)
>>   #:use-module (gnu packages version-control)
>>   #:use-module (guix store)
>>   #:use-module (guix gexp)
>>   #:use-module (guix records)
>>   #:export (mbox-fetch
>>             mbox-reference))
>>
>> (define-record-type* <mbox-reference>
>>   mbox-reference make-mbox-reference
>>   mbox-reference?
>>   (type mbox-reference-type)
>>   (id mbox-reference-id)
>>   (version mbox-reference-version))
>>
>> (define* (mbox-fetch ref hash-algo hash #:optional name
>>                      #:key (system %current-system) guile)
>>
>>   (define uri
>>     (format
>>      #f
>>      (assoc-ref
>>       '((gnu . "https://debbugs.gnu.org/cgi-bin/bugreport.cgi?bug=~a;mbox=yes")
>>         (rde . "https://lists.sr.ht/~~abcdw/rde-devel/patches/~a/mbox"))
>>        (mbox-reference-type ref))
>>      (mbox-reference-id ref)))
>>
>>   (define modules
>>     (cons `((guix config) => ,(make-config.scm))
>>           (delete '(guix config)
>>                   (source-module-closure '((guix build download)
>>                                            (guix build utils))))))
>>
>>   (define build
>>     (with-extensions (list guile-json-4 guile-gnutls)
>>       (with-imported-modules modules
>>         #~(begin
>>             (use-modules (guix build utils) (guix build download))
>>             (let ((mbox #$(match-record ref <mbox-reference>
>>                                         (type id version)
>>                             (format #f "~a-~a-~a.mbx" type id version))))
>>               (setenv "TMPDIR" (getcwd))
>>               (setenv "XDG_DATA_HOME" (getcwd))
>>               (invoke #$(file-append b4 "/bin/b4")
>>                       "-d" "-n" "--offline-mode" "--no-stdin"
>>                       "am" "--no-cover" "--no-cache"
>>                       "--use-local-mbox"
>>                       (url-fetch #$uri "mbox" #:verify-certificate? #f)
>>                       "--use-version"
>>                       (number->string #$(mbox-reference-version ref))
>>                       "--no-add-trailers"
>>                       "--outdir" "."
>>                       "--mbox-name" mbox)
>>               (install-file mbox #$output))))))
>>
>>   (mlet %store-monad ((guile (package->derivation (or guile (default-guile))
>>                                                   system)))
>>     (gexp->derivation (or name
>>                           (match-record ref <mbox-reference>
>>                                         (type id version)
>>                             (format #f "~a-~a-~a-mbox" type id version)))
>>       build
>>       ;; Use environment variables and a fixed script name so
>>       ;; there's only one script in store for all the
>>       ;; downloads.
>>       #:system system
>>       #:local-build? #t ;don't offload repo cloning
>>       #:hash-algo hash-algo
>>       #:hash hash
>>       #:recursive? #t
>>       #:guile-for-build guile)))
>>
>>
>> This can be used in such an example :
>>
>> (use-modules (guix mbox-download) (guix packages) (guix gexp)
>>              (guix monads) (guix store) (guix derivations))
>>
>> (with-store store
>>   (run-with-store store
>>     (mlet* %store-monad
>>         ((drv (origin->derivation
>>                (pk 'o (origin
>>                         (method mbox-fetch)
>>                         (uri (mbox-reference
>>                               (type 'rde)
>>                               (id 44893)
>>                               (version 4)))
>>                         (sha256
>>                          (base32 "1rs09wxvdaxrk2zh6g23s9min76wjm9lw0a5pjklc7cfraasi7s9")))))))
>>       (return drv))))
>>
>> Is guix interested in this, should I send a patch? What about renaming
>> this to patchset-reference instead of mbox-reference?
>>
>> My end-goal here is to use this to extend channels to channels with
>> patches, with something like this :
>>
>> (define* (instantiate-channel ch)
>>   (match ch
>>     ((name url ref patches)
>>      (primitive-eval
>>       `(channel
>>         (name ',name)
>>         ,@(if (null? patches)
>>               `((url ,(find-home url)))
>>               `((url ,(patched-source
>>                (symbol->string name)
>>                (git-checkout
>>                 (url (find-home url))
>>                 (commit ref))
>>                (search-patches patches)))))
>>         ,@(if ((@ (guix git) commit-id?) ref)
>>               `((commit ,ref))
>>               `((branch ,ref)))
>>         (introduction ,(assoc-ref channels-introductions name)))))))
>>
>> in the hypothesis where patched-source is exported from (guix transformations).
>
> --
> Best regards,
> Nicolas Graves

-- 
Best regards,
Nicolas Graves


  reply	other threads:[~2024-05-10 11:46 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-13 13:35 (almost) deterministic patchsets Nicolas Graves via Development of GNU Guix and the GNU System distribution.
2024-02-24 23:05 ` Nicolas Graves via Development of GNU Guix and the GNU System distribution.
2024-05-10 11:46   ` Nicolas Graves via Development of GNU Guix and the GNU System distribution. [this message]
2024-05-10 15:48     ` Richard Sent
2024-05-10 22:51       ` Ricardo Wurmus
2024-05-10 22:51       ` Ricardo Wurmus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87a5kxga9x.fsf@ngraves.fr \
    --to=guix-devel@gnu.org \
    --cc=ludo@gnu.org \
    --cc=ngraves@ngraves.fr \
    --cc=zimoun.toutoune@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.