Merge pull request #307467 from TomaSajt/redisinsight

redisinsight: fix build, refactor

authored by Jörg Thalheim and committed by GitHub 9ec6ea71 ba0f4049

+82 -65
+82 -65
pkgs/development/tools/redisinsight/default.nix
··· 1 - { lib 2 - , stdenv 3 - , fetchFromGitHub 4 - , makeWrapper 5 - , makeDesktopItem 6 - , fixup_yarn_lock 7 - , yarn 8 - , nodejs_18 9 - , python3 10 - , fetchYarnDeps 11 - , electron 12 - , desktopToDarwinBundle 13 - , nest-cli 14 - , libsass 15 - , buildPackages 16 - , pkg-config 17 - , sqlite 18 - , xdg-utils 19 }: 20 let 21 nodejs = nodejs_18; 22 in 23 stdenv.mkDerivation (finalAttrs: { 24 - pname = "redisinsight-electron"; 25 version = "2.32"; 26 27 src = fetchFromGitHub { 28 owner = "RedisInsight"; 29 repo = "RedisInsight"; 30 - rev = "${finalAttrs.version}"; 31 hash = "sha256-esaH10AyEooym/62F5LJL7oP5UmD6T2UX8g/9QniL9s="; 32 }; 33 34 offlineCache = fetchYarnDeps { 35 yarnLock = finalAttrs.src + "/yarn.lock"; 36 - sha256 = "NHKttywAaWAYkciGzYCnm1speHrWsv1t+dxL1DZgM7o="; 37 }; 38 39 feOfflineCache = fetchYarnDeps { 40 yarnLock = finalAttrs.src + "/redisinsight/yarn.lock"; 41 - sha256 = "1S1KNUOtmywQ0eyqVS2oRlhpjcL9eps8CR7AtC9ujSU="; 42 }; 43 44 apiOfflineCache = fetchYarnDeps { 45 yarnLock = finalAttrs.src + "/redisinsight/api/yarn.lock"; 46 - sha256 = "P99+1Dhdg/vznC2KepPrVGNlrofJFydXkZVxgwprIx4="; 47 }; 48 49 - nativeBuildInputs = [ yarn fixup_yarn_lock nodejs makeWrapper python3 nest-cli libsass pkg-config ] 50 - ++ lib.optionals stdenv.isDarwin [ desktopToDarwinBundle ]; 51 52 - buildInputs = [ sqlite xdg-utils ]; 53 54 configurePhase = '' 55 runHook preConfigure 56 57 export HOME=$(mktemp -d) 58 - yarn config --offline set yarn-offline-mirror $offlineCache 59 - fixup_yarn_lock yarn.lock 60 yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive 61 62 - yarn config --offline set yarn-offline-mirror $feOfflineCache 63 - fixup_yarn_lock redisinsight/yarn.lock 64 yarn --offline --cwd redisinsight/ --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive 65 66 - yarn config --offline set yarn-offline-mirror $apiOfflineCache 67 - fixup_yarn_lock redisinsight/api/yarn.lock 68 yarn --offline --cwd redisinsight/api/ --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive 69 70 patchShebangs node_modules/ ··· 76 ln -sfv "${nodejs}/include" "$HOME/.node-gyp/${nodejs.version}" 77 export npm_config_nodedir=${nodejs} 78 79 - pushd redisinsight 80 # Build the sqlite3 package. 81 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 82 popd 83 84 substituteInPlace redisinsight/api/config/default.ts \ 85 - --replace "process['resourcesPath']" "\"$out/share/redisinsight\"" \ 86 87 runHook postConfigure 88 ''; 89 90 buildPhase = '' 91 runHook preBuild 92 - yarn config --offline set yarn-offline-mirror $offlineCache 93 94 - pushd node_modules/node-sass 95 - LIBSASS_EXT=auto yarn run build --offline 96 - popd 97 98 yarn --offline build:prod 99 100 yarn --offline electron-builder \ 101 - --dir ${if stdenv.isDarwin then "--macos" else "--linux"} ${if stdenv.hostPlatform.isAarch64 then "--arm64" else "--x64"} \ 102 -c.electronDist=${electron}/libexec/electron \ 103 -c.electronVersion=${electron.version} 104 ··· 108 installPhase = '' 109 runHook preInstall 110 111 - # resources 112 - mkdir -p "$out/share/redisinsight" 113 - mkdir -p "$out/share/redisinsight/static/resources/plugins" 114 - mkdir -p "$out/share/redisinsight/default" 115 116 - cp -r release/${if stdenv.isDarwin then "darwin-" else "linux-"}${lib.optionalString stdenv.hostPlatform.isAarch64 "arm64-"}unpacked/resources/{app.asar,app.asar.unpacked} $out/share/redisinsight/ 117 - cp -r resources/ $out/share/redisinsight 118 119 # icons 120 - for icon in "$out/resources/icons/*.png"; do 121 mkdir -p "$out/share/icons/hicolor/$(basename $icon .png)/apps" 122 ln -s "$icon" "$out/share/icons/hicolor/$(basename $icon .png)/apps/redisinsight.png" 123 done 124 125 - ln -s "${finalAttrs.desktopItem}/share/applications" "$out/share/applications" 126 - 127 makeWrapper '${electron}/bin/electron' "$out/bin/redisinsight" \ 128 - --add-flags "$out/share/redisinsight/app.asar" \ 129 --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \ 130 - --chdir "$out/share/redisinsight" \ 131 - --argv0 "$out/share/redisinsight/app.asar" 132 133 runHook postInstall 134 ''; 135 136 - desktopItem = makeDesktopItem { 137 - name = "redisinsight"; 138 - exec = "redisinsight %u"; 139 - icon = "redisinsight"; 140 - desktopName = "RedisInsight"; 141 - genericName = "RedisInsight Redis Client"; 142 - comment = finalAttrs.meta.description; 143 - categories = [ "Development" ]; 144 - startupWMClass = "redisinsight"; 145 - }; 146 147 - meta = with lib; { 148 description = "RedisInsight Redis client powered by Electron"; 149 homepage = "https://github.com/RedisInsight/RedisInsight"; 150 - license = licenses.sspl; 151 - maintainers = with maintainers; [ gmemstr ]; 152 - platforms = [ "x86_64-linux" ]; 153 }; 154 })
··· 1 + { 2 + lib, 3 + stdenv, 4 + fetchFromGitHub, 5 + makeWrapper, 6 + makeDesktopItem, 7 + copyDesktopItems, 8 + fixup-yarn-lock, 9 + yarn, 10 + nodejs_18, 11 + python3, 12 + fetchYarnDeps, 13 + electron, 14 + nest-cli, 15 + libsass, 16 + buildPackages, 17 + pkg-config, 18 + sqlite, 19 + xdg-utils, 20 }: 21 + 22 let 23 nodejs = nodejs_18; 24 in 25 stdenv.mkDerivation (finalAttrs: { 26 + pname = "redisinsight"; 27 version = "2.32"; 28 29 src = fetchFromGitHub { 30 owner = "RedisInsight"; 31 repo = "RedisInsight"; 32 + rev = finalAttrs.version; 33 hash = "sha256-esaH10AyEooym/62F5LJL7oP5UmD6T2UX8g/9QniL9s="; 34 }; 35 36 offlineCache = fetchYarnDeps { 37 yarnLock = finalAttrs.src + "/yarn.lock"; 38 + hash = "sha256-NHKttywAaWAYkciGzYCnm1speHrWsv1t+dxL1DZgM7o="; 39 }; 40 41 feOfflineCache = fetchYarnDeps { 42 yarnLock = finalAttrs.src + "/redisinsight/yarn.lock"; 43 + hash = "sha256-1S1KNUOtmywQ0eyqVS2oRlhpjcL9eps8CR7AtC9ujSU="; 44 }; 45 46 apiOfflineCache = fetchYarnDeps { 47 yarnLock = finalAttrs.src + "/redisinsight/api/yarn.lock"; 48 + hash = "sha256-P99+1Dhdg/vznC2KepPrVGNlrofJFydXkZVxgwprIx4="; 49 }; 50 51 + nativeBuildInputs = [ 52 + yarn 53 + fixup-yarn-lock 54 + nodejs 55 + makeWrapper 56 + python3 57 + nest-cli 58 + libsass 59 + pkg-config 60 + copyDesktopItems 61 + ]; 62 63 + buildInputs = [ 64 + sqlite 65 + xdg-utils 66 + ]; 67 68 configurePhase = '' 69 runHook preConfigure 70 71 export HOME=$(mktemp -d) 72 + yarn config --offline set yarn-offline-mirror ${finalAttrs.offlineCache} 73 + fixup-yarn-lock yarn.lock 74 yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive 75 76 + yarn config --offline set yarn-offline-mirror ${finalAttrs.feOfflineCache} 77 + fixup-yarn-lock redisinsight/yarn.lock 78 yarn --offline --cwd redisinsight/ --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive 79 80 + yarn config --offline set yarn-offline-mirror ${finalAttrs.apiOfflineCache} 81 + fixup-yarn-lock redisinsight/api/yarn.lock 82 yarn --offline --cwd redisinsight/api/ --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive 83 84 patchShebangs node_modules/ ··· 90 ln -sfv "${nodejs}/include" "$HOME/.node-gyp/${nodejs.version}" 91 export npm_config_nodedir=${nodejs} 92 93 # Build the sqlite3 package. 94 + pushd redisinsight 95 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 96 popd 97 98 + # Build node-sass 99 + LIBSASS_EXT=auto npm rebuild --verbose node-sass 100 + 101 substituteInPlace redisinsight/api/config/default.ts \ 102 + --replace-fail "process['resourcesPath']" "\"$out/share/redisinsight\"" \ 103 + 104 + # has irrelevant files 105 + rm -r resources/app 106 107 runHook postConfigure 108 ''; 109 110 buildPhase = '' 111 runHook preBuild 112 113 + yarn config --offline set yarn-offline-mirror ${finalAttrs.offlineCache} 114 115 yarn --offline build:prod 116 117 yarn --offline electron-builder \ 118 + --dir \ 119 -c.electronDist=${electron}/libexec/electron \ 120 -c.electronVersion=${electron.version} 121 ··· 125 installPhase = '' 126 runHook preInstall 127 128 + mkdir -p "$out/share/redisinsight"/{app,defaults,static/plugins,static/resources/plugins} 129 130 + cp -r release/*-unpacked/{locales,resources{,.pak}} "$out/share/redisinsight/app" 131 + mv "$out/share/redisinsight/app/resources/resources" "$out/share/redisinsight" 132 133 # icons 134 + for icon in "$out/share/redisinsight/resources/icons"/*.png; do 135 mkdir -p "$out/share/icons/hicolor/$(basename $icon .png)/apps" 136 ln -s "$icon" "$out/share/icons/hicolor/$(basename $icon .png)/apps/redisinsight.png" 137 done 138 139 makeWrapper '${electron}/bin/electron' "$out/bin/redisinsight" \ 140 + --add-flags "$out/share/redisinsight/app/resources/app.asar" \ 141 --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \ 142 + --set-default ELECTRON_FORCE_IS_PACKAGED 1 \ 143 + --inherit-argv0 144 145 runHook postInstall 146 ''; 147 148 + desktopItems = [ 149 + (makeDesktopItem { 150 + name = "redisinsight"; 151 + exec = "redisinsight %u"; 152 + icon = "redisinsight"; 153 + desktopName = "RedisInsight"; 154 + genericName = "RedisInsight Redis Client"; 155 + comment = finalAttrs.meta.description; 156 + categories = [ "Development" ]; 157 + startupWMClass = "redisinsight"; 158 + }) 159 + ]; 160 161 + meta = { 162 description = "RedisInsight Redis client powered by Electron"; 163 homepage = "https://github.com/RedisInsight/RedisInsight"; 164 + #license = licenses.sspl; 165 + maintainers = with lib.maintainers; [ 166 + gmemstr 167 + tomasajt 168 + ]; 169 + platforms = lib.platforms.linux; 170 }; 171 })