Commit 025b63b1 authored by Robert Schütz's avatar Robert Schütz
Browse files

polaris-web: use buildNpmPackage

parent cea0b673
Loading
Loading
Loading
Loading
+0 −17
Original line number Diff line number Diff line
# This file has been generated by node2nix 1.11.1. Do not edit!

{pkgs ? import <nixpkgs> {
    inherit system;
  }, system ? builtins.currentSystem, nodejs ? pkgs."nodejs_12"}:

let
  nodeEnv = import ../../development/node-packages/node-env.nix {
    inherit (pkgs) stdenv lib python2 runCommand writeTextFile writeShellScript;
    inherit pkgs nodejs;
    libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
  };
in
import ./node-packages.nix {
  inherit (pkgs) fetchurl nix-gitignore stdenv lib fetchgit;
  inherit nodeEnv;
}
+0 −4301

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −31
Original line number Diff line number Diff line
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p common-updater-scripts nodePackages.node2nix curl jq gnused nix coreutils

set -euo pipefail

pushd .
cd "$(dirname "${BASH_SOURCE[0]}")"/../../..

latestVersion="$(curl -s "https://api.github.com/repos/agersant/polaris-web/releases?per_page=1" | jq -r ".[0].tag_name")"
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; polaris-web.version or (lib.getVersion polaris-web)" | tr -d '"')

if [[ "$currentVersion" == "$latestVersion" ]]; then
  echo "polaris-web is up-to-date: $currentVersion"
  exit 0
fi

update-source-version polaris-web "$latestVersion"

store_src="$(nix-build . -A polaris-web.src --no-out-link)"

popd
cd "$(dirname "${BASH_SOURCE[0]}")"

node2nix \
  --nodejs-12 \
  --development \
  --node-env ../../development/node-packages/node-env.nix \
  --input "$store_src"/package.json \
  --lock "$store_src"/package-lock.json \
  --output ./node-packages.nix \
  --composition ./node-composition.nix
+12 −46
Original line number Diff line number Diff line
{ lib
, stdenv
, pkgs
, buildNpmPackage
, fetchFromGitHub
, nodejs
, cypress
, nodePackages
, python3
}:

stdenv.mkDerivation rec {
buildNpmPackage rec {
  pname = "polaris-web";
  version = "build-55";

@@ -17,49 +16,19 @@ stdenv.mkDerivation rec {
    sha256 = "2XqU4sExF7Or7RxpOK2XU9APtBujfPhM/VkOLKVDvF4=";
  };

  npmDepsHash = "sha256-sSd1WSS9xsaVr9mCQueAuqceOv5SkSzqsxX9kHYC8Xo=";

  nativeBuildInputs = [
    nodejs
    nodePackages.node-gyp-build
    python3
  ];

  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"
  env.CYPRESS_INSTALL_BINARY = "0";

  # https://github.com/parcel-bundler/parcel/issues/8005
      export NODE_OPTIONS=--no-experimental-fetch

      ln -s ${nodeDependencies}/lib/node_modules .
      npm run production

      runHook postBuild
    '';
  env.NODE_OPTIONS = "--no-experimental-fetch";

  npmBuildScript = "production";

  installPhase = ''
    runHook preInstall
@@ -70,13 +39,10 @@ stdenv.mkDerivation rec {
    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;
  };
}