From: self <self@awful.systems>
Date: Mon, 3 Jul 2023 07:59:31 +0000 (-0700)
Subject: fix lemmy and lemmy-ui version info
X-Git-Url: http://these/git/readmes/%7B%60https:/%22https:/hacktivis.me/static/gitweb.js?a=commitdiff_plain;h=eef36dd281111cf8aed923f9df52b3055bc20c68;p=awful.systems.git

fix lemmy and lemmy-ui version info
---

diff --git a/lemmy/server.nix b/lemmy/server.nix
index a76ce53..9fcf594 100644
--- a/lemmy/server.nix
+++ b/lemmy/server.nix
@@ -1,20 +1,9 @@
-{ lib
-, stdenv
-, rustPlatform
-, fetchFromGitHub
-, openssl
-, postgresql
-, libiconv
-, Security
-, protobuf
-, rustfmt
-, nixosTests
-}:
+{ lib, stdenv, rustPlatform, fetchFromGitHub, openssl, postgresql, libiconv
+, Security, protobuf, rustfmt, nixosTests }:
 let
   pinData = lib.importJSON ./pin.json;
   version = pinData.version;
-in
-rustPlatform.buildRustPackage rec {
+in rustPlatform.buildRustPackage rec {
   inherit version;
   pname = "lemmy-server";
 
@@ -31,6 +20,10 @@ rustPlatform.buildRustPackage rec {
   buildInputs = [ postgresql ]
     ++ lib.optionals stdenv.isDarwin [ libiconv Security ];
 
+  postPatch = ''
+    echo "pub const VERSION: &str = \"${version}\";" > "crates/utils/src/version.rs"
+  '';
+
   # Using OPENSSL_NO_VENDOR is not an option on darwin
   # As of version 0.10.35 rust-openssl looks for openssl on darwin
   # with a hardcoded path to /usr/lib/libssl.x.x.x.dylib
diff --git a/lemmy/ui.nix b/lemmy/ui.nix
index db5d6dd..fe2e4ab 100644
--- a/lemmy/ui.nix
+++ b/lemmy/ui.nix
@@ -1,5 +1,5 @@
-{ lib, mkYarnPackage, libsass, nodejs, python3, pkg-config
-, fetchFromGitHub, fetchYarnDeps, nixosTests }:
+{ lib, mkYarnPackage, libsass, nodejs, python3, pkg-config, fetchFromGitHub
+, fetchYarnDeps, nixosTests }:
 
 let
   pinData = lib.importJSON ./pin.json;
@@ -39,6 +39,10 @@ in mkYarnPackage {
     sha256 = pinData.uiYarnDepsSha256;
   };
 
+  postPatch = ''
+    echo "export const VERSION = '${version}';" > "src/shared/version.ts"
+  '';
+
   yarnPreBuild = ''
     export npm_config_nodedir=${nodejs}
   '';