2022-06-17 20:03:34 +02:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, pkgs
|
|
|
|
, fetchFromGitHub
|
|
|
|
, nodejs
|
|
|
|
, cypress
|
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "polaris-web";
|
2022-11-06 22:29:25 +01:00
|
|
|
version = "build-55";
|
2022-06-17 20:03:34 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "agersant";
|
|
|
|
repo = "polaris-web";
|
|
|
|
rev = "${version}";
|
2022-11-06 22:29:25 +01:00
|
|
|
sha256 = "2XqU4sExF7Or7RxpOK2XU9APtBujfPhM/VkOLKVDvF4=";
|
2022-06-17 20:03:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
nodejs
|
|
|
|
];
|
|
|
|
|
|
|
|
buildPhase =
|
|
|
|
let
|
|
|
|
nodeDependencies = (import ./node-composition.nix {
|
|
|
|
inherit pkgs nodejs;
|
|
|
|
inherit (stdenv.hostPlatform) system;
|
|
|
|
}).nodeDependencies.override (old: {
|
|
|
|
# access to path '/nix/store/...-source' is forbidden in restricted mode
|
|
|
|
src = src;
|
|
|
|
dontNpmInstall = true;
|
|
|
|
|
|
|
|
# ERROR: .../.bin/node-gyp-build: /usr/bin/env: bad interpreter: No such file or directory
|
|
|
|
# https://github.com/svanderburg/node2nix/issues/275
|
|
|
|
# There are multiple instances of it, hence the globstar
|
|
|
|
preRebuild = ''
|
|
|
|
shopt -s globstar
|
|
|
|
sed -i -e "s|#!/usr/bin/env node|#! ${pkgs.nodejs}/bin/node|" \
|
|
|
|
node_modules/**/node-gyp-build/bin.js \
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildInputs = [ cypress ];
|
|
|
|
# prevent downloading cypress, use the executable in path instead
|
|
|
|
CYPRESS_INSTALL_BINARY = "0";
|
|
|
|
|
|
|
|
});
|
|
|
|
in
|
|
|
|
''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
export PATH="${nodeDependencies}/bin:${nodejs}/bin:$PATH"
|
|
|
|
|
2022-09-24 21:15:34 +02:00
|
|
|
# https://github.com/parcel-bundler/parcel/issues/8005
|
|
|
|
export NODE_OPTIONS=--no-experimental-fetch
|
|
|
|
|
2022-06-17 20:03:34 +02:00
|
|
|
ln -s ${nodeDependencies}/lib/node_modules .
|
|
|
|
npm run production
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p $out/share
|
|
|
|
cp -a dist $out/share/polaris-web
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru.updateScript = ./update-web.sh;
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Web client for Polaris";
|
|
|
|
homepage = "https://github.com/agersant/polaris-web";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ pbsds ];
|
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|