"Leo Famulari" <l...@famulari.name> writes: > On Fri, Jan 8, 2021, at 02:01, Timmy Douglas wrote: >> >> I recently installed guix for the first time and I wanted to try to >> package my first program. The one I decided to try is written in go and >> uses go.mod (https://github.com/coredns/coredns/blob/master/go.mod) for >> modules. Running `go build` would normally download those if they don't >> exist. >> >> I took a look at a couple of other packages, and it looks like the right >> way to do it would be to package the individual modules as seen in >> guix/gnu/packages/golang.scm. Has anyone tried automating this sort of >> thing? There are almost 40 dependencies... > > Thanks for working on this! > > It's true, Go programs usually have a dependency graph that is > uncomfortably large — although not impossibly large like Rust. > > There is a work-in-progress implementation of a Go package importer > that I believe should make it easier: > > https://issues.guix.gnu.org/issue/44178 > > You could try it out and, if it works for you, send those patches, and > give feedback on the importer as well :)
Thanks for the pointer! I tried both Katherine's patch (with dftxbs3e's mini fix for recursive-import) and Helio's patch (with a git remote add/cherry-pick) and had trouble with both of them. I spent a little more time with Katherine's patch so I'll go into that more below. Part of the issue is that I haven't used Scheme in like 15 years (and when I did, it wasn't for anything non-trivial). But I'm also really struggling to debug what's going on: I run `make && ./pre-inst-env guix import go -r github.com/coredns/coredns`: Starting download of /tmp/guix-file.pZqXNO >From https://proxy.golang.org/k8s.io/klog/@v/v1.0.0.mod... v1.0.0.mod 68B 88KiB/s 00:00 [##################] 100.0% metadata#f Backtrace: In ice-9/boot-9.scm: 1736:10 13 (with-exception-handler _ _ #:unwind? _ # _) In unknown file: 12 (apply-smob/0 #<thunk 7f98846a3740>) In ice-9/boot-9.scm: 718:2 11 (call-with-prompt _ _ #<procedure default-prompt-handle?>) In ice-9/eval.scm: 619:8 10 (_ #(#(#<directory (guile-user) 7f98842e0f00>))) In guix/ui.scm: 2154:12 9 (run-guix-command _ . _) In guix/scripts/import.scm: 120:11 8 (guix-import . _) In ice-9/eval.scm: 159:9 7 (_ _) In guix/import/utils.scm: 468:27 6 (recursive-import _ #:repo->guix-package _ #:guix-name _ ?) In srfi/srfi-1.scm: 586:17 5 (map1 (("k8s.io/klog" #f) ("k8s.io/client-go" #f) (?) ?)) In guix/import/utils.scm: 457:33 4 (lookup-node "k8s.io/klog" #f) In guix/utils.scm: 703:8 3 (call-with-temporary-output-file #<procedure 7f9871b8c7?>) In ice-9/eval.scm: 293:34 2 (_ #(#(#(#(#(#(#(#(#<directory ?> ?) ?) ?) ?) ?) ?) ?) ?)) 155:9 1 (_ #(#(#<directory (guix import go) 7f9882267f00>) #f)) In unknown file: 0 (list-ref #f 1) ERROR: In procedure list-ref: In procedure list-ref: Wrong type argument in position 1: #f I understand that (list-ref #f 1) won't work, but I can't figure out where that code is based on the information in the backtrace. Seems like the variables/symbols/filenames are missing everywhere where it counts. I loaded the code up with #'display and found that I needed to add another git scs/vcs entry for k8s.io, and that the fetch-module-meta-data method tries to use regexes to parse html: root-module-path= k8s.io/klog line= line= <html><head> line= <meta name="go-import" line= content="k8s.io/klog line= git https://github.com/kubernetes/klog"> line= <meta name="go-source" line= content="k8s.io/klog line= https://github.com/kubernetes/klog line= https://github.com/kubernetes/klog/tree/master{/dir} line= https://github.com/kubernetes/klog/blob/master{/dir}/{file}#L{line}"> line= </head></html> line= (define (fetch-module-meta-data module-path) "Fetches module meta-data from a module's landing page. This is necessary because goproxy servers don't currently provide all the information needed to build a package." (let* ((port (http-fetch (string->uri (format #f "https://~a?go-get=1" module-path)))) (module-metadata #f) (meta-tag-prefix "<meta name=\"go-import\" content=\"") (meta-tag-prefix-length (string-length meta-tag-prefix))) (do ((line (read-line port) (read-line port))) ((or (eof-object? line) module-metadata)) (let ((meta-tag-index (string-contains line meta-tag-prefix))) (display "line=") (display line) (newline) (when meta-tag-index (let* ((start (+ meta-tag-index meta-tag-prefix-length)) (end (string-index line #\" start))) (set! module-metadata (string-split (substring/shared line start end) #\space)))))) (close-port port) module-metadata)) I don't think the regex would match due to content="" being put on another line--so #f is returned and causes a type exception later. I'm a little more used to statically typed languages so tracing it back to there took longer than I would have liked. Maybe I need to find a video tutorial on writing Scheme for Guix or similiar? I felt like I was doing the wrong thing with printf/make/pre-inst-env guix. I tried starting geiser in emacs, but didn't really know what I should evaluate. It also added an unbearable lag to typing in the scheme buffer and didn't provide auto-completion or symbol lookup, so I didn't go too far with it... Would be interested if Katherine or Helio have any more updates.