all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* (almost) deterministic patchsets
@ 2024-02-13 13:35 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.
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Graves via Development of GNU Guix and the GNU System distribution. @ 2024-02-13 13:35 UTC (permalink / raw)
  To: guix-devel


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: (almost) deterministic patchsets
  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.
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Graves via Development of GNU Guix and the GNU System distribution. @ 2024-02-24 23:05 UTC (permalink / raw)
  To: guix-devel


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: (almost) deterministic patchsets
  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.
  2024-05-10 15:48     ` Richard Sent
  0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Graves via Development of GNU Guix and the GNU System distribution. @ 2024-05-10 11:46 UTC (permalink / raw)
  To: guix-devel, zimoun.toutoune, Ludovic Courtès


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: (almost) deterministic patchsets
  2024-05-10 11:46   ` Nicolas Graves via Development of GNU Guix and the GNU System distribution.
@ 2024-05-10 15:48     ` Richard Sent
  2024-05-10 22:51       ` Ricardo Wurmus
  2024-05-10 22:51       ` Ricardo Wurmus
  0 siblings, 2 replies; 6+ messages in thread
From: Richard Sent @ 2024-05-10 15:48 UTC (permalink / raw)
  To: Nicolas Graves via Development of GNU Guix and the GNU System distribution.
  Cc: zimoun.toutoune, Ludovic Courtès, Nicolas Graves

> 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?
>

From my perspective having a pretty, command-line way to download patch
sets would be a nice QoL feature to have and might make the patch review
process simpler.

On a related note I recently discovered that issues.guix.gnu.org does
have a patch-set endpoint that optionally takes a revision e.g.
issues.guix.gnu.org/issue/70XXX/patch-set/3.

-- 
Take it easy,
Richard Sent
Making my computer weirder one commit at a time.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: (almost) deterministic patchsets
  2024-05-10 15:48     ` Richard Sent
@ 2024-05-10 22:51       ` Ricardo Wurmus
  2024-05-10 22:51       ` Ricardo Wurmus
  1 sibling, 0 replies; 6+ messages in thread
From: Ricardo Wurmus @ 2024-05-10 22:51 UTC (permalink / raw)
  To: Richard Sent
  Cc: Nicolas Graves via Development of GNU Guix and the GNU System distribution.,
	zimoun.toutoune, Ludovic Courtès, Nicolas Graves

Richard Sent <richard@freakingpenguin.com> writes:

> On a related note I recently discovered that issues.guix.gnu.org does
> have a patch-set endpoint that optionally takes a revision e.g.
> issues.guix.gnu.org/issue/70XXX/patch-set/3.

It's not advertised because it was not well tested at the time.  I'm
using this script to fetch and apply patch sets:

    #!/bin/sh
    wget -qO- https://issues.guix.gnu.org/issue/$1/patch-set/$2 | git am --patch-format mbox -3

-- 
Ricardo


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: (almost) deterministic patchsets
  2024-05-10 15:48     ` Richard Sent
  2024-05-10 22:51       ` Ricardo Wurmus
@ 2024-05-10 22:51       ` Ricardo Wurmus
  1 sibling, 0 replies; 6+ messages in thread
From: Ricardo Wurmus @ 2024-05-10 22:51 UTC (permalink / raw)
  To: Richard Sent
  Cc: Nicolas Graves via Development of GNU Guix and the GNU System distribution.,
	zimoun.toutoune, Ludovic Courtès, Nicolas Graves

Richard Sent <richard@freakingpenguin.com> writes:

> On a related note I recently discovered that issues.guix.gnu.org does
> have a patch-set endpoint that optionally takes a revision e.g.
> issues.guix.gnu.org/issue/70XXX/patch-set/3.

It's not advertised because it was not well tested at the time.  I'm
using this script to fetch and apply patch sets:

    #!/bin/sh
    wget -qO- https://issues.guix.gnu.org/issue/$1/patch-set/$2 | git am --patch-format mbox -3

-- 
Ricardo


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-05-10 22:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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.
2024-05-10 15:48     ` Richard Sent
2024-05-10 22:51       ` Ricardo Wurmus
2024-05-10 22:51       ` Ricardo Wurmus

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.