nixpkgs/pkgs/servers/web-apps/lemmy/ui.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

99 lines
2.1 KiB
Nix
Raw Normal View History

2021-09-09 16:28:32 +02:00
{ lib
, mkYarnPackage
, libsass
, nodejs
, python3
, pkg-config
, fetchFromGitHub
, fetchYarnDeps
, nixosTests
2023-06-26 21:05:06 +02:00
, vips
, nodePackages
2021-09-09 16:28:32 +02:00
}:
let
pinData = lib.importJSON ./pin.json;
2021-09-09 16:28:32 +02:00
pkgConfig = {
node-sass = {
nativeBuildInputs = [ pkg-config ];
buildInputs = [ libsass python3 ];
2021-09-09 16:28:32 +02:00
postInstall = ''
LIBSASS_EXT=auto yarn --offline run build
rm build/config.gypi
'';
};
2023-06-26 21:05:06 +02:00
sharp = {
2023-09-28 07:58:30 +02:00
nativeBuildInputs = [ pkg-config nodePackages.node-gyp nodePackages.semver ];
2023-06-26 21:05:06 +02:00
buildInputs = [ vips ];
postInstall = ''
yarn --offline run install
'';
};
2021-09-09 16:28:32 +02:00
};
name = "lemmy-ui";
version = pinData.uiVersion;
2021-09-09 16:28:32 +02:00
src = fetchFromGitHub {
owner = "LemmyNet";
repo = name;
rev = version;
fetchSubmodules = true;
hash = pinData.uiHash;
};
in
mkYarnPackage {
2021-09-09 16:28:32 +02:00
inherit src pkgConfig name version;
2021-09-09 16:28:32 +02:00
extraBuildInputs = [ libsass ];
2021-09-09 16:28:32 +02:00
packageJSON = ./package.json;
offlineCache = fetchYarnDeps {
yarnLock = src + "/yarn.lock";
hash = pinData.uiYarnDepsHash;
};
2021-09-09 16:28:32 +02:00
2023-08-27 13:27:40 +02:00
patchPhase = ''
substituteInPlace ./package.json \
--replace '$(git rev-parse --short HEAD)' "${src.rev}" \
--replace 'yarn clean' 'yarn --offline clean' \
--replace 'yarn run rimraf dist' 'yarn --offline run rimraf dist'
'';
yarnPreBuild = ''
export npm_config_nodedir=${nodejs}
'';
2021-09-09 16:28:32 +02:00
buildPhase = ''
# Yarn writes cache directories etc to $HOME.
export HOME=$PWD/yarn_home
2021-09-09 16:28:32 +02:00
ln -sf $PWD/node_modules $PWD/deps/lemmy-ui/
echo 'export const VERSION = "${version}";' > $PWD/deps/lemmy-ui/src/shared/version.ts
2021-09-09 16:28:32 +02:00
yarn --offline build:prod
'';
2021-09-09 16:28:32 +02:00
preInstall = ''
mkdir $out
cp -R ./deps/lemmy-ui/dist $out
cp -R ./node_modules $out
'';
2021-09-09 16:28:32 +02:00
distPhase = "true";
passthru.updateScript = ./update.py;
passthru.tests.lemmy-ui = nixosTests.lemmy;
2023-08-27 13:27:40 +02:00
passthru.commit_sha = src.rev;
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 adisbladis ];
inherit (nodejs.meta) platforms;
2021-09-09 16:28:32 +02:00
};
}