summary refs log tree commit diff
path: root/pkgs/development/web/nodejs
diff options
context:
space:
mode:
authoradisbladis <adis@blad.is>2018-02-18 22:19:01 +0800
committeradisbladis <adis@blad.is>2018-02-18 23:02:07 +0800
commit43cf893d44aede3ecb62399f5c28c0046a5148f4 (patch)
tree157a46ff18ec4c718ccc09abba00e3a3664c4818 /pkgs/development/web/nodejs
parente1bd5b33b66d95d4dac3800e283ecabff28dae86 (diff)
downloadnixpkgs-43cf893d44aede3ecb62399f5c28c0046a5148f4.tar
nixpkgs-43cf893d44aede3ecb62399f5c28c0046a5148f4.tar.gz
nixpkgs-43cf893d44aede3ecb62399f5c28c0046a5148f4.tar.bz2
nixpkgs-43cf893d44aede3ecb62399f5c28c0046a5148f4.tar.lz
nixpkgs-43cf893d44aede3ecb62399f5c28c0046a5148f4.tar.xz
nixpkgs-43cf893d44aede3ecb62399f5c28c0046a5148f4.tar.zst
nixpkgs-43cf893d44aede3ecb62399f5c28c0046a5148f4.zip
nodejs: Add updater script
Diffstat (limited to 'pkgs/development/web/nodejs')
-rw-r--r--pkgs/development/web/nodejs/nodejs.nix9
-rw-r--r--pkgs/development/web/nodejs/update.nix27
2 files changed, 36 insertions, 0 deletions
diff --git a/pkgs/development/web/nodejs/nodejs.nix b/pkgs/development/web/nodejs/nodejs.nix
index 8d8a253f01d..263de2ec96b 100644
--- a/pkgs/development/web/nodejs/nodejs.nix
+++ b/pkgs/development/web/nodejs/nodejs.nix
@@ -1,5 +1,8 @@
 { stdenv, fetchurl, openssl, python2, zlib, libuv, utillinux, http-parser
 , pkgconfig, which
+# Updater dependencies
+, writeScript, coreutils, gnugrep, jq, curl, common-updater-scripts, nix
+, gnupg
 , darwin ? null
 }:
 
@@ -78,6 +81,12 @@ in
       ''}
     '';
 
+    passthru.updateScript = import ./update.nix {
+      inherit writeScript coreutils gnugrep jq curl common-updater-scripts gnupg nix;
+      inherit (stdenv) lib;
+      majorVersion = with stdenv.lib; elemAt (splitString "." version) 0;
+    };
+
     meta = {
       description = "Event-driven I/O framework for the V8 JavaScript engine";
       homepage = https://nodejs.org;
diff --git a/pkgs/development/web/nodejs/update.nix b/pkgs/development/web/nodejs/update.nix
new file mode 100644
index 00000000000..9ff11982b65
--- /dev/null
+++ b/pkgs/development/web/nodejs/update.nix
@@ -0,0 +1,27 @@
+{ lib
+, writeScript
+, coreutils
+, curl
+, gnugrep
+, jq
+, gnupg
+, common-updater-scripts
+, majorVersion
+, nix
+}:
+
+writeScript "update-nodejs" ''
+  PATH=${lib.makeBinPath [ common-updater-scripts coreutils curl gnugrep jq gnupg nix ]}
+
+  HOME=`mktemp -d`
+  cat ${./nodejs-release-keys.asc} | gpg --import
+
+  tags=`curl --silent https://api.github.com/repos/nodejs/node/git/refs/tags`
+  version=`echo $tags | jq -r '.[] | select(.ref | startswith("refs/tags/v${majorVersion}")) | .ref' | sort --version-sort  | tail -1 | grep -oP "^refs/tags/v\K.*"`
+
+  curl --silent -o $HOME/SHASUMS256.txt.asc https://nodejs.org/dist/v''${version}/SHASUMS256.txt.asc
+  hash_hex=`gpgv --keyring=$HOME/.gnupg/pubring.kbx --output - $HOME/SHASUMS256.txt.asc | grep -oP "^([0-9a-f]{64})(?=\s+node-v''${version}.tar.xz$)"`
+  hash=`nix-hash --type sha256 --to-base32 ''${hash_hex}`
+
+  update-source-version nodejs-${majorVersion}_x "''${version}" "''${hash}"
+''