!QCCCSJHEsTIfozrZxz:nixos.org

Nix + Go

231 Members
Go packaging for and with Nixpkgs. | Be excellent to each other.51 Servers

Load older messages


SenderMessageTime
29 May 2025
@deepreef11:matrix.orgdeepreef11 joined the room.02:58:43
30 May 2025
@s_r:matrix.org@s_r:matrix.org joined the room.18:00:52
@s_r:matrix.org@s_r:matrix.org Hi! I'm looking into developing some go, but I'm not sure I fully follow how dependencies are managed for go. For other languages I worked with, they are typically passed into buildInputs, which puts them in the development shell, but for go it seems that they need to be managed by go with go mod. Is that accurate? 18:02:49
@jrick:zettaport.comjrickfor the vast majority of dependencies, yes18:13:22
@jrick:zettaport.comjrickas soon as you start using cgo, those need to be put in the nix inputs18:13:59
@jrick:zettaport.comjrickas the go tooling doesn't know how/where to get those from18:14:12
@s_r:matrix.org@s_r:matrix.orgok, thanks18:17:24
@s_r:matrix.org@s_r:matrix.orgFeels a bit strange that I'll be using different files in the shell than to build the final derivation thought. What's the reason not to feed the dependencies to go as part of the build shell (e.g. by modifying GOPATH the same way the go builder does)?18:19:39
@jrick:zettaport.comjrickgo already has its own (very good) dependency tooling18:22:17
@jrick:zettaport.comjrickbuildGoModule is built to work with that18:22:36
@k900:0upti.meK900 ⚡️
In reply to @s_r:matrix.org
Feels a bit strange that I'll be using different files in the shell than to build the final derivation thought. What's the reason not to feed the dependencies to go as part of the build shell (e.g. by modifying GOPATH the same way the go builder does)?
Go will also explode horribly if you give it a version of an input that is even slightly off
18:22:52
@jrick:zettaport.comjrickpractically every go project in existence uses go modules18:23:06
@k900:0upti.meK900 ⚡️So the whole point of a central package repository is kind of ruined by that 18:23:23
@jrick:zettaport.comjrickand when you create a nix port for some software, you want it to use those same ones18:23:25
@s_r:matrix.org@s_r:matrix.orgThat is not incompatible with providing them as nix dependencies18:23:32
@s_r:matrix.org@s_r:matrix.orgthat's how other languages with their own package modules work (haskell, elisp, python, ...)18:23:56
@jrick:zettaport.comjrickthe difference is those all suck :)18:24:15
@s_r:matrix.org@s_r:matrix.orgthat I would not dispute :)18:24:43
@s_r:matrix.org@s_r:matrix.orgbut I still feel a bit dirty for using packages downloaded in my home directory when running in a nix shell :p18:25:24
@s_r:matrix.org@s_r:matrix.org maybe is possible to get the dependencies with go mod but store them as output of some derivation and use that as buildInput for the actual package that you are building... 18:26:50
@jrick:zettaport.comjrickGOMODCACHE will override where modules are downloaded to18:27:52
@jrick:zettaport.comjrick it can also be cleared at any time with go clean -modcache 18:28:39
@s_r:matrix.org@s_r:matrix.orgyeah, exactly. I think what I would like is a specific GOMODCACHE AND GOPATH for each nix shell18:29:35
@s_r:matrix.org@s_r:matrix.org* yeah, exactly. I think what I would like is a specific GOMODCACHE and GOPATH for each nix shell18:29:47
@s_r:matrix.org@s_r:matrix.orgso that you don't get binaries pulled from your home18:30:06
@k900:0upti.meK900 ⚡️ I'm pretty sure you can do that with buildGoModule? 18:30:21
@k900:0upti.meK900 ⚡️Though you'll have to keep your vendorHash in sync 18:30:34
@jrick:zettaport.comjrickforget GOPATH exists, the ones that matter are GOCACHE and GOMODCACHE18:31:18
@s_r:matrix.org@s_r:matrix.orgI guess the thing that got me thinking about this is that I need to download any given module once, the first time I need it, but then I don't need to do that again even if I'm in a different shell18:34:07
@s_r:matrix.org@s_r:matrix.orgwhich is convenient, but was counter intuitive at first18:34:32

Show newer messages


Back to Room ListRoom Version: 9