nixpkgs/pkgs/development/tools/redisinsight/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

171 lines
4.8 KiB
Nix
Raw Normal View History

2024-04-28 13:21:12 +00:00
{
lib,
stdenv,
fetchFromGitHub,
makeWrapper,
makeDesktopItem,
copyDesktopItems,
fixup-yarn-lock,
yarn,
nodejs_18,
python3,
fetchYarnDeps,
electron,
nest-cli,
libsass,
buildPackages,
pkg-config,
sqlite,
xdg-utils,
2023-09-08 19:31:09 +00:00
}:
2024-04-28 13:21:12 +00:00
2023-09-08 19:31:09 +00:00
let
nodejs = nodejs_18;
in
stdenv.mkDerivation (finalAttrs: {
2024-04-28 13:21:12 +00:00
pname = "redisinsight";
2024-05-03 21:54:52 +00:00
version = "2.48.0";
2023-09-08 19:31:09 +00:00
src = fetchFromGitHub {
owner = "RedisInsight";
repo = "RedisInsight";
2024-04-28 13:21:12 +00:00
rev = finalAttrs.version;
2024-05-03 21:54:52 +00:00
hash = "sha256-ek0Fp8v6j+mZPK2cEuFNrBgInXdYIKBBUg0UD1I51Sg=";
2023-09-08 19:31:09 +00:00
};
offlineCache = fetchYarnDeps {
yarnLock = finalAttrs.src + "/yarn.lock";
2024-05-03 21:54:52 +00:00
hash = "sha256-ohtU1h6wrg7asXDxTt1Jlzx9GaS3zDrGQD9P9tgzCOE=";
2023-09-08 19:31:09 +00:00
};
feOfflineCache = fetchYarnDeps {
yarnLock = finalAttrs.src + "/redisinsight/yarn.lock";
2024-05-03 21:54:52 +00:00
hash = "sha256-9xbIdDeLUEk4eNeK7RTwidqDGinA8SPfcumqml66kTw=";
2023-09-08 19:31:09 +00:00
};
apiOfflineCache = fetchYarnDeps {
yarnLock = finalAttrs.src + "/redisinsight/api/yarn.lock";
2024-05-03 21:54:52 +00:00
hash = "sha256-4zbffuneTceMEyKb8atTXTFhTv0DhrsRMdepZWgoxMQ=";
2023-09-08 19:31:09 +00:00
};
2024-04-28 13:21:12 +00:00
nativeBuildInputs = [
yarn
fixup-yarn-lock
nodejs
makeWrapper
2024-08-19 17:59:42 +00:00
(python3.withPackages (ps: [ ps.setuptools ]))
2024-04-28 13:21:12 +00:00
nest-cli
libsass
pkg-config
copyDesktopItems
];
buildInputs = [
sqlite
xdg-utils
];
2023-09-08 19:31:09 +00:00
configurePhase = ''
runHook preConfigure
export HOME=$(mktemp -d)
2024-04-28 13:21:12 +00:00
yarn config --offline set yarn-offline-mirror ${finalAttrs.offlineCache}
fixup-yarn-lock yarn.lock
2023-09-08 19:31:09 +00:00
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
2024-04-28 13:21:12 +00:00
yarn config --offline set yarn-offline-mirror ${finalAttrs.feOfflineCache}
fixup-yarn-lock redisinsight/yarn.lock
2023-09-08 19:31:09 +00:00
yarn --offline --cwd redisinsight/ --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
2024-04-28 13:21:12 +00:00
yarn config --offline set yarn-offline-mirror ${finalAttrs.apiOfflineCache}
fixup-yarn-lock redisinsight/api/yarn.lock
2023-09-08 19:31:09 +00:00
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.
2024-04-28 13:21:12 +00:00
pushd redisinsight
2023-09-08 19:31:09 +00:00
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
2024-04-28 13:21:12 +00:00
# Build node-sass
LIBSASS_EXT=auto npm rebuild --verbose node-sass
2023-09-08 19:31:09 +00:00
substituteInPlace redisinsight/api/config/default.ts \
2024-04-28 13:21:12 +00:00
--replace-fail "process['resourcesPath']" "\"$out/share/redisinsight\"" \
# has irrelevant files
rm -r resources/app
2023-09-08 19:31:09 +00:00
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
2024-04-28 13:21:12 +00:00
yarn config --offline set yarn-offline-mirror ${finalAttrs.offlineCache}
2023-09-08 19:31:09 +00:00
yarn --offline build:prod
yarn --offline electron-builder \
2024-04-28 13:21:12 +00:00
--dir \
-c.electronDist=${electron}/libexec/electron \
2023-09-08 19:31:09 +00:00
-c.electronVersion=${electron.version}
runHook postBuild
'';
installPhase = ''
runHook preInstall
2024-04-28 13:21:12 +00:00
mkdir -p "$out/share/redisinsight"/{app,defaults,static/plugins,static/resources/plugins}
2023-09-08 19:31:09 +00:00
2024-04-28 13:21:12 +00:00
cp -r release/*-unpacked/{locales,resources{,.pak}} "$out/share/redisinsight/app"
mv "$out/share/redisinsight/app/resources/resources" "$out/share/redisinsight"
2023-09-08 19:31:09 +00:00
# icons
2024-04-28 13:21:12 +00:00
for icon in "$out/share/redisinsight/resources/icons"/*.png; do
2023-09-08 19:31:09 +00:00
mkdir -p "$out/share/icons/hicolor/$(basename $icon .png)/apps"
ln -s "$icon" "$out/share/icons/hicolor/$(basename $icon .png)/apps/redisinsight.png"
done
makeWrapper '${electron}/bin/electron' "$out/bin/redisinsight" \
2024-04-28 13:21:12 +00:00
--add-flags "$out/share/redisinsight/app/resources/app.asar" \
2023-09-08 19:31:09 +00:00
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
2024-04-28 13:21:12 +00:00
--set-default ELECTRON_FORCE_IS_PACKAGED 1 \
--inherit-argv0
2023-09-08 19:31:09 +00:00
runHook postInstall
'';
2024-04-28 13:21:12 +00:00
desktopItems = [
(makeDesktopItem {
name = "redisinsight";
exec = "redisinsight %u";
icon = "redisinsight";
desktopName = "RedisInsight";
genericName = "RedisInsight Redis Client";
comment = finalAttrs.meta.description;
categories = [ "Development" ];
startupWMClass = "redisinsight";
})
];
meta = {
2023-09-08 19:31:09 +00:00
description = "RedisInsight Redis client powered by Electron";
homepage = "https://github.com/RedisInsight/RedisInsight";
license = lib.licenses.sspl;
2024-04-28 13:21:12 +00:00
maintainers = with lib.maintainers; [
tomasajt
];
platforms = lib.platforms.linux;
2023-09-08 19:31:09 +00:00
};
})