2022-09-23 00:10:40 +02:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitea, fetchYarnDeps
|
2024-04-17 19:34:05 +02:00
|
|
|
, fixup-yarn-lock, yarn, nodejs
|
2022-09-23 00:10:40 +02:00
|
|
|
, jpegoptim, oxipng, nodePackages
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2023-02-12 22:56:39 +01:00
|
|
|
pname = "akkoma-fe";
|
2024-02-26 12:44:16 +01:00
|
|
|
version = "3.11.0";
|
2022-09-23 00:10:40 +02:00
|
|
|
|
|
|
|
src = fetchFromGitea {
|
|
|
|
domain = "akkoma.dev";
|
|
|
|
owner = "AkkomaGang";
|
2023-02-12 22:53:41 +01:00
|
|
|
repo = "akkoma-fe";
|
2024-04-27 22:37:31 +02:00
|
|
|
rev = "v${version}";
|
2024-02-26 12:44:16 +01:00
|
|
|
hash = "sha256-Z7psmIyOo8Rvwcip90JgxLhZ5SkkGB94QInEgm8UOjQ=";
|
2022-09-23 00:10:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
offlineCache = fetchYarnDeps {
|
|
|
|
yarnLock = src + "/yarn.lock";
|
2023-02-12 22:53:41 +01:00
|
|
|
hash = "sha256-Uet3zdjLdI4qpiuU4CtW2WwWGcFaOhotLLKfnsAUqho=";
|
2022-09-23 00:10:40 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
2024-04-17 19:34:05 +02:00
|
|
|
fixup-yarn-lock
|
2022-09-23 00:10:40 +02:00
|
|
|
yarn
|
|
|
|
nodejs
|
|
|
|
jpegoptim
|
|
|
|
oxipng
|
|
|
|
nodePackages.svgo
|
|
|
|
];
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
# Build scripts assume to be used within a Git repository checkout
|
|
|
|
sed -E -i '/^let commitHash =/,/;$/clet commitHash = "${builtins.substring 0 7 src.rev}";' \
|
|
|
|
build/webpack.prod.conf.js
|
|
|
|
'';
|
|
|
|
|
|
|
|
configurePhase = ''
|
|
|
|
runHook preConfigure
|
|
|
|
|
|
|
|
export HOME="$(mktemp -d)"
|
|
|
|
|
|
|
|
yarn config --offline set yarn-offline-mirror ${lib.escapeShellArg offlineCache}
|
2023-08-18 14:36:28 +02:00
|
|
|
fixup-yarn-lock yarn.lock
|
2022-09-23 00:10:40 +02:00
|
|
|
|
|
|
|
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
|
|
|
|
|
|
|
|
runHook postConfigure
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
export NODE_ENV="production"
|
|
|
|
export NODE_OPTIONS="--openssl-legacy-provider"
|
|
|
|
yarn run build --offline
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
# (Losslessly) optimise compression of image artifacts
|
|
|
|
find dist -type f -name '*.jpg' -execdir ${jpegoptim}/bin/jpegoptim -w$NIX_BUILD_CORES {} \;
|
|
|
|
find dist -type f -name '*.png' -execdir ${oxipng}/bin/oxipng -o max -t $NIX_BUILD_CORES {} \;
|
|
|
|
find dist -type f -name '*.svg' -execdir ${nodePackages.svgo}/bin/svgo {} \;
|
|
|
|
|
|
|
|
cp -R -v dist $out
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
2023-02-12 22:56:39 +01:00
|
|
|
description = "Frontend for Akkoma";
|
|
|
|
homepage = "https://akkoma.dev/AkkomaGang/akkoma-fe/";
|
2024-03-19 13:26:06 +01:00
|
|
|
license = licenses.agpl3Only;
|
2022-09-23 00:10:40 +02:00
|
|
|
maintainers = with maintainers; [ mvs ];
|
|
|
|
};
|
|
|
|
}
|