unofficial mirror of help-guix@gnu.org 
 help / color / mirror / Atom feed
From: Csepp <raingloom@riseup.net>
To: jean franco osvarcha <talkme@osvarcha.website>
Cc: help-guix@gnu.org
Subject: Re: How to create a package written in Go
Date: Sun, 05 Nov 2023 20:28:00 +0100	[thread overview]
Message-ID: <cucbkc8f0v8.fsf@riseup.net> (raw)
In-Reply-To: <1012919286.243533.1698171972070@privateemail.com>


jean franco osvarcha <talkme@osvarcha.website> writes:

> Hello guix users.
>
> I wanted to package the program nwg-look to edit my theme icons and
> others through a graphical interface because I am currently using
> Tiling Window Manager.
> nwg-look is written in GO and its repository is at
> [[https://github.com/nwg-piotr/nwg-look]], theoretically its
> compilation is simple because you only have to do one:
>
> -make build
> -sudo make install

Yggdrasil is similar, I suggest using that as a template.
Sadly the Go importer doesn't handle Go module files on the CLI
interface, but you can:
a) use sed/grep/etc to get the package names from the go.mod files and
feed them into guix import go -r (xargs can help)
b) look into how the importer is implemented, it might have a go.mod
parser in there that you could use.

> and reading the Makefile I can also do this manually:
>
> build:
> go build -v -o bin/nwg-look .
>
> install
> mkdir -p $(DESTDIR)/usr/share/nwg-look
> mkdir -p $(DESTDIR)/usr/share/nwg-look/langs
> mkdir -p $(DESTDIR)/usr/bin
> mkdir -p $(DESTDIR)/usr/share/applications
> mkdir -p $(DESTDIR)/usr/share/pixmaps
> cp stuff/main.glade $(DESTDIR)/usr/share/nwg-look/
> cp langs/* $(DESTDIR)/usr/share/nwg-look/langs/
> cp stuff/nwg-look.desktop $(DESTDIR)/usr/share/applications/
> cp stuff/nwgg-look.svg $(DESTDIR)/usr/share/pixmaps/
> cp bin/nwg-look $(DESTDIR)/usr/bin
>
> Which you could do this manually but it is not suitable in SDGuix.
> Reading the documentation in the Manual and the Cookbook I could only
> rely on small sample examples to which I could come up with this
> ~nwg-look-osv.scm~ file.

Just call make DESTDIR=$output install, you don't need to replicate the
install steps.  Sudo is not necessary.

> (use-modules (guix licenses)
> (guix utils)
> (guix packages)
> (guix download)
> (guix build-system go)
> (gnu packages golang)
> (gnu packages xorg)
> (gnu packages gtk)
> (gnu packages pkg-config))
>
> (package
> (name "nwg-look-osv")
> (version "0.2.4")
> (source (origin
> (method url-fetch)
> (uri (string-append "https://github.com/nwg-piotr/nwg-look/releases/download/" "v" version "/nwg-look-v" version "_x86_64"
> ".tar.gz"))
> (sha256
> (base32
> "1iphamazdsvl1cp59y8sxa3iswradna6z6rmm25nmpy3nxxbkapc"))))
> (build-system go-build-system)
> (synopsis "This application is a part of the nwg-shell project")
> (description
> "GTK3 settings editor adapted to work in the wlroots environment")
> (home-page "https://github.com/nwg-piotr/nwg-look/")
> (arguments
> '(#:import-path "https://github.com/nwg-piotr/nwg-look/"))
> (inputs
> (list go
> gtk+
> xcur2png
> pkg-config))
> (license gpl3+))

You need to put all the Go dependencies into the propagated-inputs
field.  Or just putting them in inputs might also be fine.
Remember, Guix packages don't have access to the network during builds,
so Go can't automatically download dependencies.

> But I can't get it to compile and install, if I do it manually in a
> ~guix shell go gtk+ xcur2png pkg-config~ and compile it on my own it
> does but I don't know how to install it and create the manifest.
> I don't have much notion in Go and packaging in Guix, but I guide from
> all the examples of others packages, I tried to do it with
> trivial-build-system but it was messing me up, if anyone has a help or
> comment I'm happy to answer.

Yes, it works in guix shell because you have network access and Go
circumvents the distro packages.

> Sorry for my english I'm using a translator DeepL

It's quite alright, although I can't make any guarantees about how well
my message will get translated.


      reply	other threads:[~2023-11-05 19:45 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-24 18:26 How to create a package written in Go jean franco osvarcha
2023-11-05 19:28 ` Csepp [this message]

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

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=cucbkc8f0v8.fsf@riseup.net \
    --to=raingloom@riseup.net \
    --cc=help-guix@gnu.org \
    --cc=talkme@osvarcha.website \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).