zaphyra's git: tgcNUR

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

commit b2cd6d89da38bad33192d0ff321cc07b270d79a7
parent 1bb7ce2003f2dcd267f7291db65df1edb5f87837
Author: Katja Ramona Sophie Kwast (zaphyra) <git@zaphyra.eu>
Date: Fri, 20 Feb 2026 21:08:49 +0100

packages/gomuks-web: update version to current master \
3 files changed, 104 insertions(+), 137 deletions(-)
M
flake.nix
|
5
++++-
A
overlays/libheif/default.nix
|
11
+++++++++++
M
packages/gomuks-web/package.nix
|
225
+++++++++++++++++++++++++++++++------------------------------------------------
diff --git a/flake.nix b/flake.nix
@@ -59,7 +59,10 @@
         homeManagerModules = modulesTemplate (import ./homeManagerModules inputs.self);
         nixosModules = (modulesTemplate (import ./nixosModules inputs.self)) // {
           packages = {
-            nixpkgs.overlays = [ inputs.self.overlays.packages ];
+            nixpkgs.overlays = with inputs.self.overlays; [
+              libheif
+              packages
+            ];
           };
         };
 
diff --git a/overlays/libheif/default.nix b/overlays/libheif/default.nix
@@ -0,0 +1,11 @@
+final: prev: {
+  libheif = prev.libheif.overrideAttrs {
+    version = "1.21.2";
+    src = prev.fetchFromGitHub {
+      owner = "strukturag";
+      repo = "libheif";
+      rev = "v${final.libheif.version}";
+      hash = "sha256-odkJ0wZSGoZ7mX9fkaNREDpMvQuQA9HKaf3so1dYrbc=";
+    };
+  };
+}
diff --git a/packages/gomuks-web/package.nix b/packages/gomuks-web/package.nix
@@ -1,150 +1,103 @@
 {
   tgcMaintainers,
   lib,
-  fetchFromGitHub,
   applyPatches,
+  fetchFromGitHub,
+  fetchNpmDeps,
   buildGoModule,
-  buildNpmPackage,
-  go,
   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:
-  let
-    ver = "0.2025.11";
+buildGoModule (finalAttrs: {
+  pname = "gomuks-web";
+  version = "0.2602.0-0dbd2ff1";
 
-  in
-  {
-    pname = "gomuks-web";
-    version = "${ver}-unstable-2025-11-01";
-    rev = "be0d4487871c196d0c47bb1b6ac7ce9252d424de";
+  inherit vendorHash;
 
-    srcHash = "sha256-x7M7d8obnt8mpH1ZRev8c39PE5ZlgssgusGvrLaF/vg=";
-    npmDepsHash = "sha256-4Ir4uq9Hg6Hwj21P/H7xWdVPzYrDrXiouEtjnLJj4Ko=";
-    vendorHash = "sha256-TDvTZ0n324pNPAPMZMhWq0LdDUqFrzBXNVNdfMlxqeQ=";
-    src = applyPatches {
-      src = fetchFromGitHub {
-        owner = "tulir";
-        repo = "gomuks";
-        hash = finalAttrs.srcHash;
-        inherit (finalAttrs) rev;
-      };
-      patches = [
-        ./0001-web-remove-underscore-from-gomuks.wasm.patch
-      ]
-      ++ extraPatches;
+  src = applyPatches {
+    src = fetchFromGitHub {
+      owner = "gomuks";
+      repo = "gomuks";
+      hash = srcHash;
+      inherit rev;
     };
-
-    frontend = buildNpmPackage (frontendFinalAttrs: {
-      name = "${finalAttrs.pname}_${finalAttrs.version}-frontend";
-      src = finalAttrs.src;
-      inherit (finalAttrs) version npmDepsHash;
-
-      goStuff = buildGoModule {
-        name = "${finalAttrs.pname}_${finalAttrs.version}-wasm";
-        inherit (finalAttrs) src vendorHash;
-
-        env.CGO_ENABLED = 0;
-
-        doCheck = false;
-
-        buildPhase = ''
-          runHook preBuild
-
-          GOOS=js GOARCH=wasm go build -tags goolm -ldflags "${lib.concatStringsSep " " finalAttrs.ldflags}" -o ./gomuks.wasm ./cmd/wasmuks
-          go build -o ./print ./pkg/hicli/cmdspec/print
-
-          runHook postBuild
-        '';
-
-        installPhase = ''
-          runHook preInstall
-
-          mkdir -p $out
-          cp gomuks.wasm $out
-          cp print $out
-
-          runHook postInstall
-        '';
-      };
-
-      postPatch = ''
-        cp ${frontendFinalAttrs.goStuff}/gomuks.wasm web/src/api/wasm/gomuks.wasm
-        ${frontendFinalAttrs.goStuff}/print web/src/api/types/stdcommands.json web/src/api/types/stdcommands.d.ts
-        cp web/{package.json,package-lock.json} ./
-      '';
-
-      buildPhase = ''
-        runHook preBuild
-
-        cd ./web
-
-        npm install
-
-        ../node_modules/typescript/bin/tsc -b
-        ../node_modules/vite/bin/vite.js build
-
-        runHook postBuild
-      '';
-
-      installPhase = ''
-        runHook preInstall
-
-        cp -r ./dist $out
-
-        runHook postInstall
-      '';
-    });
-
-    # these flags have to be set, otherwise a dev-build will be created, which is missing features
-    ldflags = [
-      "-X 'go.mau.fi/gomuks/version.Tag=v${ver}'"
-      "-X 'go.mau.fi/gomuks/version.Commit=${finalAttrs.rev}'"
-      "-X 'go.mau.fi/gomuks/version.BuildTime=2000-01-01T00:00:01+00:00'"
-      (lib.concatStrings [
-        "-X 'maunium.net/go/mautrix.GoModVersion="
-        (lib.pipe (builtins.readFile "${finalAttrs.src}/go.mod") [
-          (builtins.match "^.*maunium.net/go/mautrix ([a-z0-9\.-]+).*$")
-          lib.last
-        ])
-        "'"
-      ])
-    ];
-
-    doCheck = false;
-
-    tags = [ "goolm" ];
-
-    subPackages = [
-      "cmd/gomuks"
-      "cmd/gomuks-terminal"
-      "cmd/archivemuks"
-    ];
-
-    preBuild = ''
-      cp -rf ${finalAttrs.frontend} ./web/dist
-    '';
-
-    postInstall = ''
-      mv $out/bin/gomuks $out/bin/gomuks-web
-    '';
-
-    passthru.updateScript = {
-      inherit (finalAttrs) frontend;
-      updateScript = unstableGitUpdater {
-        branch = "main";
-      };
+    patches = extraPatches;
+  };
+
+  nativeBuildInputs = [
+    nodejs
+    npmHooks.npmConfigHook
+    pkg-config
+  ];
+
+  buildInputs = [
+    libheif
+  ];
+
+  env = {
+    npmRoot = "web";
+    npmDeps = fetchNpmDeps {
+      src = "${finalAttrs.src}/web";
+      hash = npmDepsHash;
     };
-
-    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;
+  };
+
+  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;
+  };
+})