help-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to create a package written in Go


From: Csepp
Subject: Re: How to create a package written in Go
Date: Sun, 05 Nov 2023 20:28:00 +0100

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 via email to

[Prev in Thread] Current Thread [Next in Thread]