!QCCCSJHEsTIfozrZxz:nixos.org

Nix + Go

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

Load older messages


SenderMessageTime
3 Oct 2024
@midirhee12:tchncs.demidirhee12 joined the room.14:38:10
4 Oct 2024
@katexochen:matrix.orgPaul Meyer (katexochen)https://github.com/NixOS/nixpkgs/issues/34638010:14:14
@bashfulrobot.:matrix.orgbashfulrobot changed their profile picture.16:24:15
6 Oct 2024
@galaxyyy:matrix.orgSaturn joined the room.03:59:58
@galaxyyy:matrix.orgSaturn

Hello, I am trying to package a Go application however I ran into an error I've never seen before and can't seem to find anything online

        github.com/hrfee/jfa-go/docs: is replaced in go.mod, but not marked as replaced in vendor/modules.txt
        github.com/hrfee/jfa-go/common: is replaced in go.mod, but not marked as replaced in vendor/modules.txt
        github.com/hrfee/jfa-go/ombi: is replaced in go.mod, but not marked as replaced in vendor/modules.txt
        github.com/hrfee/jfa-go/logger: is replaced in go.mod, but not marked as replaced in vendor/modules.txt
        github.com/hrfee/jfa-go/linecache: is replaced in go.mod, but not marked as replaced in vendor/modules.txt
        github.com/hrfee/jfa-go/api: is replaced in go.mod, but not marked as replaced in vendor/modules.txt
        github.com/hrfee/jfa-go/easyproxy: is replaced in go.mod, but not marked as replaced in vendor/modules.txt

        To ignore the vendor directory, use -mod=readonly or -mod=mod.
        To sync the vendor directory, run:
                go mod vendor

That is the error I am getting and here is my current derivation

{
  lib,
  buildGoModule,
  fetchFromGitHub,
  pkg-config,
  libayatana-appindicator,
  go-swag,
}:
buildGoModule rec {
  pname = "jfa-go";
  version = "0.5.1";

  src = fetchFromGitHub {
    owner = "hrfee";
    repo = "jfa-go";
    rev = "v${version}";
    hash = "sha256-7F0cPTG3LuZQk5AT5V5UwW9+dX25aGS8RDYi62CGDR8=";
  };
  vendorHash = "sha256-JC9d/FDG6hadkX1ywJ120BAsVkg/xMt9sUkh/DHModI=";

  nativeBuildInputs = [
    pkg-config
    go-swag
  ];

  buildInputs = [
    libayatana-appindicator
  ];

  preBuild = ''
    swag init -g main.go -d ${src}/
  '';

  ldflags = [
    "-X=main.version=v${version}"
    "-X=main.commit=${src.rev}"
    "-X=main.updater=binary"
    "-X=main.cssVersion=v3"
    "-X=main.builtBy=Nix"
  ];

  meta = {
    description = "A bit-of-everything user managament app for Jellyfin";
    homepage = "https://github.com/hrfee/jfa-go/tree/main";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [saturn745];
    mainProgram = "jfa-go";
  };
}

Does anybody have any ideas?

04:03:34
@katexochen:matrix.orgPaul Meyer (katexochen)

Saturn: The error your quoting doesn't seem to be the fatal one. Rather the build of internal.go seems to fail:

jfa-go> Building subPackage .
jfa-go> internal.go:13:12: pattern data: no matching files found

internal.go has a build tag !external, so it seems like this shouldn't be build by nix.

Also check the Makefile, where they control this build tag: https://github.com/hrfee/jfa-go/blob/main/Makefile#L35-L42

So add tags = [ "external" ];

Next error you will face is

jfa-go> Building subPackage .
jfa-go> Building subPackage ./common
jfa-go> main module (github.com/hrfee/jfa-go) does not contain package github.com/hrfee/jfa-go/common

As this is a multi-module repository ./common cannot be build, you can use subPackages so that only the top level package is build:

subPackages = [ "." ];

11:08:43
@katexochen:matrix.orgPaul Meyer (katexochen) *

Saturn: The error your quoting doesn't seem to be the fatal one. Rather the build of internal.go seems to fail:

jfa-go> Building subPackage .
jfa-go> internal.go:13:12: pattern data: no matching files found

internal.go has a build tag !external, so it seems like this shouldn't be build by nix.

Also check the Makefile, where they control this build tag: https://github.com/hrfee/jfa-go/blob/main/Makefile#L35-L42

So add tags = [ "external" ];

Next error you will face is

jfa-go> Building subPackage .
jfa-go> Building subPackage ./common
jfa-go> main module (github.com/hrfee/jfa-go) does not contain package github.com/hrfee/jfa-go/common

As this is a multi-module repository ./common cannot be build, you can use subPackages so that only the top level package is build:

subPackages = [ "." ];

Then it builds for me successfully. :)

11:09:21
@galaxyyy:matrix.orgSaturn
In reply to @katexochen:matrix.org

Saturn: The error your quoting doesn't seem to be the fatal one. Rather the build of internal.go seems to fail:

jfa-go> Building subPackage .
jfa-go> internal.go:13:12: pattern data: no matching files found

internal.go has a build tag !external, so it seems like this shouldn't be build by nix.

Also check the Makefile, where they control this build tag: https://github.com/hrfee/jfa-go/blob/main/Makefile#L35-L42

So add tags = [ "external" ];

Next error you will face is

jfa-go> Building subPackage .
jfa-go> Building subPackage ./common
jfa-go> main module (github.com/hrfee/jfa-go) does not contain package github.com/hrfee/jfa-go/common

As this is a multi-module repository ./common cannot be build, you can use subPackages so that only the top level package is build:

subPackages = [ "." ];

Then it builds for me successfully. :)

I see :) I greatly appreciate your help
15:06:41
@galaxyyy:matrix.orgSaturnAwesome yep it built. So this package also needs to generate some UI stuff via NodeJS it seems. What would be the best way to go about that? Just adding node into the build inputs and running the commands in a hook or is there a better way?15:55:08
@diamondburned:matrix.orgDiamond (it/she)i'd at least split the nodejs stuff out into a separate derivation then link/copy them in16:03:17
@diamondburned:matrix.orgDiamond (it/she) unless you want to use all 16:03:22
@diamondburned:matrix.orgDiamond (it/she) unless you want to use make all 16:03:25
@galaxyyy:matrix.orgSaturn
In reply to @diamondburned:matrix.org
i'd at least split the nodejs stuff out into a separate derivation then link/copy them in
Yeah thought about that as well
16:05:10
8 Oct 2024
@kaya:catnip.eekaya changed their profile picture.19:36:05
9 Oct 2024
@glepage:matrix.orgGaétan Lepage

Hi,
I'm packaging a simple go package and it fails with:

src/main.go:14:12: pattern manifest.json: no matching files found

This file indeed uses a go:embed instruction
https://github.com/mikew/nvrh/blob/main/src/main.go#L14

13:04:28
@glepage:matrix.orgGaétan Lepage I checked and the manifest.json is present in the root of the archive. Why can't it be found then ?
Is the nix go helper doing something weird here ?
13:05:07
@katexochen:matrix.orgPaul Meyer (katexochen) Gaétan Lepage: Has nothing to do with nix, check https://github.com/mikew/nvrh/blob/main/script/build 13:08:39
@katexochen:matrix.orgPaul Meyer (katexochen) * Gaétan Lepage: Has nothing to do with nix, check https://github.com/mikew/nvrh/blob/main/script/build#L14. You just need to copy the file from . to ./src 13:09:19
@glepage:matrix.orgGaétan LepageIndeed thanks a lot !13:10:31
10 Oct 2024
@p4cmanus3r:matrix.orgp4cmanus3r joined the room.13:24:34
11 Oct 2024
@netbrain:matrix.orgnetbrain joined the room.05:34:29
16 Oct 2024
@odysee:catgirl.cloudodysee joined the room.14:02:41
17 Oct 2024
@joerg:thalheim.ioMic92 changed their display name from Mic92 to Mic3000.06:51:17
@joerg:thalheim.ioMic92 changed their display name from Mic3000 to Mic3000 🌋.06:51:46
@joerg:thalheim.ioMic92 changed their display name from Mic3000 🌋 to Mic92.12:22:31
20 Oct 2024
@daveseddon:matrix.orgdave seddon joined the room.22:56:48
@daveseddon:matrix.orgdave seddonanyone had any success with gomod2nix please? I tried posting here: https://discourse.nixos.org/t/gomod2nix-cannot-find-module-providing-package/5455822:57:38
21 Oct 2024
@daveseddon:matrix.orgdave seddon
In reply to @galaxyyy:matrix.org

Hello, I am trying to package a Go application however I ran into an error I've never seen before and can't seem to find anything online

        github.com/hrfee/jfa-go/docs: is replaced in go.mod, but not marked as replaced in vendor/modules.txt
        github.com/hrfee/jfa-go/common: is replaced in go.mod, but not marked as replaced in vendor/modules.txt
        github.com/hrfee/jfa-go/ombi: is replaced in go.mod, but not marked as replaced in vendor/modules.txt
        github.com/hrfee/jfa-go/logger: is replaced in go.mod, but not marked as replaced in vendor/modules.txt
        github.com/hrfee/jfa-go/linecache: is replaced in go.mod, but not marked as replaced in vendor/modules.txt
        github.com/hrfee/jfa-go/api: is replaced in go.mod, but not marked as replaced in vendor/modules.txt
        github.com/hrfee/jfa-go/easyproxy: is replaced in go.mod, but not marked as replaced in vendor/modules.txt

        To ignore the vendor directory, use -mod=readonly or -mod=mod.
        To sync the vendor directory, run:
                go mod vendor

That is the error I am getting and here is my current derivation

{
  lib,
  buildGoModule,
  fetchFromGitHub,
  pkg-config,
  libayatana-appindicator,
  go-swag,
}:
buildGoModule rec {
  pname = "jfa-go";
  version = "0.5.1";

  src = fetchFromGitHub {
    owner = "hrfee";
    repo = "jfa-go";
    rev = "v${version}";
    hash = "sha256-7F0cPTG3LuZQk5AT5V5UwW9+dX25aGS8RDYi62CGDR8=";
  };
  vendorHash = "sha256-JC9d/FDG6hadkX1ywJ120BAsVkg/xMt9sUkh/DHModI=";

  nativeBuildInputs = [
    pkg-config
    go-swag
  ];

  buildInputs = [
    libayatana-appindicator
  ];

  preBuild = ''
    swag init -g main.go -d ${src}/
  '';

  ldflags = [
    "-X=main.version=v${version}"
    "-X=main.commit=${src.rev}"
    "-X=main.updater=binary"
    "-X=main.cssVersion=v3"
    "-X=main.builtBy=Nix"
  ];

  meta = {
    description = "A bit-of-everything user managament app for Jellyfin";
    homepage = "https://github.com/hrfee/jfa-go/tree/main";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [saturn745];
    mainProgram = "jfa-go";
  };
}

Does anybody have any ideas?

Saturn: I believe this means that you DO have a vendor/modules.txt file. e.g. The go.mod and modules.txt are out of sync with each other. Maybe "rm -rf vendor" will fix it? Or "go mod vendor"
17:33:36
@galaxyyy:matrix.orgSaturn
In reply to @daveseddon:matrix.org
Saturn: I believe this means that you DO have a vendor/modules.txt file. e.g. The go.mod and modules.txt are out of sync with each other. Maybe "rm -rf vendor" will fix it? Or "go mod vendor"
Actually seems I needed to just set subPackages = ["."] iirc
17:34:36
@galaxyyy:matrix.orgSaturn That error ended up not being the one that caused the build to fail and those were more so just warnings 17:35:03

Show newer messages


Back to Room ListRoom Version: 9