Loading pkgs/by-name/ho/homepage-dashboard/package.nix +20 −7 Original line number Diff line number Diff line Loading @@ -38,18 +38,11 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-03am9z381UozNsmWZefopMp8/tLycXJyiZ5BUGaV1kY="; }; # This patch ensures that the cache implementation respects the env # variable `NIXPKGS_HOMEPAGE_CACHE_DIR`, which is set by default in the # wrapper below. # The patch is automatically generated by the `update.sh` script. patches = [ ./prerender_cache_path.patch ]; pnpmDeps = pnpm_10.fetchDeps { inherit (finalAttrs) pname version src patches ; fetcherVersion = 1; hash = "sha256-svkqmRFwZpcExFWtAbLL0lpHhzsI2s7RiLfQajIqjck="; Loading @@ -68,6 +61,26 @@ stdenv.mkDerivation (finalAttrs: { env.PYTHON = "${python3}/bin/python"; preBuild = '' # patch next.js file-system-cache to use NIXPKGS_HOMEPAGE_CACHE_DIR # related: # * https://github.com/NixOS/nixpkgs/issues/328621 ("homepage-dashboard: Failed to update prerender cache") # * https://github.com/NixOS/nixpkgs/pull/337902 ("nixos/homepage-dashboard: set an explicit cache dir") # * https://github.com/NixOS/nixpkgs/issues/458494 ("homepage-dashboard: Dashboard styles are destroyed after a server restart") # source file substituteInPlace node_modules/next/dist/server/lib/incremental-cache/file-system-cache.js \ --replace-fail 'this.serverDistDir = ctx.serverDistDir;' \ 'this.serverDistDir = require("path").join((process.env.NIXPKGS_HOMEPAGE_CACHE_DIR || "/var/cache/homepage-dashboard"), "homepage");' # bundled runtimes for bundle in node_modules/next/dist/compiled/next-server/*.runtime.prod.js; do substituteInPlace "$bundle" \ --replace-fail 'this.serverDistDir=e.serverDistDir' \ 'this.serverDistDir=(process.env.NIXPKGS_HOMEPAGE_CACHE_DIR||"/var/cache/homepage-dashboard")+"/homepage"' done ''; buildPhase = '' runHook preBuild mkdir -p config Loading pkgs/by-name/ho/homepage-dashboard/prerender_cache_path.patchdeleted 100644 → 0 +0 −89 Original line number Diff line number Diff line diff --git a/package.json b/package.json index 927674f3..e7d45ae6 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,9 @@ "onlyBuiltDependencies": [ "osx-temperature-sensor", "sharp" - ] + ], + "patchedDependencies": { + "next": "patches/next.patch" + } } } diff --git a/patches/next.patch b/patches/next.patch new file mode 100644 index 00000000..39b17f16 --- /dev/null +++ b/patches/next.patch @@ -0,0 +1,13 @@ +diff --git a/dist/server/lib/incremental-cache/file-system-cache.js b/dist/server/lib/incremental-cache/file-system-cache.js +index cc2cc2506668435d817eaa9f0aa32b568b6aa331..26f0321efcadb4f4255dbd660825759721e799eb 100644 +--- a/dist/server/lib/incremental-cache/file-system-cache.js ++++ b/dist/server/lib/incremental-cache/file-system-cache.js +@@ -24,7 +24,7 @@ class FileSystemCache { + constructor(ctx){ + this.fs = ctx.fs; + this.flushToDisk = ctx.flushToDisk; +- this.serverDistDir = ctx.serverDistDir; ++ this.serverDistDir = require("path").join((process.env.NIXPKGS_HOMEPAGE_CACHE_DIR || "/var/cache/homepage-dashboard"), "homepage"); + this.revalidatedTags = ctx.revalidatedTags; + if (ctx.maxMemoryCacheSize) { + if (!FileSystemCache.memoryCache) { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2765fe04..11dc6a81 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,11 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +patchedDependencies: + next: + hash: 9fc5fd5a09692f0ba1ffb8a979978da9595ed6c3f9bcb0a01205f20fdc39b68c + path: patches/next.patch + importers: .: @@ -52,10 +57,10 @@ importers: version: 1.2.2 next: specifier: ^15.5.2 - version: 15.5.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + version: 15.5.2(patch_hash=9fc5fd5a09692f0ba1ffb8a979978da9595ed6c3f9bcb0a01205f20fdc39b68c)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) next-i18next: specifier: ^12.1.0 - version: 12.1.0(next@15.5.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + version: 12.1.0(next@15.5.2(patch_hash=9fc5fd5a09692f0ba1ffb8a979978da9595ed6c3f9bcb0a01205f20fdc39b68c)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) ping: specifier: ^0.4.4 version: 0.4.4 @@ -5243,7 +5248,7 @@ snapshots: net@1.0.2: {} - next-i18next@12.1.0(next@15.5.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1): + next-i18next@12.1.0(next@15.5.2(patch_hash=9fc5fd5a09692f0ba1ffb8a979978da9595ed6c3f9bcb0a01205f20fdc39b68c)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1): dependencies: '@babel/runtime': 7.26.9 '@types/hoist-non-react-statics': 3.3.6 @@ -5251,14 +5256,14 @@ snapshots: hoist-non-react-statics: 3.3.2 i18next: 21.10.0 i18next-fs-backend: 1.2.0 - next: 15.5.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + next: 15.5.2(patch_hash=9fc5fd5a09692f0ba1ffb8a979978da9595ed6c3f9bcb0a01205f20fdc39b68c)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) react: 18.3.1 react-i18next: 11.18.6(i18next@21.10.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) transitivePeerDependencies: - react-dom - react-native - next@15.5.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1): + next@15.5.2(patch_hash=9fc5fd5a09692f0ba1ffb8a979978da9595ed6c3f9bcb0a01205f20fdc39b68c)(react-dom@18.3.1(react@18.3.1))(react@18.3.1): dependencies: '@next/env': 15.5.2 '@swc/helpers': 0.5.15 pkgs/by-name/ho/homepage-dashboard/update.sh +1 −26 Original line number Diff line number Diff line #!/usr/bin/env nix-shell #!nix-shell -I nixpkgs=./. -i bash -p curl jq git nodejs pnpm sd #!nix-shell -I nixpkgs=./. -i bash -p curl jq git # shellcheck shell=bash set -euo pipefail nixpkgs="$(pwd)" cd $(readlink -e $(dirname "${BASH_SOURCE[0]}")) # Generate the patch file that makes homepage-dashboard aware of the NIXPKGS_HOMEPAGE_CACHE_DIR environment variable. # Generating the patch this way ensures that both the patch is included, and the lock file is updated. generate_patch() { local version; version="$1" echo "Generating homepage-dashboard patch" git clone -b "v$version" https://github.com/gethomepage/homepage.git src pushd src pnpm install pnpm patch next sd \ 'this.serverDistDir = ctx.serverDistDir;' \ 'this.serverDistDir = require("path").join((process.env.NIXPKGS_HOMEPAGE_CACHE_DIR || "/var/cache/homepage-dashboard"), "homepage");' \ node_modules/.pnpm_patches/next*/dist/server/lib/incremental-cache/file-system-cache.js pnpm patch-commit node_modules/.pnpm_patches/next* git add -A . git diff -p --staged --no-ext-diff > ../prerender_cache_path.patch popd rm -rf src } # Update the hash of the homepage-dashboard source code in the Nix expression. update_homepage_dashboard_source() { local version; version="$1" Loading Loading @@ -62,5 +38,4 @@ if [[ "$CURRENT_VERSION" == "$LATEST_VERSION" ]]; then fi update_homepage_dashboard_source "$LATEST_VERSION" generate_patch "$LATEST_VERSION" update_pnpm_deps_hash Loading
pkgs/by-name/ho/homepage-dashboard/package.nix +20 −7 Original line number Diff line number Diff line Loading @@ -38,18 +38,11 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-03am9z381UozNsmWZefopMp8/tLycXJyiZ5BUGaV1kY="; }; # This patch ensures that the cache implementation respects the env # variable `NIXPKGS_HOMEPAGE_CACHE_DIR`, which is set by default in the # wrapper below. # The patch is automatically generated by the `update.sh` script. patches = [ ./prerender_cache_path.patch ]; pnpmDeps = pnpm_10.fetchDeps { inherit (finalAttrs) pname version src patches ; fetcherVersion = 1; hash = "sha256-svkqmRFwZpcExFWtAbLL0lpHhzsI2s7RiLfQajIqjck="; Loading @@ -68,6 +61,26 @@ stdenv.mkDerivation (finalAttrs: { env.PYTHON = "${python3}/bin/python"; preBuild = '' # patch next.js file-system-cache to use NIXPKGS_HOMEPAGE_CACHE_DIR # related: # * https://github.com/NixOS/nixpkgs/issues/328621 ("homepage-dashboard: Failed to update prerender cache") # * https://github.com/NixOS/nixpkgs/pull/337902 ("nixos/homepage-dashboard: set an explicit cache dir") # * https://github.com/NixOS/nixpkgs/issues/458494 ("homepage-dashboard: Dashboard styles are destroyed after a server restart") # source file substituteInPlace node_modules/next/dist/server/lib/incremental-cache/file-system-cache.js \ --replace-fail 'this.serverDistDir = ctx.serverDistDir;' \ 'this.serverDistDir = require("path").join((process.env.NIXPKGS_HOMEPAGE_CACHE_DIR || "/var/cache/homepage-dashboard"), "homepage");' # bundled runtimes for bundle in node_modules/next/dist/compiled/next-server/*.runtime.prod.js; do substituteInPlace "$bundle" \ --replace-fail 'this.serverDistDir=e.serverDistDir' \ 'this.serverDistDir=(process.env.NIXPKGS_HOMEPAGE_CACHE_DIR||"/var/cache/homepage-dashboard")+"/homepage"' done ''; buildPhase = '' runHook preBuild mkdir -p config Loading
pkgs/by-name/ho/homepage-dashboard/prerender_cache_path.patchdeleted 100644 → 0 +0 −89 Original line number Diff line number Diff line diff --git a/package.json b/package.json index 927674f3..e7d45ae6 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,9 @@ "onlyBuiltDependencies": [ "osx-temperature-sensor", "sharp" - ] + ], + "patchedDependencies": { + "next": "patches/next.patch" + } } } diff --git a/patches/next.patch b/patches/next.patch new file mode 100644 index 00000000..39b17f16 --- /dev/null +++ b/patches/next.patch @@ -0,0 +1,13 @@ +diff --git a/dist/server/lib/incremental-cache/file-system-cache.js b/dist/server/lib/incremental-cache/file-system-cache.js +index cc2cc2506668435d817eaa9f0aa32b568b6aa331..26f0321efcadb4f4255dbd660825759721e799eb 100644 +--- a/dist/server/lib/incremental-cache/file-system-cache.js ++++ b/dist/server/lib/incremental-cache/file-system-cache.js +@@ -24,7 +24,7 @@ class FileSystemCache { + constructor(ctx){ + this.fs = ctx.fs; + this.flushToDisk = ctx.flushToDisk; +- this.serverDistDir = ctx.serverDistDir; ++ this.serverDistDir = require("path").join((process.env.NIXPKGS_HOMEPAGE_CACHE_DIR || "/var/cache/homepage-dashboard"), "homepage"); + this.revalidatedTags = ctx.revalidatedTags; + if (ctx.maxMemoryCacheSize) { + if (!FileSystemCache.memoryCache) { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 2765fe04..11dc6a81 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,11 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +patchedDependencies: + next: + hash: 9fc5fd5a09692f0ba1ffb8a979978da9595ed6c3f9bcb0a01205f20fdc39b68c + path: patches/next.patch + importers: .: @@ -52,10 +57,10 @@ importers: version: 1.2.2 next: specifier: ^15.5.2 - version: 15.5.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + version: 15.5.2(patch_hash=9fc5fd5a09692f0ba1ffb8a979978da9595ed6c3f9bcb0a01205f20fdc39b68c)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) next-i18next: specifier: ^12.1.0 - version: 12.1.0(next@15.5.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + version: 12.1.0(next@15.5.2(patch_hash=9fc5fd5a09692f0ba1ffb8a979978da9595ed6c3f9bcb0a01205f20fdc39b68c)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1) ping: specifier: ^0.4.4 version: 0.4.4 @@ -5243,7 +5248,7 @@ snapshots: net@1.0.2: {} - next-i18next@12.1.0(next@15.5.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1): + next-i18next@12.1.0(next@15.5.2(patch_hash=9fc5fd5a09692f0ba1ffb8a979978da9595ed6c3f9bcb0a01205f20fdc39b68c)(react-dom@18.3.1(react@18.3.1))(react@18.3.1))(react-dom@18.3.1(react@18.3.1))(react@18.3.1): dependencies: '@babel/runtime': 7.26.9 '@types/hoist-non-react-statics': 3.3.6 @@ -5251,14 +5256,14 @@ snapshots: hoist-non-react-statics: 3.3.2 i18next: 21.10.0 i18next-fs-backend: 1.2.0 - next: 15.5.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + next: 15.5.2(patch_hash=9fc5fd5a09692f0ba1ffb8a979978da9595ed6c3f9bcb0a01205f20fdc39b68c)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) react: 18.3.1 react-i18next: 11.18.6(i18next@21.10.0)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) transitivePeerDependencies: - react-dom - react-native - next@15.5.2(react-dom@18.3.1(react@18.3.1))(react@18.3.1): + next@15.5.2(patch_hash=9fc5fd5a09692f0ba1ffb8a979978da9595ed6c3f9bcb0a01205f20fdc39b68c)(react-dom@18.3.1(react@18.3.1))(react@18.3.1): dependencies: '@next/env': 15.5.2 '@swc/helpers': 0.5.15
pkgs/by-name/ho/homepage-dashboard/update.sh +1 −26 Original line number Diff line number Diff line #!/usr/bin/env nix-shell #!nix-shell -I nixpkgs=./. -i bash -p curl jq git nodejs pnpm sd #!nix-shell -I nixpkgs=./. -i bash -p curl jq git # shellcheck shell=bash set -euo pipefail nixpkgs="$(pwd)" cd $(readlink -e $(dirname "${BASH_SOURCE[0]}")) # Generate the patch file that makes homepage-dashboard aware of the NIXPKGS_HOMEPAGE_CACHE_DIR environment variable. # Generating the patch this way ensures that both the patch is included, and the lock file is updated. generate_patch() { local version; version="$1" echo "Generating homepage-dashboard patch" git clone -b "v$version" https://github.com/gethomepage/homepage.git src pushd src pnpm install pnpm patch next sd \ 'this.serverDistDir = ctx.serverDistDir;' \ 'this.serverDistDir = require("path").join((process.env.NIXPKGS_HOMEPAGE_CACHE_DIR || "/var/cache/homepage-dashboard"), "homepage");' \ node_modules/.pnpm_patches/next*/dist/server/lib/incremental-cache/file-system-cache.js pnpm patch-commit node_modules/.pnpm_patches/next* git add -A . git diff -p --staged --no-ext-diff > ../prerender_cache_path.patch popd rm -rf src } # Update the hash of the homepage-dashboard source code in the Nix expression. update_homepage_dashboard_source() { local version; version="$1" Loading Loading @@ -62,5 +38,4 @@ if [[ "$CURRENT_VERSION" == "$LATEST_VERSION" ]]; then fi update_homepage_dashboard_source "$LATEST_VERSION" generate_patch "$LATEST_VERSION" update_pnpm_deps_hash