Help with building a GO app (stmps)

stmps is a terminal client for *sonic music servers, inspired by ncmpcpp and musickube. Since it doesn’t exist in the nixpkgs I would like to build one myself, but I seem to get stuck in the last step. I would greatly appreciate if someone could extend their expertise on the topic.

Irregularities
Since the project doesn’t have any versions I am trying to build it from commit.

CODE

{ lib
, stdenv
, fetchFromGitHub
, buildGoModule
, mpv
# , pkgconfig
}:

let
  version = "0.0.5";
  pname = "stmps";
  commit = "3748452234fb305f5c1c46501833723156a964e3";
  hash = "sha256-kuzvOAtJnFPuSKWZ7WHDnx+8iP2qHu5gXB1rgGKLHPI=";
in

buildGoModule {
  inherit pname;
  inherit version;

  src = fetchFromGitHub {
    owner = "xxxserxxx";
    repo = "stmps";
    rev = "${commit}";
    hash = "${hash}";
  };

  buildInputs = [
    mpv
    mpv
  ];

  ldflags = [
    "-s" "-w"
    "-X main.Version=${version}"
    "-X main.Commit=${version}"
    "-L ${mpv}/lib"
  ];

  vendorHash = "sha256-nQ+njG45mYJ6lkGPOsEe+ob4EXvIoJ2d+cFXZSM3Lls=";

#  nativeBuildInputs = [ pkgconfig ];

  meta = with lib; {
    homepage = "https://github.com/xxxserxxx/stmps";
    description = "Stmps is a terminal client for *sonic music servers, inspired by ncmpcpp and musickube.";
    license = licenses.gpl3Plus;
    maintainers = [ ];
  };
}

I have given it a placeholder commit.

I was just about to make a post about this. I too would like to get this working. Please post a solution once you get this figured out.

What are you stuck on? The question is unclear.

My bad, the build process fails at CheckPhase when executing

nix-build -E 'with import <nixpkgs> {}; callPackage ./stmps.nix {}'
Running phase: checkPhase
# github.com/spezifisch/stmps [github.com/spezifisch/stmps.test]
./cache_test.go:21:4: too many arguments in call to NewCache
        have (string, func(k string) (string, error), func(k string, v string), func(k string) bool, time.Duration, *logger.Logger)
        want (T, func(string) (T, error), func(string, T), func(string) string, *logger.Logger)
./cache_test.go:43:4: too many arguments in call to NewCache
        have (int, func(k string) (int, error), func(k string, v int), func(k string) bool, time.Duration, *logger.Logger)
        want (T, func(string) (T, error), func(string, T), func(string) string, *logger.Logger)
./cache_test.go:70:3: too many arguments in call to NewCache
        have (string, func(k string) (string, error), func(k string, v string), func(k string) bool, time.Duration, *logger.Logger)
        want (T, func(string) (T, error), func(string, T), func(string) string, *logger.Logger)
./cache_test.go:107:3: too many arguments in call to NewCache
        have (string, func(k string) (string, error), func(k string, v string), func(k string) bool, time.Duration, *logger.Logger)
        want (T, func(string) (T, error), func(string, T), func(string) string, *logger.Logger)
./cache_test.go:132:4: too many arguments in call to NewCache
        have (string, func(k string) (string, error), func(k string, v string), func(k string) bool, time.Duration, *logger.Logger)
        want (T, func(string) (T, error), func(string, T), func(string) string, *logger.Logger)
./cache_test.go:161:4: too many arguments in call to NewCache
        have (string, func(k string) (string, error), func(k string, v string), func(k string) bool, time.Duration, *logger.Logger)
        want (T, func(string) (T, error), func(string, T), func(string) string, *logger.Logger)
./cache_test.go:190:3: too many arguments in call to NewCache
        have (string, func(k string) (string, error), func(k string, v string), func(k string) bool, time.Duration, *logger.Logger)
        want (T, func(string) (T, error), func(string, T), func(string) string, *logger.Logger)
./stmps_test.go:18:12: not enough arguments in call to logger.Init
        have ()
        want (string)
FAIL    github.com/spezifisch/stmps [build failed]
FAIL
error: builder for '/nix/store/g2xwsm5dj603dlwcmx1fdfj7vmznyfn6-stmps-0.0.5.drv' failed with exit code 1;
       last 25 log lines:
       >    have (string, func(k string) (string, error), func(k string, v string), func(k string) bool, time.Duration, *logger.Logger)
       >    want (T, func(string) (T, error), func(string, T), func(string) string, *logger.Logger)
       > ./cache_test.go:43:4: too many arguments in call to NewCache
       >  have (int, func(k string) (int, error), func(k string, v int), func(k string) bool, time.Duration, *logger.Logger)
       >     want (T, func(string) (T, error), func(string, T), func(string) string, *logger.Logger)
       > ./cache_test.go:70:3: too many arguments in call to NewCache
       >  have (string, func(k string) (string, error), func(k string, v string), func(k string) bool, time.Duration, *logger.Logger)
       >    want (T, func(string) (T, error), func(string, T), func(string) string, *logger.Logger)
       > ./cache_test.go:107:3: too many arguments in call to NewCache
       >         have (string, func(k string) (string, error), func(k string, v string), func(k string) bool, time.Duration, *logger.Logger)
       >    want (T, func(string) (T, error), func(string, T), func(string) string, *logger.Logger)
       > ./cache_test.go:132:4: too many arguments in call to NewCache
       >         have (string, func(k string) (string, error), func(k string, v string), func(k string) bool, time.Duration, *logger.Logger)
       >    want (T, func(string) (T, error), func(string, T), func(string) string, *logger.Logger)
       > ./cache_test.go:161:4: too many arguments in call to NewCache
       >         have (string, func(k string) (string, error), func(k string, v string), func(k string) bool, time.Duration, *logger.Logger)
       >    want (T, func(string) (T, error), func(string, T), func(string) string, *logger.Logger)
       > ./cache_test.go:190:3: too many arguments in call to NewCache
       >         have (string, func(k string) (string, error), func(k string, v string), func(k string) bool, time.Duration, *logger.Logger)
       >    want (T, func(string) (T, error), func(string, T), func(string) string, *logger.Logger)
       > ./stmps_test.go:18:12: not enough arguments in call to logger.Init
       >    have ()
       >        want (string)
       > FAIL     github.com/spezifisch/stmps [build failed]
       > FAIL
       For full logs, run 'nix log /nix/store/g2xwsm5dj603dlwcmx1fdfj7vmznyfn6-stmps-0.0.5.drv'.

There seem to be errors in the go tests of that project. You could disable the tests with doCheck = false and see if it still builds.

Have you checked if the go program actually builds and tests run through just using a nix shell with go tools installed?

Edit: I just saw that test fail since three month upstream as well:

I seem to have found the issue. I think the problem arises because i am using xxxserxxx’s fork of the original spezifisch’s fork. When changed to the original fork it successfully packaged the program. I still don’t understand the underlying reason for the error, although I suspect it lies with the program itself.

New Code

{
  lib,
  stdenv,
  fetchFromGitHub,
  buildGoModule,
  mpv,
  pkg-config
}:

let
  version = "0.0.5";
  pname = "stmps";
  commit = "4a8428bc06cc2490ff1caf7fc53fcacc5fc398c0";
  hash = "sha256-yR2foOt6sDShaLQ1dB4S9ni5sseItHxKBwTVvE5Em6g=";
in

buildGoModule {
  inherit pname;
  inherit version;

  src = fetchFromGitHub {
    owner = "spezifisch";
    repo = "stmps";
    rev = "${commit}";
    hash = "${hash}";
  };

  buildInputs = [
    mpv
    pkg-config
  ];

  ldflags = [
    "-s" "-w"
    "-X main.Version=${version}"
    "-X main.Commit=${version}"
    "-L ${mpv}/lib"
  ];

  vendorHash = "sha256-nQ+njG45mYJ6lkGPOsEe+ob4EXvIoJ2d+cFXZSM3Lls=";

  meta = with lib; {
    homepage = "https://github.com/spezifisch/stmps";
    description = "Stmps is a terminal client for *sonic music servers, inspired by ncmpcpp and musickube written in GO.";
    license = licenses.gpl3Plus;
    maintainers = [ ];
    platforms = [
      "x86_64-linux"
      "aarch64-darwin"
    ];
  };
}

Happy it works for you now.

Did you read what I wrote? It works because probably the test pass on that fork. Because that was the error previously.

Sorry, I only saw your reply now . I will try with a successful commit.

1 Like