about summary refs log tree commit diff
path: root/pkgs/by-name/po/postlight-parser/package.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/po/postlight-parser/package.nix')
-rw-r--r--pkgs/by-name/po/postlight-parser/package.nix43
1 files changed, 30 insertions, 13 deletions
diff --git a/pkgs/by-name/po/postlight-parser/package.nix b/pkgs/by-name/po/postlight-parser/package.nix
index c00028b9a4016..fd0617ede1f2e 100644
--- a/pkgs/by-name/po/postlight-parser/package.nix
+++ b/pkgs/by-name/po/postlight-parser/package.nix
@@ -1,36 +1,53 @@
 { lib
 , stdenv
-, mkYarnPackage
 , fetchFromGitHub
 , fetchYarnDeps
+, yarnConfigHook
+, yarnBuildHook
+, nodejs
+, npmHooks
 }:
 
-mkYarnPackage rec {
+stdenv.mkDerivation (finalAttrs: {
   pname = "postlight-parser";
   version = "2.2.3";
 
   src = fetchFromGitHub {
     owner = "postlight";
     repo = "parser";
-    rev = "v${version}";
+    rev = "v${finalAttrs.version}";
     hash = "sha256-k6m95FHeJ+iiWSeY++1zds/bo1RtNXbnv2spaY/M+L0=";
   };
 
-  packageJSON = ./package.json;
-
-  doDist = false;
-
   offlineCache = fetchYarnDeps {
-    yarnLock = "${src}/yarn.lock";
+    yarnLock = "${finalAttrs.src}/yarn.lock";
     hash = "sha256-Vs8bfkhEbPv33ew//HBeDnpQcyWveByHi1gUsdl2CNI=";
   };
 
-  meta = with lib; {
-    changelog = "https://github.com/postlight/parser/blob/${src.rev}/CHANGELOG.md";
+  nativeBuildInputs = [
+    yarnConfigHook
+    yarnBuildHook
+    nodejs
+    npmHooks.npmInstallHook
+  ];
+  # Upstream doesn't include a script in package.json that only builds without
+  # testing, and tests fail because they need to access online websites. Hence
+  # we use the builtin interface of yarnBuildHook to lint, and in `postBuild`
+  # we run the rest of commands needed to create the js files eventually
+  # distributed and wrapped by npmHooks.npmInstallHook
+  yarnBuildScript = "lint";
+  postBuild = ''
+    yarn --offline run rollup -c
+  '';
+  # Tries to download stuff from the internet in this phase.
+  dontNpmPrune = true;
+
+  meta = {
+    changelog = "https://github.com/postlight/parser/blob/${finalAttrs.src.rev}/CHANGELOG.md";
     homepage = "https://reader.postlight.com";
     description = "Extracts the bits that humans care about from any URL you give it";
-    license = licenses.mit;
-    maintainers = with maintainers; [ viraptor ];
+    license = lib.licenses.mit;
+    maintainers = with lib.maintainers; [ viraptor ];
     mainProgram = "postlight-parser";
   };
-}
+})