2021-09-09 15:28:32 +01:00
|
|
|
{ lib
|
|
|
|
, mkYarnPackage
|
|
|
|
, libsass
|
|
|
|
, nodejs
|
|
|
|
, python3
|
|
|
|
, pkg-config
|
|
|
|
, fetchFromGitHub
|
2021-10-29 01:58:08 +01:00
|
|
|
, fetchYarnDeps
|
2022-09-02 10:02:51 +01:00
|
|
|
, nixosTests
|
2023-06-26 20:05:06 +01:00
|
|
|
, vips
|
|
|
|
, nodePackages
|
2021-09-09 15:28:32 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2021-10-29 02:07:48 +01:00
|
|
|
pinData = lib.importJSON ./pin.json;
|
|
|
|
|
2021-09-09 15:28:32 +01:00
|
|
|
pkgConfig = {
|
|
|
|
node-sass = {
|
2022-09-25 03:49:25 +01:00
|
|
|
nativeBuildInputs = [ pkg-config ];
|
|
|
|
buildInputs = [ libsass python3 ];
|
2021-09-09 15:28:32 +01:00
|
|
|
postInstall = ''
|
|
|
|
LIBSASS_EXT=auto yarn --offline run build
|
|
|
|
rm build/config.gypi
|
|
|
|
'';
|
|
|
|
};
|
2023-06-26 20:05:06 +01:00
|
|
|
sharp = {
|
|
|
|
nativeBuildInputs = [ pkg-config nodePackages.semver ];
|
|
|
|
buildInputs = [ vips ];
|
|
|
|
postInstall = ''
|
|
|
|
yarn --offline run install
|
|
|
|
'';
|
|
|
|
};
|
2021-09-09 15:28:32 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
name = "lemmy-ui";
|
2021-10-29 02:07:48 +01:00
|
|
|
version = pinData.version;
|
2021-09-09 15:28:32 +01:00
|
|
|
|
2021-10-03 06:51:06 +01:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "LemmyNet";
|
|
|
|
repo = name;
|
|
|
|
rev = version;
|
|
|
|
fetchSubmodules = true;
|
2021-10-29 02:07:48 +01:00
|
|
|
sha256 = pinData.uiSha256;
|
2021-10-03 06:51:06 +01:00
|
|
|
};
|
2021-10-29 01:58:08 +01:00
|
|
|
in
|
|
|
|
mkYarnPackage {
|
2021-09-09 15:28:32 +01:00
|
|
|
|
2021-10-29 01:58:08 +01:00
|
|
|
inherit src pkgConfig name version;
|
2021-09-09 15:28:32 +01:00
|
|
|
|
2021-10-03 06:51:06 +01:00
|
|
|
extraBuildInputs = [ libsass ];
|
2021-09-09 15:28:32 +01:00
|
|
|
|
2021-11-01 00:27:06 +00:00
|
|
|
packageJSON = ./package.json;
|
2021-10-29 01:58:08 +01:00
|
|
|
offlineCache = fetchYarnDeps {
|
|
|
|
yarnLock = src + "/yarn.lock";
|
2021-10-29 02:07:48 +01:00
|
|
|
sha256 = pinData.uiYarnDepsSha256;
|
2021-10-29 01:58:08 +01:00
|
|
|
};
|
2021-09-09 15:28:32 +01:00
|
|
|
|
2021-10-03 06:51:06 +01:00
|
|
|
yarnPreBuild = ''
|
|
|
|
export npm_config_nodedir=${nodejs}
|
|
|
|
'';
|
2021-09-09 15:28:32 +01:00
|
|
|
|
2021-10-03 06:51:06 +01:00
|
|
|
buildPhase = ''
|
|
|
|
# Yarn writes cache directories etc to $HOME.
|
|
|
|
export HOME=$PWD/yarn_home
|
2021-09-09 15:28:32 +01:00
|
|
|
|
2021-10-03 06:51:06 +01:00
|
|
|
ln -sf $PWD/node_modules $PWD/deps/lemmy-ui/
|
2023-06-27 04:36:54 +01:00
|
|
|
echo 'export const VERSION = "${version}";' > $PWD/deps/lemmy-ui/src/shared/version.ts
|
2021-09-09 15:28:32 +01:00
|
|
|
|
2021-10-03 06:51:06 +01:00
|
|
|
yarn --offline build:prod
|
|
|
|
'';
|
2021-09-09 15:28:32 +01:00
|
|
|
|
2021-10-03 06:51:06 +01:00
|
|
|
preInstall = ''
|
|
|
|
mkdir $out
|
2021-09-23 15:27:42 +01:00
|
|
|
cp -R ./deps/lemmy-ui/dist $out
|
|
|
|
cp -R ./node_modules $out
|
2021-10-03 06:51:06 +01:00
|
|
|
'';
|
2021-09-09 15:28:32 +01:00
|
|
|
|
2021-10-03 06:51:06 +01:00
|
|
|
distPhase = "true";
|
|
|
|
|
2021-10-29 02:07:48 +01:00
|
|
|
passthru.updateScript = ./update.sh;
|
2022-09-02 10:02:51 +01:00
|
|
|
passthru.tests.lemmy-ui = nixosTests.lemmy;
|
2021-10-29 02:07:48 +01:00
|
|
|
|
2021-10-03 06:51:06 +01:00
|
|
|
meta = with lib; {
|
|
|
|
description = "Building a federated alternative to reddit in rust";
|
|
|
|
homepage = "https://join-lemmy.org/";
|
|
|
|
license = licenses.agpl3Only;
|
|
|
|
maintainers = with maintainers; [ happysalada billewanick ];
|
2023-06-14 13:44:35 +01:00
|
|
|
inherit (nodejs.meta) platforms;
|
2021-09-09 15:28:32 +01:00
|
|
|
};
|
2021-10-03 06:51:06 +01:00
|
|
|
}
|