feat: attempt to update homepage to 1.0.0

This commit is contained in:
matt1432 2025-03-14 19:36:59 -04:00
parent 51cc659c91
commit 4765001144
3 changed files with 58 additions and 54 deletions

View file

@ -4,36 +4,40 @@
# nix build inputs
lib,
stdenv,
buildNpmPackage,
concatTextFile,
fetchFromGitHub,
makeWrapper,
# deps
cctools,
git,
nodePackages,
nodejs,
pnpm,
python3,
IOKit ? {},
...
}: let
inherit (lib) optionals optionalString;
inherit (lib) optionalString;
installLocalIcons = import ./icons.nix {inherit fetchFromGitHub;};
pname = "homepage-dashboard";
version = "0.10.9";
in
buildNpmPackage {
inherit pname version;
stdenv.mkDerivation (finalAttrs: {
pname = "homepage-dashboard";
version = "1.0.0";
src = fetchFromGitHub {
owner = "gethomepage";
repo = "homepage";
rev = "v${version}";
hash = "sha256-q8+uoikHMQVuTrVSH8tPsoI5655ZStMc/7tmoAfoZIY=";
rev = "v${finalAttrs.version}";
hash = "sha256-j543lwSWOFuPjHCTN/4vEKME39RpG4D16qWeSrL5hZY=";
};
npmDepsHash = "sha256-N39gwct2U4UxlIL5ceDzzU7HpA6xh2WksrZNxGz04PU=";
pnpmDepsHash = "sha256-E16+JLtfoiWCXwgFGdTGuFlx/pYxhINNl6tCuF9Z6MQ=";
preBuild = ''
mkdir -p config
pnpmDeps = pnpm.fetchDeps {
inherit (finalAttrs) pname version src;
hash = finalAttrs.pnpmDepsHash;
};
buildPhase = ''
pnpm build
'';
postBuild = ''
@ -42,13 +46,12 @@ in
patchShebangs .next/standalone/server.js
'';
nativeBuildInputs = [git] ++ optionals stdenv.hostPlatform.isDarwin [cctools];
buildInputs =
[
nodePackages.node-gyp-build
]
++ optionals stdenv.hostPlatform.isDarwin [IOKit];
nativeBuildInputs = [
git
makeWrapper
nodejs
pnpm.configHook
];
env.PYTHON = "${python3}/bin/python";
@ -57,6 +60,16 @@ in
mkdir -p $out/{share,bin}
# Without this, homepage-dashboard errors when trying to
# write its prerender cache.
#
# This ensures that the cache implementation respects the env
# variable `HOMEPAGE_CACHE_DIR`, which is set by default in the
# wrapper below.
substituteInPlace .next/standalone/node_modules/next/dist/server/lib/incremental-cache/file-system-cache.js --replace-fail \
"this.serverDistDir = ctx.serverDistDir;" \
"this.serverDistDir = require('node:path').join(process.env.HOMEPAGE_CACHE_DIR, \"homepage\");"
cp -r .next/standalone $out/share/homepage/
cp -r public $out/share/homepage/public
@ -65,17 +78,6 @@ in
chmod +x $out/share/homepage/server.js
# This patch must be applied here, as it's patching the `dist` directory
# of NextJS. Without this, homepage-dashboard errors when trying to
# write its prerender cache.
#
# This patch ensures that the cache implementation respects the env
# variable `HOMEPAGE_CACHE_DIR`, which is set by default in the
# wrapper below.
pushd $out
git apply ${./prerender_cache_path.patch}
popd
makeWrapper $out/share/homepage/server.js $out/bin/homepage \
--set-default PORT 3000 \
--set-default HOMEPAGE_CONFIG_DIR /var/lib/homepage-dashboard \
@ -86,15 +88,20 @@ in
runHook postInstall
'';
doDist = false;
passthru.updateScript = concatTextFile {
name = "update";
files = [./update.sh];
executable = true;
destination = "/bin/update";
};
meta = {
mainProgram = "homepage";
license = lib.licenses.gpl3;
homepage = "https://gethomepage.dev";
changelog = "https://github.com/gethomepage/homepage/releases/tag/v${version}";
changelog = "https://github.com/gethomepage/homepage/releases/tag/v${finalAttrs.version}";
description = ''
Highly customisable dashboard with Docker and service API integrations.
'';
};
}
})

View file

@ -1,18 +0,0 @@
diff --git a/share/homepage/node_modules/next/dist/server/lib/incremental-cache/file-system-cache.js b/share/homepage/node_modules/next/dist/server/lib/incremental-cache/file-system-cache.js
index b1b74d8..a46c80b 100644
--- a/share/homepage/node_modules/next/dist/server/lib/incremental-cache/file-system-cache.js
+++ b/share/homepage/node_modules/next/dist/server/lib/incremental-cache/file-system-cache.js
@@ -5,11 +5,12 @@ Object.defineProperty(exports, "__esModule", {
exports.default = void 0;
var _lruCache = _interopRequireDefault(require("next/dist/compiled/lru-cache"));
var _path = _interopRequireDefault(require("../../../shared/lib/isomorphic/path"));
+var path = require('node:path');
class FileSystemCache {
constructor(ctx){
this.fs = ctx.fs;
this.flushToDisk = ctx.flushToDisk;
- this.serverDistDir = ctx.serverDistDir;
+ this.serverDistDir = path.join(process.env.HOMEPAGE_CACHE_DIR, "homepage");
this.appDir = !!ctx._appDir;
if (ctx.maxMemoryCacheSize) {
this.memoryCache = new _lruCache.default({

View file

@ -0,0 +1,15 @@
#!/usr/bin/env bash
nix-update --flake homepage
file="$FLAKE/packages/homepage/default.nix"
old_hash="$(sed -n 's/.*pnpmDepsHash = "\(.*\)";/\1/p' "$file")"
sed -i "s/pnpmDepsHash = .*/pnpmDepsHash = \"\";/" "$file"
npm_hash="$(nix build "$FLAKE#homepage" |& sed -n 's/.*got: *//p')"
if [[ "$npm_hash" != "$old_hash" ]]; then
sed -i "s#pnpmDepsHash = .*#pnpmDepsHash = \"$npm_hash\";#" "$file"
else
sed -i "s#pnpmDepsHash = .*#pnpmDepsHash = \"$old_hash\";#" "$file"
fi