!QCCCSJHEsTIfozrZxz:nixos.org

Nix + Go

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

Load older messages


SenderMessageTime
5 Jun 2025
@s_r:matrix.orgsamuelYeah, but for the actual derivation I don't want to commit the vendor directory. I can obviously gitignore it, but then I need to remember to update the vendorHash before merging. Nothing of that is unsurmountable in any way, but it feels like a slightly awkward workflow, compared to how I would work in other languages.06:47:01
@s_r:matrix.orgsamuel(not complaining, to be clear, just trying to figure out if there are better ways to work with go in nix)06:47:52
@s_r:matrix.orgsamuelWhat do you mean with "regular devShell"?06:52:58
@diamondburned:matrix.orgDiamond (it/she) what other languages do you not need to also have a vendorHash for? 06:53:57
@diamondburned:matrix.orgDiamond (it/she)i know go, rust and node by default require those06:54:20
@diamondburned:matrix.orgDiamond (it/she)and that's like a lot06:54:25
@diamondburned:matrix.orgDiamond (it/she) just a devShells.default = pkgs.mkShell instead of using your package's build env 06:54:43
@s_r:matrix.orgsamuelI don't use it for haskell, python, c, ...06:54:57
@diamondburned:matrix.orgDiamond (it/she)because the Go build env in Nix sets some extra env vars that you don't want to use for deevlopment06:54:57
@diamondburned:matrix.orgDiamond (it/she)for haskell and C you're basically kind of using Nix as a build tool and dependency management system already06:55:20
@s_r:matrix.orgsamuel for those you get the dependencies in buildInputs 06:55:29
@diamondburned:matrix.orgDiamond (it/she)same for Python unless you use like Poetry06:55:30
@diamondburned:matrix.orgDiamond (it/she)you can theoretically package Go modules up as Nix derivations but like why when the language has already good dependency management on its own06:56:04
@diamondburned:matrix.orgDiamond (it/she)you'd rather just use the good dependency management and put it behind a fixed-output derivation06:56:19
@diamondburned:matrix.orgDiamond (it/she)at least for now until Nix has something better to deal with it06:56:25
@s_r:matrix.orgsamuelThat's fine, I'm not against using vendor :)06:56:38
@s_r:matrix.orgsamuel does mkShell for go pull the module dependencies in? 06:57:39
@diamondburned:matrix.orgDiamond (it/she) go the tool will do this for you 06:58:38
@diamondburned:matrix.orgDiamond (it/she) (it does in buildGoModule too) 06:58:53
@diamondburned:matrix.orgDiamond (it/she)((you just need the FDO hash for its output))06:59:02
@s_r:matrix.orgsamuel the problem with buildGoModule is that it sets the flag to do vendoring, if mkShell doesn't do that it might be nicer 06:59:55
@s_r:matrix.orgsamuelI'll give it a go later today07:00:08
@diamondburned:matrix.orgDiamond (it/she) i mean it might if you tell it to, but all of your mkShell should just be packages = [ go ] which only grabs the package in 07:00:31
@diamondburned:matrix.orgDiamond (it/she)maybe gopls and gotools for the standard dev tools07:00:44
@diamondburned:matrix.orgDiamond (it/she)LSP + goimports07:00:47
@diamondburned:matrix.orgDiamond (it/she) also if you don't mind doing go mod vendor but you do mind checking the whole vendor directory in, you could look at gomod2nix which generates a go.sum-esque file that is Nix-compatible instead 07:03:09
@diamondburned:matrix.orgDiamond (it/she) or use Tailscale's funny narhash tool 07:03:16
@diamondburned:matrix.orgDiamond (it/she) or use Tailscale's funny nardump tool 07:03:30
@diamondburned:matrix.orgDiamond (it/she)https://github.com/tailscale/tailscale/tree/main/cmd/nardump https://github.com/tailscale/tailscale/blob/main/update-flake.sh07:04:10
@s_r:matrix.orgsamuelI think I have some ideas now. Thanks!07:08:51

Show newer messages


Back to Room ListRoom Version: 9