2021-09-18 10:52:07 +00:00
|
|
|
{ lib
|
|
|
|
, mkYarnPackage
|
|
|
|
, libsass
|
|
|
|
, nodejs
|
|
|
|
, python3
|
|
|
|
, pkg-config
|
|
|
|
, fetchFromGitHub
|
2021-12-06 16:07:01 +00:00
|
|
|
, fetchYarnDeps
|
2022-09-09 14:08:57 +00:00
|
|
|
, nixosTests
|
2021-09-18 10:52:07 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2021-12-06 16:07:01 +00:00
|
|
|
pinData = lib.importJSON ./pin.json;
|
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
pkgConfig = {
|
|
|
|
node-sass = {
|
|
|
|
nativeBuildInputs = [ ];
|
|
|
|
buildInputs = [ libsass pkg-config python3 ];
|
|
|
|
postInstall = ''
|
|
|
|
LIBSASS_EXT=auto yarn --offline run build
|
|
|
|
rm build/config.gypi
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
name = "lemmy-ui";
|
2021-12-06 16:07:01 +00:00
|
|
|
version = pinData.version;
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2021-10-04 12:37:57 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "LemmyNet";
|
|
|
|
repo = name;
|
|
|
|
rev = version;
|
|
|
|
fetchSubmodules = true;
|
2021-12-06 16:07:01 +00:00
|
|
|
sha256 = pinData.uiSha256;
|
2021-10-04 12:37:57 +00:00
|
|
|
};
|
2021-12-06 16:07:01 +00:00
|
|
|
in
|
|
|
|
mkYarnPackage {
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
inherit src pkgConfig name version;
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2021-10-04 12:37:57 +00:00
|
|
|
extraBuildInputs = [ libsass ];
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2021-10-04 12:37:57 +00:00
|
|
|
packageJSON = ./package.json;
|
2021-12-06 16:07:01 +00:00
|
|
|
offlineCache = fetchYarnDeps {
|
|
|
|
yarnLock = src + "/yarn.lock";
|
|
|
|
sha256 = pinData.uiYarnDepsSha256;
|
|
|
|
};
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2021-10-04 12:37:57 +00:00
|
|
|
yarnPreBuild = ''
|
|
|
|
export npm_config_nodedir=${nodejs}
|
|
|
|
'';
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2021-10-04 12:37:57 +00:00
|
|
|
buildPhase = ''
|
|
|
|
# Yarn writes cache directories etc to $HOME.
|
|
|
|
export HOME=$PWD/yarn_home
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2021-10-04 12:37:57 +00:00
|
|
|
ln -sf $PWD/node_modules $PWD/deps/lemmy-ui/
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2021-10-04 12:37:57 +00:00
|
|
|
yarn --offline build:prod
|
|
|
|
'';
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2021-10-04 12:37:57 +00:00
|
|
|
preInstall = ''
|
|
|
|
mkdir $out
|
2021-10-06 13:57:05 +00:00
|
|
|
cp -R ./deps/lemmy-ui/dist $out
|
|
|
|
cp -R ./node_modules $out
|
2021-10-04 12:37:57 +00:00
|
|
|
'';
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2021-10-04 12:37:57 +00:00
|
|
|
distPhase = "true";
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
passthru.updateScript = ./update.sh;
|
2022-09-09 14:08:57 +00:00
|
|
|
passthru.tests.lemmy-ui = nixosTests.lemmy;
|
2021-12-06 16:07:01 +00:00
|
|
|
|
2021-10-04 12:37:57 +00: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 ];
|
|
|
|
platforms = platforms.linux;
|
2021-09-18 10:52:07 +00:00
|
|
|
};
|
2021-10-04 12:37:57 +00:00
|
|
|
}
|