-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge #538: rtl: 0.12.3 -> 0.13.0, clightning-rest: 0.7.2 -> 0.8.0
53dd2a1 cl-rest: 0.7.2 -> 0.8.0 (Erik Arvstedt) 617ed4c rtl: 0.12.3-beta -> 0.13.0 (Erik Arvstedt) e63dafe pkgs: add `fetch-node-modules` (Erik Arvstedt) Pull request description: ACKs for top commit: jonasnick: ACK 53dd2a1 Tree-SHA512: aa4854b48d0186887a2db42b1f5e8fb27dc7da4ba6def50ee0a33d76ceb5425f593fb0c159e81809b67dda441559262872a331476136195c8033db94cc302026
- Loading branch information
Showing
13 changed files
with
276 additions
and
5,769 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
set -euo pipefail | ||
|
||
# The file that defines the derivation that should be updated | ||
file=$1 | ||
# The name of the output of this flake that should be updated | ||
flakeOutput=$2 | ||
# A pattern in a line preceding the hash that should be updated | ||
patternPrecedingHash=$3 | ||
|
||
sed -i "/$patternPrecedingHash/,/hash/ s|hash = .*|hash = \"\";|" $file | ||
# Display stderr and capture it. stdbuf is required to disable output buffering. | ||
stderr=$( | ||
nix build --no-link -L .#$flakeOutput |& | ||
stdbuf -oL grep -v '\berror:.*failed to build$' | | ||
tee /dev/stderr || : | ||
) | ||
hash=$(echo "$stderr" | sed -nE 's/.*?\bgot: *?(sha256-.*)/\1/p') | ||
if [[ ! $hash ]]; then | ||
echo | ||
echo "Error: No hash in build output." | ||
exit 1 | ||
fi | ||
sed -i "/$patternPrecedingHash/,/hash/ s|hash = .*|hash = \"$hash\";|" $file | ||
echo "(Note: The above hash mismatch message is not an error. It is part of the fetching process.)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# This is a modified version of | ||
# https://github.com/NixOS/nixpkgs/pull/128749 | ||
|
||
{ lib, stdenvNoCC, makeWrapper, nodejs }: | ||
|
||
{ src | ||
, hash ? "" | ||
, runScripts ? false | ||
, preferLocalBuild ? true | ||
, npmFlags ? "" | ||
, ... | ||
} @ args: | ||
stdenvNoCC.mkDerivation ({ | ||
inherit src preferLocalBuild; | ||
|
||
name = "${src.name}-node_modules"; | ||
nativeBuildInputs = [ | ||
makeWrapper | ||
(if args ? nodejs then args.nodejs else nodejs) | ||
]; | ||
|
||
outputHashMode = "recursive"; | ||
|
||
impureEnvVars = lib.fetchers.proxyImpureEnvVars; | ||
|
||
phases = "unpackPhase patchPhase buildPhase installPhase"; | ||
|
||
buildPhase = '' | ||
runHook preBuild | ||
if [[ ! -f package.json ]]; then | ||
echo "Error: file `package.json` doesn't exist" | ||
exit 1 | ||
fi | ||
if [[ ! -f package-lock.json ]]; then | ||
echo "Error: file `package-lock.json` doesn't exist" | ||
exit 1 | ||
fi | ||
export SOURCE_DATE_EPOCH=1 | ||
export npm_config_cache=/tmp | ||
NPM_FLAGS="--omit=dev --omit=optional --no-update-notifier $npmFlags" | ||
# Scripts may result in non-deterministic behavior. | ||
# Some packages (e.g., Puppeteer) use postinstall scripts to download extra data. | ||
if [[ ! $runScripts ]]; then | ||
NPM_FLAGS+=" --ignore-scripts" | ||
fi | ||
echo "Running npm ci $NPM_FLAGS" | ||
npm ci $NPM_FLAGS | ||
cp package.json \ | ||
package-lock.json node_modules/ | ||
rm -f node_modules/.package-lock.json | ||
runHook postBuild | ||
''; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
mkdir -p $out/lib | ||
cp -r node_modules $out/lib | ||
runHook postInstall | ||
''; | ||
} // ( | ||
if hash == "" then { | ||
outputHashAlgo = "sha256"; | ||
outputHash = ""; | ||
} else { | ||
outputHash = hash; | ||
} | ||
) // (builtins.removeAttrs args [ "hash" ])) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,40 @@ | ||
#!/usr/bin/env nix-shell | ||
#! nix-shell -i bash -p nodePackages.node2nix gnupg wget jq gnused | ||
#! nix-shell -i bash -p gnupg wget gnused | ||
set -euo pipefail | ||
|
||
TMPDIR="$(mktemp -d -p /tmp)" | ||
trap "rm -rf $TMPDIR" EXIT | ||
|
||
version="0.7.2" | ||
version="0.8.0" | ||
repo=https://github.com/Ride-The-Lightning/c-lightning-REST | ||
|
||
# Fetch and verify source tarball | ||
file=v${version}.tar.gz | ||
url=$repo/archive/refs/tags/$file | ||
export GNUPGHOME=$TMPDIR | ||
gpg --keyserver hkps://keyserver.ubuntu.com --recv-key 3E9BD4436C288039CA827A9200C9E2BC2E45666F | ||
wget -P $TMPDIR $url | ||
wget -P $TMPDIR $repo/releases/download/v${version}/$file.asc | ||
gpg --verify $TMPDIR/$file.asc $TMPDIR/$file | ||
hash=$(nix hash file $TMPDIR/$file) | ||
scriptDir=$(cd "${BASH_SOURCE[0]%/*}" && pwd) | ||
|
||
updateSrc() { | ||
TMPDIR="$(mktemp -d /tmp/clightning-rest.XXX)" | ||
trap "rm -rf $TMPDIR" EXIT | ||
|
||
# Extract source | ||
src=$TMPDIR/src | ||
mkdir $src | ||
tar xvf $TMPDIR/$file -C $src --strip-components 1 >/dev/null | ||
# Fetch and verify source tarball | ||
export GNUPGHOME=$TMPDIR | ||
# Fetch saubyk's key | ||
gpg --keyserver hkps://keyserver.ubuntu.com --recv-key 3E9BD4436C288039CA827A9200C9E2BC2E45666F | ||
file=v${version}.tar.gz | ||
wget -P $TMPDIR $repo/archive/refs/tags/$file | ||
wget -P $TMPDIR $repo/releases/download/v${version}/$file.asc | ||
gpg --verify $TMPDIR/$file.asc $TMPDIR/$file | ||
hash=$(nix hash file $TMPDIR/$file) | ||
|
||
# Generate nix pkg | ||
node2nix \ | ||
--input $src/package.json \ | ||
--lock $src/package-lock.json \ | ||
--composition composition.nix \ | ||
--no-copy-node-env | ||
sed -i " | ||
s|\bversion = .*;|version = \"$version\";| | ||
s|\bhash = .*;|hash = \"$hash\";| | ||
" default.nix | ||
} | ||
|
||
# Use node-env.nix from nixpkgs | ||
nodeEnvImport='import "${toString pkgs.path}/pkgs/development/node-packages/node-env.nix"' | ||
sed -i "s|import ./node-env.nix|$nodeEnvImport|" composition.nix | ||
updateNodeModulesHash() { | ||
$scriptDir/../../helper/update-fixed-output-derivation.sh ./default.nix clightning-rest.nodeModules nodeModules | ||
} | ||
|
||
# Use the verified package src | ||
read -d '' fetchurl <<EOF || : | ||
fetchurl { | ||
url = "$url"; | ||
hash = "$hash"; | ||
}; | ||
EOF | ||
sed -i "s|src = .*/src;|src = ${fetchurl//$'\n'/\\n}|" node-packages.nix | ||
if [[ $# == 0 ]]; then | ||
# Each of these can be run separately | ||
updateSrc | ||
updateNodeModulesHash | ||
else | ||
eval "$@" | ||
fi |
Oops, something went wrong.