zaphyra's git: tgcNUR

fork of https://git.transgirl.cafe/zaphoid/tgc-nix-user-repository

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
88 
89 
90 
91 
92 
93 
94 
95 
96 
97 
98 
99 
100 
101 
102 
103 
{
  tgcMaintainers,
  lib,
  applyPatches,
  fetchFromGitHub,
  fetchNpmDeps,
  buildGoModule,
  unstableGitUpdater,
  nodejs,
  npmHooks,
  pkg-config,
  libheif,
  extraPatches ? [ ],
  vendorHash ? "sha256-ml84pNkwuB55VSBNFRp9trnf+QxORkIz1Vq2ZBYs65g=",
  npmDepsHash ? "sha256-ob85fZDC3Qcos53MGvf+c1eGEO/SvfUTdnjA3T/y6/A=",
  rev ? "c794a3e9034d76dc1a8c1598f1ff957ecda9e22d",
  srcHash ? "sha256-2H+RiYIOJBxqIWP5OAOadlj8aebE0Gh2rG2G2o7Kb90=",
}:

buildGoModule (finalAttrs: {
  pname = "gomuks-web";
  version = "0.2602.0-0dbd2ff1";

  inherit vendorHash;

  src = applyPatches {
    src = fetchFromGitHub {
      owner = "gomuks";
      repo = "gomuks";
      hash = srcHash;
      inherit rev;
    };
    patches = extraPatches;
  };

  nativeBuildInputs = [
    nodejs
    npmHooks.npmConfigHook
    pkg-config
  ];

  buildInputs = [
    libheif
  ];

  env = {
    npmRoot = "web";
    npmDeps = fetchNpmDeps {
      src = "${finalAttrs.src}/web";
      hash = npmDepsHash;
    };
  };

  postPatch = ''
    substituteInPlace ./web/build-wasm.sh \
      --replace-fail 'go.mau.fi/gomuks/version.Tag=$(git describe --exact-match --tags 2>/dev/null)' "go.mau.fi/gomuks/version.Tag=v${finalAttrs.version}" \
      --replace-fail 'go.mau.fi/gomuks/version.Commit=$(git rev-parse HEAD)' "go.mau.fi/gomuks/version.Commit=${rev}"
  '';

  doCheck = false;

  tags = [
    "goolm"
    "libheif"
  ];

  ldflags = [
    "-X 'go.mau.fi/gomuks/version.Tag=v${finalAttrs.version}'"
    "-X 'go.mau.fi/gomuks/version.Commit=${rev}'"
    "-X \"go.mau.fi/gomuks/version.BuildTime=$(date -Iseconds)\""
    "-X \"maunium.net/go/mautrix.GoModVersion=$(cat go.mod | grep 'maunium.net/go/mautrix ' | head -n1 | awk '{ print $2 })\""
  ];

  subPackages = [
    "cmd/gomuks"
    "cmd/gomuks-terminal"
    "cmd/archivemuks"
  ];

  preBuild = ''
    go generate ./web
  '';

  postInstall = ''
    mv $out/bin/gomuks $out/bin/gomuks-web
  '';

  passthru.updateScript = {
    inherit (finalAttrs) frontend;
    updateScript = unstableGitUpdater {
      branch = "main";
    };
  };

  meta = {
    mainProgram = "gomuks-web";
    description = "Matrix client written in Go";
    homepage = "https://github.com/tulir/gomuks";
    license = lib.licenses.agpl3Only;
    maintainers = [ tgcMaintainers.zaphyra ];
    platforms = lib.platforms.unix;
  };
})