Creating my first nix pkg for wl-gammarelay with go, make and C

I have been attempting to package this project github.com/jeremija/wl-gammarelay and I’ve been having a lot of trouble. It uses CGO and has a Makefile that builds the wayland protocols and then runs “go build”

Im trying to wrap my head around this but every single source has radically different information on how this is to be done, and none of them have been particularly helpful. This was my first attempt, I also tried to use stdenv.mkDerivation alongside build phases but I cannot even get my feet off the ground here. I’m getting extremely generic errors like “cannot evaluate a function that does not have a value”

Any advice would be greatly appreciated, Im gearing up to learn Nix and make the switch over and this was a major package that I use that is not available in Nixpkgs. Of course there are alternatives but they do not also configure brightness and I hate that they are timer based, whereas wl-gammarelay is a simple daemon that responds to keybindings.

{
    lib,
    stdenv,
    fetchFromGitHub,
    wayland,
    # wlr-protocols,
    # pkg-config,
    # make,
    buildGoModule
}:

buildGoModule rec {
  pname = "wl-gammarelay";
  version = "0.1.1";

  src = fetchFromGitHub {
    owner = "jeremija";
    repo = pname;
    # rev = "b384bee6e2610f7ef9efd9f92778d52d4507dfb2";
    rev = "${version}";
    sha256 = "sha256-zk1U6bJpQrQXujbcqKjqSc0E+TxKY+p9w6sH8XYPm1c=";
  };

  # vendorHash = lib.fakeHash;
  # modHash = lib.fakeHash;

  nativeBuildInputs = [ wayland stdenv go glibc.static ];
  CGO_ENABLED = 1;

  ldflags = [
    "-X main.Version=${version}"
  ];

  # subPackages = [ "." ];

  meta = with stdenv.lib; {
    description = "A client and daemon for changing color temperature and brightness under Wayland via keybindings.";
    homepage = "https://github.com/jeremija/wl-gammarelay";
    license = licenses.gplv3;
    maintainers = with maintainers; [ sweetbbak ];
  };
};
}

I also tried things like this and another that imported nixpkgs from a tarball

{ lib, stdenv, fetchFromGitHub, buildGoModule, makeWrapper, pkgconfig, go, git }:

buildGoModule rec {
  pname = "wl-gammarelay";
  version = "0.1.1";  # Update with your version if needed

  src = fetchFromGitHub {
    owner = "jeremija";
    repo = pname;
    rev = "b384bee6e2610f7ef9efd9f92778d52d4507dfb2";
    # rev = "${version}";
    sha256 = "sha256-zk1U6bJpQrQXujbcqKjqSc0E+TxKY+p9w6sH8XYPm1c=";
  };

  buildInputs = [ git pkgconfig go ];

  ldflags = [
    "-X main.Version=${version}"
    # "-X main.CommitHash=${rev}"
  ];

  buildPhase = ''
    mkdir -p $out/bin
    go build ${ldflags} -o $out/bin/${pname} ./cmd/${pname}
  '';

  installPhase = ''
    mkdir -p $out/bin
    install -Dm755 $out/bin/${pname} $out/bin/${pname}
  '';

  meta = with stdenv.lib; {
    description = "A client and daemon for changing color temperature and brightness under Wayland via keybindings.";
    homepage = "https://github.com/jeremija/wl-gammarelay";
    license = licenses.gplv3;
    maintainers = with maintainers; [ sweetbbak ];
  };
}