| 30 May 2025 |
samuel | 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)? | 18:19:39 |
jrick | go already has its own (very good) dependency tooling | 18:22:17 |
jrick | buildGoModule is built to work with that | 18:22:36 |
K900 | 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 | practically every go project in existence uses go modules | 18:23:06 |
K900 | So the whole point of a central package repository is kind of ruined by that | 18:23:23 |
jrick | and when you create a nix port for some software, you want it to use those same ones | 18:23:25 |
samuel | That is not incompatible with providing them as nix dependencies | 18:23:32 |
samuel | that's how other languages with their own package modules work (haskell, elisp, python, ...) | 18:23:56 |
jrick | the difference is those all suck :) | 18:24:15 |
samuel | that I would not dispute :) | 18:24:43 |
samuel | but I still feel a bit dirty for using packages downloaded in my home directory when running in a nix shell :p | 18:25:24 |
samuel | 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 | GOMODCACHE will override where modules are downloaded to | 18:27:52 |
jrick | it can also be cleared at any time with go clean -modcache | 18:28:39 |
samuel | yeah, exactly. I think what I would like is a specific GOMODCACHE AND GOPATH for each nix shell | 18:29:35 |
samuel | * yeah, exactly. I think what I would like is a specific GOMODCACHE and GOPATH for each nix shell | 18:29:47 |
samuel | so that you don't get binaries pulled from your home | 18:30:06 |
K900 | I'm pretty sure you can do that with buildGoModule? | 18:30:21 |
K900 | Though you'll have to keep your vendorHash in sync | 18:30:34 |
jrick | forget GOPATH exists, the ones that matter are GOCACHE and GOMODCACHE | 18:31:18 |
samuel | I 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 shell | 18:34:07 |
samuel | which is convenient, but was counter intuitive at first | 18:34:32 |
samuel | I think I can live with that given that there is still a vendor hash | 18:34:55 |
jrick | go's tooling already handles that with the module cache (albeit per-user) | 18:35:14 |
samuel | yeah, I know | 18:35:25 |
samuel | my issue is that it feels counter-nixy, but it is probably me, that's why I was asking | 18:35:49 |
jrick | go cryptographically verifies the dependencies too so you're not going to risk building from different sources even if there is some download duplication | 18:37:19 |
jrick | and the cache files are read-only so unless you intentionally try to break them... | 18:38:28 |
samuel | Yeah, that's probably ok | 18:38:29 |