Re: Packaging Golang programs

2021-05-07 Thread Ekaitz Zarraga
‐‐‐ Original Message ‐‐‐
On Friday, April 30, 2021 3:24 PM, Formbi  wrote:

> Hi
>
> I'm trying to package Protonmail's proton-bridge, which is written in Go. In 
> most cases, it's quite easy to import a package or write the definition 
> manually. However, some packages are made of sub-packages and the build 
> system says, for example:
>
> can't load package: package golang.org/x/mobile: no Go files in (…)
>
> Those packages are referenced as whole, though. If the sub-packages (with 
> #:unpack-path) are needed, they don't really work either. For example 
> github.com/shurcooL/httpfs/vfsutil in the test suite can't find itself:
>
> package github.com/shurcool/httpfs/vfsutil_test
> imports github.com/shurcooL/httpfs/vfsutil: cannot find package 
> "github.com/shurcooL/httpfs/vfsutil" in any of:
> /gnu/store/y5rwacd5l4q26pxis28wsmswj2603hkw-go-1.14.15/src/github.com/shurcooL/httpfs/vfsutil
>  (from $GOROOT)
> /tmp/guix-build-go-github-com-shurcool-httpfs-vfsutil-0.0.0-20190707220628-8d4bc4ba7749.drv-0/src/github.com/shurcooL/httpfs/vfsutil
>  (from $GOPATH)
> FAIL github.com/shurcool/httpfs/vfsutil [setup failed]
> FAIL
>
> Disabling the tests doesn't suffice here, because after it «builds», it can't 
> be found by a package which needs it. Could you please give me some 
> directions?
>
> Kind regards.



Hi,

I've been waiting until you got an answer here but seems you're
out of luck.

I'm writing just to tell you that I had the same issue in the
past, trying to package the same exact thing and I was unable to
solve it.

You have my solidarity at least.

That being said, we can join forces and make this package.

I'll ping some people in Guix's IRC to see if someone can help.
It is true that Go programs are pretty crazy with dependencies...

Sorry for the late response.

Best,
Ekaitz



Re: How to lower a record to the build code ?

2021-05-07 Thread Edouard Klein
Dear Christopher,

I can't thank you enough, your idea of "ungexp[ing] the record access
bits" is what got me out of the tarpit.

You can see the resulting code here, which will hopefully clear the
misunderstandings generated by my oversimplification of the minimal
nonworking example:
https://issues.guix.gnu.org/issue/48277

Thanks again !

Cheers,

Edouard.


Christopher Baines writes:

> e...@beaver-labs.com writes:
>
>> I've been stuck for a few days on the following:
>> Let's say I have a record type:
>>
>> (define-record-type*  my-record make-my-record
>>   my-record?
>>   this-record
>>  (first-field my-record-first-field)
>>  (second-field my-record-second-field))
>>
>> And a function that uses such a record, but needs to run on the build
>> side, because it also needs the store path of a package (I can't edit
>> this function):
>>
>> (define (function-of-a-record-and-a-build-time-path rec path)
>>   "Concatenate the path, first, and second field"
>>   (string-append path " " (my-record-first-field rec) " " (car
>>   (my-record-second-field rec)) " " (cdr (my-record-second-field rec
>>
>> How can I use this record in the build side. For example, I'm unable to
>> build the following G-exp:
>> (define a-record (my-record
>>   (first-field "first")
>>   (second-field '("second" . "third"
>>
>>
>> #~(with-output-to-file (string-append #$output "/file.txt")
>>  (lambda _
>>(display (function-of-a-record-and-a-build-time-path #$a-record
>>  #$bash)
>
> Could you ungexp the record access bits? So something like:
>
>   (string-append #$path " " #$(my-record-first-field rec) " " #$(car
> (my-record-second-field rec)) " " #$(cdr (my-record-second-field
> rec)))
>
> Obviously, then the handling of rec would just be on the build side.
>
> I'm not quite sure quite what your code looks like, in the example you
> give, you've got a number of problems.
>
> Ignoring the #$a-record, you'll need to (mkdir #$output) before trying
> to write to a file within that directory.
>
> Secondly, function-of-a-record-and-a-build-time-path isn't defined on
> the build side.
>
> If you want to define function-of-a-record-and-a-build-time-path on the
> host side, then you could have it return a gexp, something like:
>
>   (define (function-of-a-record-and-a-build-time-path rec path)
> "Concatenate the path, first, and second field"
> #~(string-append #$path " " #$(my-record-first-field rec) " " #$(car 
> (my-record-second-field rec)) " " #$(cdr (my-record-second-field rec
>
>   (build-gexp
>#~(begin
>(mkdir #$output)
>(with-output-to-file (string-append #$output "/file.txt")
>  (lambda _
>(display #$(function-of-a-record-and-a-build-time-path  a-record 
> bash))
>
> With these changes, the example you give works for me.