parent
51cc659c91
commit
4765001144
3 changed files with 58 additions and 54 deletions
packages/homepage
|
@ -4,36 +4,40 @@
|
||||||
# nix build inputs
|
# nix build inputs
|
||||||
lib,
|
lib,
|
||||||
stdenv,
|
stdenv,
|
||||||
buildNpmPackage,
|
concatTextFile,
|
||||||
fetchFromGitHub,
|
fetchFromGitHub,
|
||||||
|
makeWrapper,
|
||||||
# deps
|
# deps
|
||||||
cctools,
|
|
||||||
git,
|
git,
|
||||||
nodePackages,
|
nodejs,
|
||||||
|
pnpm,
|
||||||
python3,
|
python3,
|
||||||
IOKit ? {},
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib) optionals optionalString;
|
inherit (lib) optionalString;
|
||||||
|
|
||||||
installLocalIcons = import ./icons.nix {inherit fetchFromGitHub;};
|
installLocalIcons = import ./icons.nix {inherit fetchFromGitHub;};
|
||||||
|
|
||||||
pname = "homepage-dashboard";
|
|
||||||
version = "0.10.9";
|
|
||||||
in
|
in
|
||||||
buildNpmPackage {
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
inherit pname version;
|
pname = "homepage-dashboard";
|
||||||
|
version = "1.0.0";
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "gethomepage";
|
owner = "gethomepage";
|
||||||
repo = "homepage";
|
repo = "homepage";
|
||||||
rev = "v${version}";
|
rev = "v${finalAttrs.version}";
|
||||||
hash = "sha256-q8+uoikHMQVuTrVSH8tPsoI5655ZStMc/7tmoAfoZIY=";
|
hash = "sha256-j543lwSWOFuPjHCTN/4vEKME39RpG4D16qWeSrL5hZY=";
|
||||||
};
|
};
|
||||||
|
|
||||||
npmDepsHash = "sha256-N39gwct2U4UxlIL5ceDzzU7HpA6xh2WksrZNxGz04PU=";
|
pnpmDepsHash = "sha256-E16+JLtfoiWCXwgFGdTGuFlx/pYxhINNl6tCuF9Z6MQ=";
|
||||||
|
|
||||||
preBuild = ''
|
pnpmDeps = pnpm.fetchDeps {
|
||||||
mkdir -p config
|
inherit (finalAttrs) pname version src;
|
||||||
|
hash = finalAttrs.pnpmDepsHash;
|
||||||
|
};
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
pnpm build
|
||||||
'';
|
'';
|
||||||
|
|
||||||
postBuild = ''
|
postBuild = ''
|
||||||
|
@ -42,13 +46,12 @@ in
|
||||||
patchShebangs .next/standalone/server.js
|
patchShebangs .next/standalone/server.js
|
||||||
'';
|
'';
|
||||||
|
|
||||||
nativeBuildInputs = [git] ++ optionals stdenv.hostPlatform.isDarwin [cctools];
|
nativeBuildInputs = [
|
||||||
|
git
|
||||||
buildInputs =
|
makeWrapper
|
||||||
[
|
nodejs
|
||||||
nodePackages.node-gyp-build
|
pnpm.configHook
|
||||||
]
|
];
|
||||||
++ optionals stdenv.hostPlatform.isDarwin [IOKit];
|
|
||||||
|
|
||||||
env.PYTHON = "${python3}/bin/python";
|
env.PYTHON = "${python3}/bin/python";
|
||||||
|
|
||||||
|
@ -57,6 +60,16 @@ in
|
||||||
|
|
||||||
mkdir -p $out/{share,bin}
|
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 .next/standalone $out/share/homepage/
|
||||||
cp -r public $out/share/homepage/public
|
cp -r public $out/share/homepage/public
|
||||||
|
|
||||||
|
@ -65,17 +78,6 @@ in
|
||||||
|
|
||||||
chmod +x $out/share/homepage/server.js
|
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 \
|
makeWrapper $out/share/homepage/server.js $out/bin/homepage \
|
||||||
--set-default PORT 3000 \
|
--set-default PORT 3000 \
|
||||||
--set-default HOMEPAGE_CONFIG_DIR /var/lib/homepage-dashboard \
|
--set-default HOMEPAGE_CONFIG_DIR /var/lib/homepage-dashboard \
|
||||||
|
@ -86,15 +88,20 @@ in
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
doDist = false;
|
passthru.updateScript = concatTextFile {
|
||||||
|
name = "update";
|
||||||
|
files = [./update.sh];
|
||||||
|
executable = true;
|
||||||
|
destination = "/bin/update";
|
||||||
|
};
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
mainProgram = "homepage";
|
mainProgram = "homepage";
|
||||||
license = lib.licenses.gpl3;
|
license = lib.licenses.gpl3;
|
||||||
homepage = "https://gethomepage.dev";
|
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 = ''
|
description = ''
|
||||||
Highly customisable dashboard with Docker and service API integrations.
|
Highly customisable dashboard with Docker and service API integrations.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
})
|
||||||
|
|
|
@ -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({
|
|
15
packages/homepage/update.sh
Normal file
15
packages/homepage/update.sh
Normal 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
|
Loading…
Add table
Reference in a new issue