Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions apps/sources/insights.nix
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
pname = "insights";
version = "v3.0.24";
version = "v3.12.6";
meta = {
url = "https://github.com/frappe/insights/releases/tag/v3.0.24";
description = "Sources for insights (v3.0.24)";
url = "https://github.com/frappe/insights/releases/tag/v3.12.6";
description = "Sources for insights (v3.12.6)";
};
src = builtins.fetchTree {
type = "git";
url = "https://github.com/frappe/insights.git"; submodules = true; allRefs = true;
narHash = "sha256-5x+EbxPWlcGtUxqisHQA6LKiUqK9oDGY9DW0DBhoK90=";
rev = "406ac82e230e6ba84c67774530bd41001f680ed0";
narHash = "sha256-BmScDDfBG9eB9+7x9ev6fONlYU7z1rjkwMAccKsTUos=";
rev = "e2d4adcd192096c2ec89822c2decc452312a2a5d";
};
passthru = builtins.fromJSON ''{}'';
}
}
128 changes: 113 additions & 15 deletions src/overlays/frappe/insights.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,46 +6,144 @@
flit-core,
python,
extractFrappeMeta,
mkAssets,
applyPatches,
stdenv,
fetchYarnDeps,
nodejs,
yarnConfigHook,
}:
buildPythonPackage rec {
let
src = applyPatches {
inherit (appSources.insights) src;
name = "patched-insights";
};

version = appSources.insights.version;

frontend = stdenv.mkDerivation (finalAttrs: {
pname = "insights-frontend";
inherit version;

src = "${src}/frontend";

yarnOfflineCache = fetchYarnDeps {
yarnLock = "${finalAttrs.src}/yarn.lock";
hash = "sha256-XcrDeF1TKN33Njwqm/CC2x/ffqBevK2wdLIfgOw2ZDU=";
};

nativeBuildInputs = [
nodejs
yarnConfigHook
];

buildPhase = ''
runHook preBuild

substituteInPlace $TMP/frontend/vite.config.js --replace-fail "../insights/public/frontend" out/public/frontend

substituteInPlace $TMP/frontend/package.json --replace-fail "../insights/public/frontend" out/public/frontend
substituteInPlace $TMP/frontend/package.json --replace-fail "../insights/www" out/public/www

runHook postBuild
'';

installPhase = ''
runHook preInstall

mkdir -p out/public/frontend
mkdir -p out/public/www
mkdir $out

npm run build

cp -R out/* $out

runHook postInstall
'';
});

insights = stdenv.mkDerivation (finalAttrs: {
pname = "insights";
inherit version;

inherit src;

yarnOfflineCache = fetchYarnDeps {
yarnLock = "${finalAttrs.src}/yarn.lock";
hash = "sha256-oZgyP0hTU9bxszOVg3Bmiu6yos2d2Inc1Do8To4z8GQ=";
};

nativeBuildInputs = [
nodejs
yarnConfigHook
];

dontBuild = true;

installPhase = ''
runHook preInstall

mkdir -p $out/insights/www

cp -R insights/public $out/insights
cp -R insights/www $out/insights
cp -R node_modules $out/insights/public

cp -R ${frontend}/public/frontend $out/insights/public

cp -R ${frontend}/public/www/* $out/insights/www

runHook postInstall
'';
});
in
buildPythonPackage {
inherit
(extractFrappeMeta src)
pname
version
format
;

src = mkAssets (appSources.insights
// {
src = applyPatches {
inherit (appSources.insights) src;
name = "insights-prod";
patches = [
./insights-0001-build-socket-port-is-reverse-proxied.patch
];
};
});
src = stdenv.mkDerivation {
pname = "insights_";
inherit src version;
installPhase = ''
mkdir $out
cp -R . $out
cp -R ${insights}/insights/public/node_modules $out

cp -R ${insights}/insights/public/frontend $out/insights/public
cp -R ${insights}/insights/www/insights.html $out/insights/www/
cp -R ${insights}/insights/www/insights_v2.html $out/insights/www/
'';
};
inherit (appSources.insights) passthru;

nativeBuildInputs = [
pythonRelaxDepsHook
flit-core
];

propagatedBuildInputs = with python.pkgs; [
dependencies = with python.pkgs; [
duckdb
ibis-framework
pandas
psycopg
python-telegram-bot
sqlalchemy
sqlglot
];

pythonImportsCheck = ["insights"];

pythonRelaxDeps = [
"python-telegram-bot"
"SQLAlchemy"
"duckdb"
"ibis-framework"
"pandas"
"python-telegram-bot"
"sqlalchemy"
"sqlglot"
];

meta = with lib; {
Expand Down
Loading