From a68ee204a5baa4d274dfebb33bda7b21889db08f Mon Sep 17 00:00:00 2001 From: TomaSajt <62384384+TomaSajt@users.noreply.github.com> Date: Fri, 18 Apr 2025 21:02:44 +0200 Subject: [PATCH] redisinsight: 2.48.0 -> 2.68.0 --- pkgs/by-name/re/redisinsight/package.nix | 146 +++++++++--------- .../re/redisinsight/remove-cpu-features.patch | 70 +++++++++ 2 files changed, 146 insertions(+), 70 deletions(-) create mode 100644 pkgs/by-name/re/redisinsight/remove-cpu-features.patch diff --git a/pkgs/by-name/re/redisinsight/package.nix b/pkgs/by-name/re/redisinsight/package.nix index 2c2f4bd345b6..9f8c88f2b136 100644 --- a/pkgs/by-name/re/redisinsight/package.nix +++ b/pkgs/by-name/re/redisinsight/package.nix @@ -1,108 +1,108 @@ { lib, stdenv, + fetchFromGitHub, - makeWrapper, - makeDesktopItem, - copyDesktopItems, - fixup-yarn-lock, - yarn, - nodejs_18, - python3, fetchYarnDeps, - electron, - nest-cli, - libsass, - buildPackages, + makeDesktopItem, + + copyDesktopItems, + dart-sass, + makeWrapper, + nodejs_20, pkg-config, + yarnConfigHook, + + electron, + libsecret, sqlite, - xdg-utils, }: let - nodejs = nodejs_18; + nodejs = nodejs_20; in stdenv.mkDerivation (finalAttrs: { pname = "redisinsight"; - version = "2.48.0"; + version = "2.68.0"; src = fetchFromGitHub { owner = "RedisInsight"; repo = "RedisInsight"; rev = finalAttrs.version; - hash = "sha256-ek0Fp8v6j+mZPK2cEuFNrBgInXdYIKBBUg0UD1I51Sg="; + hash = "sha256-rXp3C/Ui3vMBscsxlwU9fRF1bmvMrvXLtmJfGzfh1Rk="; }; - offlineCache = fetchYarnDeps { - yarnLock = finalAttrs.src + "/yarn.lock"; - hash = "sha256-ohtU1h6wrg7asXDxTt1Jlzx9GaS3zDrGQD9P9tgzCOE="; + patches = [ + # the `file:` specifier doesn't seem to be supported with fetchYarnDeps + # upstream uses it to point the cpu-features dependency to a stub package + # so it's safe to remove + ./remove-cpu-features.patch + ]; + + baseOfflineCache = fetchYarnDeps { + name = "redisinsight-${finalAttrs.version}-base-offline-cache"; + inherit (finalAttrs) src patches; + hash = "sha256-ORVftwl/8Yrug2MeqWfZTsHNTRJlpKGn2P7JCHUf3do="; }; - feOfflineCache = fetchYarnDeps { - yarnLock = finalAttrs.src + "/redisinsight/yarn.lock"; - hash = "sha256-9xbIdDeLUEk4eNeK7RTwidqDGinA8SPfcumqml66kTw="; + innerOfflineCache = fetchYarnDeps { + name = "redisinsight-${finalAttrs.version}-inner-offline-cache"; + inherit (finalAttrs) src patches; + postPatch = "cd redisinsight"; + hash = "sha256-yFfkpWV/GD2CcAzb0D3lNZwmqzEN6Bi1MjPyRwClaQ0="; }; apiOfflineCache = fetchYarnDeps { - yarnLock = finalAttrs.src + "/redisinsight/api/yarn.lock"; - hash = "sha256-4zbffuneTceMEyKb8atTXTFhTv0DhrsRMdepZWgoxMQ="; + name = "redisinsight-${finalAttrs.version}-api-offline-cache"; + inherit (finalAttrs) src patches; + postPatch = "cd redisinsight/api"; + hash = "sha256-go7IR1UsW8TrWjaFSlC6/biUvb9cHo3PgJa16tF0XHo="; }; nativeBuildInputs = [ - yarn - fixup-yarn-lock - nodejs - makeWrapper - (python3.withPackages (ps: [ ps.setuptools ])) - nest-cli - libsass - pkg-config copyDesktopItems + makeWrapper + nodejs + (nodejs.python.withPackages (ps: [ ps.setuptools ])) + pkg-config + yarnConfigHook ]; buildInputs = [ - sqlite - xdg-utils + sqlite # for `sqlite3` node module + libsecret # for `keytar` node module ]; + postPatch = '' + substituteInPlace redisinsight/api/config/default.ts \ + --replace-fail "process['resourcesPath']" "\"$out/share/redisinsight\"" + + # has irrelevant files + rm -r resources/app + ''; + + # will run yarnConfigHook manually later + dontYarnInstallDeps = true; + configurePhase = '' runHook preConfigure - export HOME=$(mktemp -d) - yarn config --offline set yarn-offline-mirror ${finalAttrs.offlineCache} - fixup-yarn-lock yarn.lock - yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive + yarnOfflineCache="$baseOfflineCache" yarnConfigHook + cd redisinsight + yarnOfflineCache="$innerOfflineCache" yarnConfigHook + cd api + yarnOfflineCache="$apiOfflineCache" yarnConfigHook + cd ../.. - yarn config --offline set yarn-offline-mirror ${finalAttrs.feOfflineCache} - fixup-yarn-lock redisinsight/yarn.lock - yarn --offline --cwd redisinsight/ --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive - - yarn config --offline set yarn-offline-mirror ${finalAttrs.apiOfflineCache} - fixup-yarn-lock redisinsight/api/yarn.lock - yarn --offline --cwd redisinsight/api/ --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive - - patchShebangs node_modules/ - patchShebangs redisinsight/node_modules/ - patchShebangs redisinsight/api/node_modules/ - - mkdir -p "$HOME/.node-gyp/${nodejs.version}" - echo 9 >"$HOME/.node-gyp/${nodejs.version}/installVersion" - ln -sfv "${nodejs}/include" "$HOME/.node-gyp/${nodejs.version}" - export npm_config_nodedir=${nodejs} - - # Build the sqlite3 package. - pushd redisinsight - npm_config_node_gyp="${buildPackages.nodejs}/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" npm rebuild --verbose --sqlite=${sqlite.dev} sqlite3 - popd - - # Build node-sass - LIBSASS_EXT=auto npm rebuild --verbose node-sass - - substituteInPlace redisinsight/api/config/default.ts \ - --replace-fail "process['resourcesPath']" "\"$out/share/redisinsight\"" \ - - # has irrelevant files - rm -r resources/app + export npm_config_nodedir=${electron.headers} + export npm_config_sqlite=${lib.getDev sqlite} + export ELECTRON_SKIP_BINARY_DOWNLOAD=1 + npm rebuild --verbose --no-progress + cd redisinsight + npm rebuild --verbose --no-progress + cd api + npm rebuild --verbose --no-progress + cd ../.. runHook postConfigure ''; @@ -110,14 +110,20 @@ stdenv.mkDerivation (finalAttrs: { buildPhase = '' runHook preBuild - yarn config --offline set yarn-offline-mirror ${finalAttrs.offlineCache} + # force the sass npm dependency to use our own sass binary instead of the bundled one + substituteInPlace node_modules/sass/dist/lib/src/compiler-path.js \ + --replace-fail 'compilerCommand = (() => {' 'compilerCommand = (() => { return ["${lib.getExe dart-sass}"];' yarn --offline build:prod + # TODO: Generate defaults. Currently broken because it requires network access. + # yarn --offline --cwd=redisinsight/api build:defaults + yarn --offline electron-builder \ --dir \ -c.electronDist=${electron.dist} \ - -c.electronVersion=${electron.version} + -c.electronVersion=${electron.version} \ + -c.npmRebuild=false # we've already rebuilt the native libs using the electron headers runHook postBuild ''; @@ -159,7 +165,7 @@ stdenv.mkDerivation (finalAttrs: { ]; meta = { - description = "RedisInsight Redis client powered by Electron"; + description = "Developer GUI for Redis"; homepage = "https://github.com/RedisInsight/RedisInsight"; license = lib.licenses.sspl; maintainers = with lib.maintainers; [ diff --git a/pkgs/by-name/re/redisinsight/remove-cpu-features.patch b/pkgs/by-name/re/redisinsight/remove-cpu-features.patch new file mode 100644 index 000000000000..a24964a6e322 --- /dev/null +++ b/pkgs/by-name/re/redisinsight/remove-cpu-features.patch @@ -0,0 +1,70 @@ +diff --git a/redisinsight/api/package.json b/redisinsight/api/package.json +index 4a24ac8..fab339c 100644 +--- a/redisinsight/api/package.json ++++ b/redisinsight/api/package.json +@@ -49,7 +49,6 @@ + "@nestjs/platform-socket.io/socket.io": "^4.8.0", + "@nestjs/cli/**/braces": "^3.0.3", + "**/semver": "^7.5.2", +- "**/cpu-features": "file:./stubs/cpu-features", + "**/cross-spawn": "^7.0.5", + "**/redis-parser": "3.0.0", + "winston-daily-rotate-file/**/file-stream-rotator": "^1.0.0" +diff --git a/redisinsight/api/yarn.lock b/redisinsight/api/yarn.lock +index e0e8495..dfed1ae 100644 +--- a/redisinsight/api/yarn.lock ++++ b/redisinsight/api/yarn.lock +@@ -3223,9 +3223,6 @@ cosmiconfig@^8.2.0: + parse-json "^5.2.0" + path-type "^4.0.0" + +-"cpu-features@file:./stubs/cpu-features", cpu-features@~0.0.9: +- version "1.0.0" +- + create-jest@^29.7.0: + version "29.7.0" + resolved "https://registry.yarnpkg.com/create-jest/-/create-jest-29.7.0.tgz#a355c5b3cb1e1af02ba177fe7afd7feee49a5320" +@@ -7969,7 +7966,6 @@ ssh2@^1.15.0: + asn1 "^0.2.6" + bcrypt-pbkdf "^1.0.2" + optionalDependencies: +- cpu-features "~0.0.9" + nan "^2.18.0" + + ssri@^8.0.0, ssri@^8.0.1: +diff --git a/redisinsight/package.json b/redisinsight/package.json +index 8649be7..354ed42 100644 +--- a/redisinsight/package.json ++++ b/redisinsight/package.json +@@ -16,8 +16,7 @@ + }, + "resolutions": { + "**/semver": "^7.5.2", +- "sqlite3/**/tar": "^6.2.1", +- "**/cpu-features": "file:./api/stubs/cpu-features" ++ "sqlite3/**/tar": "^6.2.1" + }, + "dependencies": { + "keytar": "^7.9.0", +diff --git a/redisinsight/yarn.lock b/redisinsight/yarn.lock +index 7a063ce..22f37a7 100644 +--- a/redisinsight/yarn.lock ++++ b/redisinsight/yarn.lock +@@ -183,9 +183,6 @@ console-control-strings@^1.1.0: + resolved "https://registry.yarnpkg.com/console-control-strings/-/console-control-strings-1.1.0.tgz#3d7cf4464db6446ea644bf4b39507f9851008e8e" + integrity sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ== + +-"cpu-features@file:./api/stubs/cpu-features", cpu-features@~0.0.10: +- version "1.0.0" +- + debug@4, debug@^4.3.3: + version "4.3.4" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" +@@ -807,7 +804,6 @@ ssh2@^1.15.0: + asn1 "^0.2.6" + bcrypt-pbkdf "^1.0.2" + optionalDependencies: +- cpu-features "~0.0.10" + nan "^2.20.0" + + ssri@^8.0.0, ssri@^8.0.1: