infrastructure/machines/nixos/web01/crabfit/packages/crabfit-frontend/default.nix
Tom Hubrecht ecbad0a638
All checks were successful
Check workflows / check_workflows (push) Successful in 21s
Run pre-commit on all files / check (push) Successful in 24s
Check meta / check_dns (pull_request) Successful in 19s
Check meta / check_meta (pull_request) Successful in 18s
Check workflows / check_workflows (pull_request) Successful in 19s
Build all the nodes / bridge01 (pull_request) Successful in 1m13s
Build all the nodes / geo01 (pull_request) Successful in 1m14s
Build all the nodes / compute01 (pull_request) Successful in 1m44s
Build all the nodes / geo02 (pull_request) Successful in 1m12s
Build all the nodes / rescue01 (pull_request) Successful in 1m30s
Build all the nodes / storage01 (pull_request) Successful in 1m29s
Build all the nodes / vault01 (pull_request) Successful in 1m26s
Build all the nodes / web02 (pull_request) Successful in 1m19s
Run pre-commit on all files / check (pull_request) Successful in 24s
Build all the nodes / web01 (pull_request) Successful in 1m56s
Build all the nodes / web03 (pull_request) Successful in 1m25s
chore: Abstract machines and modules
This adds subdirectories for the different types of systems, for the
modules and the machines
2024-12-08 13:39:10 +01:00

113 lines
2.7 KiB
Nix

{
lib,
stdenv,
fetchFromGitHub,
fetchYarnDeps,
nodejs,
yarn,
fixup_yarn_lock,
google-fonts,
api_url ? "http://127.0.0.1:3000",
frontend_url ? "crab.fit",
}:
stdenv.mkDerivation (finalAttrs: {
pname = "crabfit-frontend";
version = "unstable-2023-08-02";
src = fetchFromGitHub {
owner = "GRA0007";
repo = "crab.fit";
rev = "628f9eefc300bf1ed3d6cc3323332c2ed9b8a350";
hash = "sha256-jy8BrJSHukRenPbZHw4nPx3cSi7E2GSg//WOXDh90mY=";
};
sourceRoot = "source/frontend";
patches = [
./01-privacy.patch
./02-karla.patch
./03-standalone.patch
./04-frontend_url.patch
./05-dgnum.patch
./06-download.patch
./07-colormap.patch
];
offlineCache = fetchYarnDeps {
yarnLock = "${finalAttrs.src}/frontend/yarn.lock";
hash = "sha256-jkyQygwHdLlEZ1tlSQOh72nANp2F29rZbTXvKQStvGc=";
};
nativeBuildInputs = [
nodejs
yarn
fixup_yarn_lock
];
postPatch = ''
substituteInPlace \
public/robots.txt \
public/sitemap.xml \
src/app/\[id\]/page.tsx \
src/app/layout.tsx \
src/components/CreateForm/components/EventInfo/EventInfo.tsx \
src/i18n/locales/de/help.json \
src/i18n/locales/en-GB/help.json \
src/i18n/locales/en/help.json \
src/i18n/locales/es/help.json \
src/i18n/locales/fr/help.json \
src/i18n/locales/hi/help.json \
src/i18n/locales/id/help.json \
src/i18n/locales/it/help.json \
src/i18n/locales/ko/help.json \
src/i18n/locales/pt-BR/help.json \
src/i18n/locales/pt-PT/help.json \
src/i18n/locales/ru/help.json \
--replace "@FRONTEND_URL@" "${frontend_url}"
'';
configurePhase = ''
runHook preConfigure
export HOME="$PWD"
echo 'NEXT_PUBLIC_API_URL="${api_url}"' > .env.local
fixup_yarn_lock yarn.lock
yarn config --offline set yarn-offline-mirror ${finalAttrs.offlineCache}
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
patchShebangs node_modules
mkdir -p src/app/fonts
cp "${
google-fonts.override { fonts = [ "Karla" ]; }
}/share/fonts/truetype/Karla[wght].ttf" src/app/fonts/karla.ttf
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
NODE_ENV=production yarn build
runHook postBuild
'';
installPhase = ''
mkdir $out
cp -R .next/* $out
cp -R public $out/standalone/
cp -R .next/static $out/standalone/.next
ln -s /var/cache/crabfit $out/standalone/.next/cache
'';
meta = with lib; {
description = "Enter your availability to find a time that works for everyone";
homepage = "https://github.com/GRA0007/crab.fit";
license = licenses.gpl3;
maintainers = with maintainers; [ thubrecht ];
};
})