commit 9398810b0e70d1284239782b4d3535c8faf0e52e
parent 9cd66b692ec633fc057bf4d4e45e7d0e4d78271a
Author: Katja (ctucx) <git@ctu.cx>
Date: Thu, 20 Mar 2025 15:15:19 +0100
parent 9cd66b692ec633fc057bf4d4e45e7d0e4d78271a
Author: Katja (ctucx) <git@ctu.cx>
Date: Thu, 20 Mar 2025 15:15:19 +0100
packages/all: add `gomuks-web`
1 file changed, 61 insertions(+), 0 deletions(-)
diff --git a/packages/all/gomuks-web.nix b/packages/all/gomuks-web.nix @@ -0,0 +1,61 @@ +{ lib, fetchFromGitHub, buildGo123Module, buildNpmPackage, stdenv, olm, withGoolm ? true, ... }: + +let + cppStdLib = if stdenv.hostPlatform.isDarwin then "-lc++" else "-lstdc++"; + +in buildGo123Module rec { + pname = "gomuks-web"; + rev = "295d1f156e4d4bd1b0e47596cc1bf02c1b9173ec"; + sha256 = "sha256-AB7Gjs/42r3CiHTOqc0Y3EJCUio9i48dMGsLMRQG+nA="; + + # Extract version from version.go + versionContent = builtins.readFile "${src}/version/version.go"; + versionMatch = builtins.match ''^.*const StaticVersion = "([0-9\.]+)".*$'' versionContent; + version = "${builtins.elemAt versionMatch 0}-${builtins.substring 0 6 rev}"; + + src = fetchFromGitHub { + owner = "tulir"; + repo = "gomuks"; + inherit rev sha256; + }; + + frontend = buildNpmPackage{ + name = "${pname}_${version}-frontend"; + src = "${src}/web"; + inherit version; + + npmBuildScript = "build"; + npmDepsHash = "sha256-ilgjik6TlhSfnRKN7MfJZ9rJfcGLfwNZ9JhuTxgBmTM="; + + installPhase = '' + cp -r dist $out + ''; + }; + + vendorHash = "sha256-uF1WoSFOnKqaydqRRDzol0jKO5KmqLNRL0apupDCtIg="; + + buildInputs = (lib.optional (!withGoolm) olm) ++ (lib.optional withGoolm stdenv.cc.cc.lib); + + CGO_LDFLAGS = lib.optional withGoolm [ cppStdLib ]; + + tags = lib.optional withGoolm "goolm"; + + subPackages = [ "cmd/gomuks" ]; + + preBuild = '' + cp -r ${frontend} ./web/dist; + ''; + + installPhase = '' + mkdir -p $out/bin; + cp $GOPATH/bin/gomuks $out/bin/gomuks-web; + ''; + + doCheck = false; + + meta = with lib; { + description = "A Matrix client written in Go"; + homepage = "https://github.com/tulir/gomuks"; + mainProgram = "gomuks-web"; + }; +}