!QCCCSJHEsTIfozrZxz:nixos.org

Nix + Go

235 Members
Go packaging for and with Nixpkgs. | Be excellent to each other.50 Servers

Load older messages


SenderMessageTime
27 Aug 2023
@keanuk:matrix.orgKeanu joined the room.20:05:35
30 Aug 2023
@theclearpill:matrix.orgMoritz joined the room.08:49:10
@theclearpill:matrix.orgMoritzHey, I'm currently trying to build https://github.com/mautrix/discord using go. However, I'm having a missing dependency problem: ``` go: github.com/bwmarrin/discordgo@v0.27.0 requires golang.org/x/crypto@v0.8.0: missing go.sum entry; to add it: go mod download golang.org/x/cryp ``` I couldn't find anything in the documentation (https://nixos.org/manual/nixpkgs/unstable/#sec-language-go) on how I could add this dependency. Does anybody know how I could patch go.sum or something alike? Here is my current package definition: ```nix { lib , buildGoModule , fetchFromGitHub }: buildGoModule rec { pname = "discord"; version = "0.6.1"; src = fetchFromGitHub { owner = "mautrix"; repo = "discord"; rev = "v${version}"; hash = "sha256-rs7wWlQMc79Vls+cqPPo+lRzYAGye4WcKKz+9EXlEBo="; }; vendorSha256 = "sha256-GKUy/HYuPyaUNzfAD7NQWH+tuwcoQhWU4bfxhOpIM0Y="; ldflags = [ "-s" "-w" ]; doCheck = false; proxyVendor = true; meta = with lib; { description = "A Matrix-Discord puppeting bridge"; homepage = "https://github.com/mautrix/discord"; changelog = "https://github.com/mautrix/discord/blob/${src.rev}/CHANGELOG.md"; license = licenses.agpl3Only; maintainers = with maintainers; [ ]; }; } ```08:55:47
@j-k:matrix.orgj-k this should probably work
clone the repo > checkout the tag you want > go mod tidy > create patch file > add patch file to patches list (see other packages for examples
09:00:36
@theclearpill:matrix.orgMoritzThanks, I'll try it.09:01:48
@j-k:matrix.orgj-kremember when you add the patch you need to invalidate the vendorSha256 otherwise it might keep using the already fetched copy09:03:54
@theclearpill:matrix.orgMoritz I tried checking out cloning https://github.com/mautrix/discord and running go mod tidy, but it didn't produce any different result. The same with discordgo...
However, I did notice that the definition for crypto in the discordgo repo seems a bit odd: golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b. Could this have something to do with the error I'm getting?
09:07:41
@theclearpill:matrix.orgMoritz * I tried checking out cloning https://github.com/mautrix/discord and running go mod tidy, but it didn't produce any different result. The same with discordgo...
However, I did notice that the definition for crypto in the discordgo repo seems a bit odd: golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b. Could this have something to do with the error I'm getting?
09:07:55
@theclearpill:matrix.orgMoritz * I tried checking out cloning https://github.com/mautrix/discord and running go mod tidy, but it didn't produce any diff in git. The same with discordgo...
However, I did notice that the definition for crypto in the discordgo repo seems a bit odd: golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b. Could this have something to do with the error I'm getting?
09:08:17
@theclearpill:matrix.orgMoritz * I tried cloning https://github.com/mautrix/discord and running go mod tidy, but it didn't produce any diff in git. The same with discordgo...
However, I did notice that the definition for crypto in the discordgo repo seems a bit odd: golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b. Could this have something to do with the error I'm getting?
09:08:28
@j-k:matrix.orgj-kyeah. that's pre go modules by the looks of it09:10:02
@j-k:matrix.orgj-k

go get -u golang.org/x/crypto/... should probably update that

https://pkg.go.dev/golang.org/x/crypto#section-readme

09:10:39
@j-k:matrix.orgj-koh it does have x/crypto v0.12.0 in the go.mod so it shouldn't cause any issue there09:11:27
@j-k:matrix.orgj-kmaybe check which copy of go you're using for build and tidy09:12:36
@theclearpill:matrix.orgMoritzIt's go v1.20.7 in both cases.09:13:57
@theclearpill:matrix.orgMoritzMhh, I guess I'll just try another version.09:15:28
@j-k:matrix.orgj-k

I just built what you built and got

error: hash mismatch in fixed-output derivation '/nix/store/qkk0kml8q992k99ivj83bdf7fri7j8d7-discord-0.6.1-go-modules.drv':
         specified: sha256-GKUy/HYuPyaUNzfAD7NQWH+tuwcoQhWU4bfxhOpIM0Y=
            got:    sha256-8SfxzooeX9jPdi2FZ4iiGiF8e3DLtZhjOvFnNsvPAjU=

I don't think you invalidated your vendorsha256 when you changed something so it's using an old copy of the modules that's out of sync

09:17:34
@theclearpill:matrix.orgMoritzThats weird. I removed the vendorSha and got the same one back... ``` error: hash mismatch in fixed-output derivation '/nix/store/f41z9cabgm4qqk6g78vx2ig1s662f36n-discord-0.6.1-go-modules.drv': specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= got: sha256-GKUy/HYuPyaUNzfAD7NQWH+tuwcoQhWU4bfxhOpIM0Y= ```09:20:00
@theclearpill:matrix.orgMoritz * Thats weird. I removed the vendorSha and got the same one back... ` error: hash mismatch in fixed-output derivation '/nix/store/f41z9cabgm4qqk6g78vx2ig1s662f36n-discord-0.6.1-go-modules.drv': specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= got: sha256-GKUy/HYuPyaUNzfAD7NQWH+tuwcoQhWU4bfxhOpIM0Y= `09:20:09
@theclearpill:matrix.orgMoritz * Thats weird. I removed the vendorSha and got the same one back... ``` error: hash mismatch in fixed-output derivation '/nix/store/f41z9cabgm4qqk6g78vx2ig1s662f36n-discord-0.6.1-go-modules.drv': specified: sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA= got: sha256-GKUy/HYuPyaUNzfAD7NQWH+tuwcoQhWU4bfxhOpIM0Y= ```09:20:17
@j-k:matrix.orgj-kyou're on nixos or using nix on a different distro?09:20:54
@theclearpill:matrix.orgMoritzI'm on NixOS unstable. My nix-info: system: "x86_64-linux", multi-user?: yes, version: nix-env (Nix Super) 2.18.0pre20230813_65e8aba, channels(root): "nixos-21.11pre324423.34ad3ffe08a, nixpkgs-21.11pre325327.30f73c6493b", channels(moritz): "", nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos09:21:39
@j-k:matrix.orgj-k21.11 👀09:22:21
@theclearpill:matrix.orgMoritzOh wait 😧09:22:52
@j-k:matrix.orgj-k

FYI this builds for me using latest nixpkgs repo and

$ nix --version
nix (Nix) 2.15.1
{ lib
, buildGoModule
, fetchFromGitHub
, olm
}:

buildGoModule rec {
  pname = "discord";
  version = "0.6.1";

  src = fetchFromGitHub {
    owner = "mautrix";
    repo = "discord";
    rev = "v${version}";
    hash = "sha256-rs7wWlQMc79Vls+cqPPo+lRzYAGye4WcKKz+9EXlEBo=";
  };

  vendorSha256 = "sha256-ZI1+Tfru2OfnqLnaaiDL08OtSmbMBiRDvkL39+jhhmI=";

  ldflags = [ "-s" "-w" ];

  buildInputs = [ olm ];

  doCheck = false;

  meta = with lib; {
    description = "A Matrix-Discord puppeting bridge";
    homepage = "https://github.com/mautrix/discord";
    changelog = "https://github.com/mautrix/discord/blob/${src.rev}/CHANGELOG.md";
    license = licenses.agpl3Only;
    maintainers = with maintainers; [ ];
  };
}
09:24:43
@theclearpill:matrix.orgMoritzMhh it seems I still had the channels set from before I switched to flakes... Okay, thanks. I guess then there is just something wrong on my end. Sorry for wasting your time...09:25:49
@j-k:matrix.orgj-k np.
maybe try run this quickly nix run github:nixos/nixpkgs/nixpkgs-unstable#nix-info -- -m
09:28:33
@theclearpill:matrix.orgMoritz
  • system: "x86_64-linux"
    • host os: Linux 6.4.11, NixOS, 23.11 (Tapir), 23.11.20230823.9201b5f
    • multi-user?: no
    • sandbox: yes
    • version: nix-env (Nix Super) 2.18.0pre20230813_65e8aba
    • channels(root): ""
    • channels(moritz): ""
    • nixpkgs: not found
09:29:15
@theclearpill:matrix.orgMoritz *
  • system: "x86_64-linux"
  • host os: Linux 6.4.11, NixOS, 23.11 (Tapir), 23.11.20230823.9201b5f
  • multi-user?: no
  • sandbox: yes
  • version: nix-env (Nix Super) 2.18.0pre20230813_65e8aba
  • channels(root): ""
  • channels(moritz): ""
  • nixpkgs: not found
09:29:41
@theclearpill:matrix.orgMoritzI guess I really just need to setup my channels to follow the flake input.09:30:13

Show newer messages


Back to Room ListRoom Version: 9