-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: phanirithvij <[email protected]>
- Loading branch information
1 parent
8aed22e
commit 3684728
Showing
3 changed files
with
150 additions
and
18 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
@ ["packages","","devDependencies","esbuild"] | ||
+ "^0.18.20" | ||
@ ["packages","node_modules/@esbuild/android-arm"] | ||
+ {"cpu":["arm"],"dev":true,"engines":{"node":"\u003e=12"},"integrity":"sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw==","license":"MIT","optional":true,"os":["android"],"resolved":"https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.18.20.tgz","version":"0.18.20"} | ||
@ ["packages","node_modules/@esbuild/android-arm64"] | ||
+ {"cpu":["arm64"],"dev":true,"engines":{"node":"\u003e=12"},"integrity":"sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==","license":"MIT","optional":true,"os":["android"],"resolved":"https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.18.20.tgz","version":"0.18.20"} | ||
@ ["packages","node_modules/@esbuild/android-x64"] | ||
+ {"cpu":["x64"],"dev":true,"engines":{"node":"\u003e=12"},"integrity":"sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg==","license":"MIT","optional":true,"os":["android"],"resolved":"https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.18.20.tgz","version":"0.18.20"} | ||
@ ["packages","node_modules/@esbuild/darwin-arm64"] | ||
+ {"cpu":["arm64"],"dev":true,"engines":{"node":"\u003e=12"},"integrity":"sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA==","license":"MIT","optional":true,"os":["darwin"],"resolved":"https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.18.20.tgz","version":"0.18.20"} | ||
@ ["packages","node_modules/@esbuild/darwin-x64"] | ||
+ {"cpu":["x64"],"dev":true,"engines":{"node":"\u003e=12"},"integrity":"sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ==","license":"MIT","optional":true,"os":["darwin"],"resolved":"https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.18.20.tgz","version":"0.18.20"} | ||
@ ["packages","node_modules/@esbuild/freebsd-arm64"] | ||
+ {"cpu":["arm64"],"dev":true,"engines":{"node":"\u003e=12"},"integrity":"sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw==","license":"MIT","optional":true,"os":["freebsd"],"resolved":"https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.18.20.tgz","version":"0.18.20"} | ||
@ ["packages","node_modules/@esbuild/freebsd-x64"] | ||
+ {"cpu":["x64"],"dev":true,"engines":{"node":"\u003e=12"},"integrity":"sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ==","license":"MIT","optional":true,"os":["freebsd"],"resolved":"https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.18.20.tgz","version":"0.18.20"} | ||
@ ["packages","node_modules/@esbuild/linux-arm"] | ||
+ {"cpu":["arm"],"dev":true,"engines":{"node":"\u003e=12"},"integrity":"sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg==","license":"MIT","optional":true,"os":["linux"],"resolved":"https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.18.20.tgz","version":"0.18.20"} | ||
@ ["packages","node_modules/@esbuild/linux-arm64"] | ||
+ {"cpu":["arm64"],"dev":true,"engines":{"node":"\u003e=12"},"integrity":"sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA==","license":"MIT","optional":true,"os":["linux"],"resolved":"https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.18.20.tgz","version":"0.18.20"} | ||
@ ["packages","node_modules/@esbuild/linux-ia32"] | ||
+ {"cpu":["ia32"],"dev":true,"engines":{"node":"\u003e=12"},"integrity":"sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA==","license":"MIT","optional":true,"os":["linux"],"resolved":"https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.18.20.tgz","version":"0.18.20"} | ||
@ ["packages","node_modules/@esbuild/linux-loong64"] | ||
+ {"cpu":["loong64"],"dev":true,"engines":{"node":"\u003e=12"},"integrity":"sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg==","license":"MIT","optional":true,"os":["linux"],"resolved":"https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.18.20.tgz","version":"0.18.20"} | ||
@ ["packages","node_modules/@esbuild/linux-mips64el"] | ||
+ {"cpu":["mips64el"],"dev":true,"engines":{"node":"\u003e=12"},"integrity":"sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ==","license":"MIT","optional":true,"os":["linux"],"resolved":"https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.18.20.tgz","version":"0.18.20"} | ||
@ ["packages","node_modules/@esbuild/linux-ppc64"] | ||
+ {"cpu":["ppc64"],"dev":true,"engines":{"node":"\u003e=12"},"integrity":"sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA==","license":"MIT","optional":true,"os":["linux"],"resolved":"https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.18.20.tgz","version":"0.18.20"} | ||
@ ["packages","node_modules/@esbuild/linux-riscv64"] | ||
+ {"cpu":["riscv64"],"dev":true,"engines":{"node":"\u003e=12"},"integrity":"sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A==","license":"MIT","optional":true,"os":["linux"],"resolved":"https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.18.20.tgz","version":"0.18.20"} | ||
@ ["packages","node_modules/@esbuild/linux-s390x"] | ||
+ {"cpu":["s390x"],"dev":true,"engines":{"node":"\u003e=12"},"integrity":"sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ==","license":"MIT","optional":true,"os":["linux"],"resolved":"https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.18.20.tgz","version":"0.18.20"} | ||
@ ["packages","node_modules/@esbuild/netbsd-x64"] | ||
+ {"cpu":["x64"],"dev":true,"engines":{"node":"\u003e=12"},"integrity":"sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A==","license":"MIT","optional":true,"os":["netbsd"],"resolved":"https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.18.20.tgz","version":"0.18.20"} | ||
@ ["packages","node_modules/@esbuild/openbsd-x64"] | ||
+ {"cpu":["x64"],"dev":true,"engines":{"node":"\u003e=12"},"integrity":"sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg==","license":"MIT","optional":true,"os":["openbsd"],"resolved":"https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.18.20.tgz","version":"0.18.20"} | ||
@ ["packages","node_modules/@esbuild/sunos-x64"] | ||
+ {"cpu":["x64"],"dev":true,"engines":{"node":"\u003e=12"},"integrity":"sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ==","license":"MIT","optional":true,"os":["sunos"],"resolved":"https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.18.20.tgz","version":"0.18.20"} | ||
@ ["packages","node_modules/@esbuild/win32-arm64"] | ||
+ {"cpu":["arm64"],"dev":true,"engines":{"node":"\u003e=12"},"integrity":"sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg==","license":"MIT","optional":true,"os":["win32"],"resolved":"https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.18.20.tgz","version":"0.18.20"} | ||
@ ["packages","node_modules/@esbuild/win32-ia32"] | ||
+ {"cpu":["ia32"],"dev":true,"engines":{"node":"\u003e=12"},"integrity":"sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g==","license":"MIT","optional":true,"os":["win32"],"resolved":"https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.18.20.tgz","version":"0.18.20"} | ||
@ ["packages","node_modules/@esbuild/win32-x64"] | ||
+ {"cpu":["x64"],"dev":true,"engines":{"node":"\u003e=12"},"integrity":"sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ==","license":"MIT","optional":true,"os":["win32"],"resolved":"https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.18.20.tgz","version":"0.18.20"} |
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 |
---|---|---|
|
@@ -4,38 +4,37 @@ | |
buildNpmPackage, | ||
fetchFromGitHub, | ||
moreutils, | ||
npm-lockfile-fix, | ||
jd-diff-patch, | ||
jq, | ||
git, | ||
}: | ||
let | ||
# finalAttrs when 🥺 (buildGoModule does not support them) | ||
# https://github.com/NixOS/nixpkgs/issues/273815 | ||
version = "1.7.5"; | ||
version = "1.8.1"; | ||
src = fetchFromGitHub { | ||
owner = "thomiceli"; | ||
repo = "opengist"; | ||
rev = "v${version}"; | ||
hash = "sha256-mZ4j9UWdKa3nygcRO5ceyONetkks3ZGWxvzD34eOXew="; | ||
|
||
# follow https://github.com/thomiceli/opengist/pull/350 and remove here | ||
postFetch = '' | ||
${lib.getExe npm-lockfile-fix} $out/package-lock.json | ||
''; | ||
hash = "sha256-rUE4E5moMujVeN/2obp1LlvyKOPGyP6de1xI/2GdAUc="; | ||
}; | ||
jd' = lib.getExe jd-diff-patch; | ||
jq' = lib.getExe jq; | ||
sponge = "${moreutils}/bin/sponge"; | ||
|
||
frontend = buildNpmPackage { | ||
pname = "opengist-frontend"; | ||
inherit version src; | ||
|
||
nativeBuildInputs = [ | ||
moreutils | ||
jq | ||
]; | ||
|
||
# npm complains of "invalid package". shrug. we can give it a version. | ||
preBuild = '' | ||
jq '.version = "${version}"' package.json | sponge package.json | ||
# esbuild optional dependencies installed explicitly | ||
# as they are missing for non-x86_64-linux in package-lock.json | ||
# nix shell nixpkgs#{nodejs,jd-diff-patch} -c \ | ||
# sh -c "npm add -D [email protected]; git difftool -yx jd @ -- package-lock.json > package-lock-esbuild.jd.diff" | ||
prePatch = '' | ||
${jq'} '.version = "${version}"' package.json | ${sponge} package.json | ||
${jd'} -o package-lock.json -p ${./package-lock-esbuild.jd.diff} package-lock.json || true | ||
${jq'} -S . package-lock.json | ${sponge} package-lock.json | ||
''; | ||
|
||
# copy pasta from the Makefile upstream, seems to be a workaround of sass | ||
|
@@ -50,13 +49,13 @@ let | |
cp -R public $out | ||
''; | ||
|
||
npmDepsHash = "sha256-cITkgRvWOml6uH77WkiNgFedEuPNze63Gntet09uS5w="; | ||
npmDepsHash = "sha256-uRocJqRsVqmmndqIJ4MqBussnpfh3bpkYVYxFv38Kpw="; | ||
}; | ||
in | ||
buildGoModule { | ||
pname = "opengist"; | ||
inherit version src; | ||
vendorHash = "sha256-6PpS/dsonc/akBn8NwUIVFNe2FjynAhF1TYIYT9K/ws="; | ||
vendorHash = "sha256-B8h+/pUMDzLew0+r2/nTHDcm3Y7Bnwj9R3FzHts6i+k="; | ||
tags = [ "fs_embed" ]; | ||
ldflags = [ | ||
"-s" | ||
|
@@ -73,11 +72,20 @@ buildGoModule { | |
export OG_OPENGIST_HOME=$(mktemp -d) | ||
''; | ||
|
||
checkPhase = '' | ||
runHook preCheck | ||
make test | ||
runHook postCheck | ||
''; | ||
|
||
postPatch = '' | ||
cp -R ${frontend}/public/{manifest.json,assets} public/ | ||
''; | ||
|
||
passthru.frontend = frontend; | ||
passthru = { | ||
inherit frontend; | ||
updateScript = ./update.sh; | ||
}; | ||
|
||
meta = { | ||
description = "Self-hosted pastebin powered by Git"; | ||
|
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,80 @@ | ||
#!/usr/bin/env nix-shell | ||
#!nix-shell -i bash -p bash curl coreutils jq git prefetch-npm-deps moreutils nodejs jd-diff-patch common-updater-scripts common-updater-scripts | ||
|
||
# shellcheck shell=bash | ||
|
||
set -eou pipefail | ||
|
||
NIXPKGS_DIR="$PWD" | ||
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")" | ||
|
||
# Get latest release | ||
OPENGIST_RELEASE=$( | ||
curl --silent ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \ | ||
https://api.github.com/repos/thomiceli/opengist/releases/latest | ||
) | ||
|
||
# Get release information | ||
latestVersion=$(echo "$OPENGIST_RELEASE" | jq -r ".tag_name") | ||
latestVersion="${latestVersion:1}" # remove first char 'v' | ||
|
||
oldVersion=$(nix eval --raw -f "$NIXPKGS_DIR" opengist.version) | ||
|
||
if [[ "$oldVersion" == "$latestVersion" ]]; then | ||
echo "opengist is up-to-date: ${oldVersion}" | ||
echo TODO exit 0 | ||
fi | ||
|
||
echo "Updating opengist $oldVersion -> $latestVersion" | ||
|
||
update-source-version opengist "${latestVersion}" | ||
|
||
pushd "$SCRIPT_DIR" >/dev/null || exit 1 | ||
|
||
# esbuild patch | ||
rm -f package{,-lock}.json | ||
curl -sLO "https://raw.githubusercontent.com/thomiceli/opengist/refs/tags/v$latestVersion/package.json" | ||
curl -sLO "https://raw.githubusercontent.com/thomiceli/opengist/refs/tags/v$latestVersion/package-lock.json" | ||
|
||
# keep original | ||
cp package-lock.json package-lock-original.json | ||
jq -S . package-lock-original.json | sponge package-lock-original.json | ||
|
||
# get esbuild ver from package-lock.json | ||
npm add -D esbuild@"$(jq -r '.packages."node_modules/esbuild".version' package-lock.json)" | ||
|
||
# it is committed by r-ryantm | ||
jd -o package-lock-esbuild.jd.diff package-lock-original.json package-lock.json || true | ||
git add package-lock-esbuild.jd.diff | ||
|
||
## npm hash | ||
# sort json after modification | ||
# also sorting it in the derivation | ||
jq -S . package-lock.json | sponge package-lock.json | ||
npmDepsHash="$(prefetch-npm-deps package-lock.json)" | ||
sed -E 's#\bnpmDepsHash = ".*?"#npmDepsHash = "'"$npmDepsHash"'"#' --in-place package.nix | ||
|
||
# cleanup | ||
rm -rf node_modules/ package.json package-lock-original.json package-lock.json | ||
|
||
popd >/dev/null | ||
|
||
# nix-prefetch broken due to ninja finalAttrs.src.rev | ||
# nix-update with goModules broken for this package | ||
|
||
setKV () { | ||
sed -i "s|$1 = \".*\"|$1 = \"${2:-}\"|" "${SCRIPT_DIR}/package.nix" | ||
} | ||
|
||
setKV vendorHash "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" # The same as lib.fakeHash | ||
|
||
set +e | ||
VENDOR_HASH=$(nix-build --no-out-link -A opengist "$NIXPKGS_DIR" 2>&1 >/dev/null | grep "got:" | cut -d':' -f2 | sed 's| ||g') | ||
set -e | ||
|
||
if [ -n "${VENDOR_HASH:-}" ]; then | ||
setKV vendorHash "${VENDOR_HASH}" | ||
else | ||
echo "Update failed. VENDOR_HASH is empty." | ||
exit 1 | ||
fi |