2023-11-19 20:12:05 +00:00
|
|
|
{ depot
|
|
|
|
, fetchFromGitLab
|
2021-12-20 21:05:51 +00:00
|
|
|
, pkgs
|
2021-12-21 19:39:11 +00:00
|
|
|
, lib
|
2021-12-20 21:05:51 +00:00
|
|
|
, stdenv
|
|
|
|
, makeWrapper
|
2024-08-04 17:51:12 +00:00
|
|
|
, python311
|
2023-05-28 00:28:20 +00:00
|
|
|
, nodejs-18_x
|
2021-12-21 19:39:11 +00:00
|
|
|
, ossOnly ? true
|
2021-12-20 21:05:51 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2024-08-04 17:51:12 +00:00
|
|
|
python3 = python311;
|
2023-05-11 10:27:38 +00:00
|
|
|
version = "1.16.0";
|
2021-12-21 19:39:11 +00:00
|
|
|
suffix = lib.optionalString ossOnly "-oss";
|
|
|
|
src' = fetchFromGitLab {
|
2023-05-11 11:09:49 +00:00
|
|
|
owner = "baserow";
|
2021-12-20 21:05:51 +00:00
|
|
|
repo = "baserow";
|
2021-12-21 19:23:53 +00:00
|
|
|
rev = version;
|
2023-05-11 10:27:38 +00:00
|
|
|
sha256 = "02ij94cqk5f0lsy8qiz0zrm9087swji9lxqbzy64jf1drqsdjj7a";
|
2021-12-20 21:05:51 +00:00
|
|
|
};
|
2021-12-21 19:39:11 +00:00
|
|
|
src = if ossOnly then pkgs.runCommand "${src'.name}${suffix}" {} ''
|
|
|
|
cp -R ${src'} $out
|
|
|
|
chmod -R u+w $out
|
|
|
|
rm -rf $out/premium
|
2023-01-14 21:26:29 +00:00
|
|
|
rm -rf $out/enterprise
|
2021-12-21 19:39:11 +00:00
|
|
|
|
2023-01-14 21:26:29 +00:00
|
|
|
sed -i -e '/baserow_premium/d' -e '/baserow_enterprise/d' $out/backend/src/baserow/config/settings/base.py
|
|
|
|
sed -i -e '/premium/d' -e '/enterprise/d' $out/web-frontend/config/nuxt.config.base.js
|
2021-12-21 19:39:11 +00:00
|
|
|
'' else src';
|
2021-12-20 21:05:51 +00:00
|
|
|
web-frontend-deps = import ./web-frontend {
|
|
|
|
inherit pkgs nodejs;
|
|
|
|
inherit (pkgs) system;
|
|
|
|
src = "${src}/web-frontend";
|
|
|
|
};
|
2021-12-21 00:18:16 +00:00
|
|
|
|
2023-05-28 00:28:20 +00:00
|
|
|
nodejs = nodejs-18_x;
|
2023-11-19 20:12:05 +00:00
|
|
|
inherit (depot.third_party) poetry2nix;
|
2023-04-02 01:20:15 +00:00
|
|
|
poetry2nixOverrides = poetry2nix.defaultPoetryOverrides.overrideOverlay (self: super: let
|
|
|
|
addBuildInputs = f: buildInputs: f.overridePythonAttrs (old: {
|
|
|
|
buildInputs = (old.buildInputs or []) ++ buildInputs;
|
|
|
|
});
|
|
|
|
in {
|
|
|
|
kombu = let
|
|
|
|
kombuVersion = "5.2.4";
|
|
|
|
in assert lib.assertMsg (super.kombu.version == kombuVersion) "kombu (${super.kombu.version}) is different version to what I expected (${kombuVersion}); maybe remove the override?"; super.kombu.overridePythonAttrs (old: {
|
|
|
|
buildInputs = (old.buildInputs or []) ++ [ self.setuptools ];
|
|
|
|
postPatch = ''
|
|
|
|
${old.postPatch or ""}
|
|
|
|
substituteInPlace requirements/test.txt --replace "pytz>dev" "pytz"
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
opentelemetry-instrumentation-aiohttp = addBuildInputs super.opentelemetry-instrumentation-aiohttp [ self.hatchling ];
|
|
|
|
opentelemetry-instrumentation-aiohttp-client = addBuildInputs super.opentelemetry-instrumentation-aiohttp-client [ self.hatchling ];
|
|
|
|
opentelemetry-instrumentation-botocore = addBuildInputs super.opentelemetry-instrumentation-botocore [ self.hatchling ];
|
|
|
|
opentelemetry-instrumentation-celery = addBuildInputs super.opentelemetry-instrumentation-celery [ self.hatchling ];
|
|
|
|
opentelemetry-instrumentation-dbapi = addBuildInputs super.opentelemetry-instrumentation-dbapi [ self.hatchling ];
|
|
|
|
opentelemetry-instrumentation-django = addBuildInputs super.opentelemetry-instrumentation-django [ self.hatchling ];
|
|
|
|
opentelemetry-instrumentation-grpc = addBuildInputs super.opentelemetry-instrumentation-grpc [ self.hatchling ];
|
|
|
|
opentelemetry-instrumentation-logging = addBuildInputs super.opentelemetry-instrumentation-logging [ self.hatchling ];
|
|
|
|
opentelemetry-instrumentation-psycopg2 = addBuildInputs super.opentelemetry-instrumentation-psycopg2 [ self.hatchling ];
|
|
|
|
opentelemetry-instrumentation-redis = addBuildInputs super.opentelemetry-instrumentation-redis [ self.hatchling ];
|
|
|
|
opentelemetry-instrumentation-requests = addBuildInputs super.opentelemetry-instrumentation-requests [ self.hatchling ];
|
|
|
|
opentelemetry-instrumentation-wsgi = addBuildInputs super.opentelemetry-instrumentation-wsgi [ self.hatchling ];
|
|
|
|
django-health-check = addBuildInputs super.django-health-check [ self.sphinx self.setuptools-scm ];
|
|
|
|
pysaml2 = addBuildInputs super.pysaml2 [ self.poetry-core ];
|
2024-04-26 17:02:05 +00:00
|
|
|
cython = python3.pkgs.cython_0;
|
|
|
|
pystemmer = addBuildInputs super.pystemmer [ self.cython ];
|
2023-04-02 01:20:15 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
mkBackendSrc = { type, fromDir, pyproject, poetrylock, extra ? "" }: pkgs.runCommand "baserow-${type}-src" {
|
|
|
|
inherit src pyproject poetrylock fromDir;
|
|
|
|
} ''
|
|
|
|
cp -r $src/$fromDir $out
|
|
|
|
chmod -R +w $out
|
|
|
|
|
|
|
|
cp $pyproject $out/pyproject.toml
|
|
|
|
cp $poetrylock $out/poetry.lock
|
|
|
|
cp $src/README.md $out
|
|
|
|
rm $out/setup.py
|
|
|
|
${extra}
|
|
|
|
'';
|
|
|
|
mkBackendApp = {
|
|
|
|
type, fromDir, pyproject, poetrylock, srcExtra ? "", postInstall ? ""
|
|
|
|
}: let
|
|
|
|
src = mkBackendSrc { inherit type fromDir pyproject poetrylock; extra = srcExtra; };
|
|
|
|
in poetry2nix.mkPoetryApplication {
|
|
|
|
projectDir = src;
|
|
|
|
inherit pyproject poetrylock postInstall;
|
|
|
|
overrides = poetry2nixOverrides;
|
|
|
|
python = python3;
|
|
|
|
passthru.src = src;
|
|
|
|
};
|
|
|
|
|
|
|
|
templates = pkgs.runCommand "baserow-templates" {
|
|
|
|
inherit src;
|
|
|
|
} ''
|
|
|
|
cp -r "$src/backend/templates" $out
|
|
|
|
'';
|
|
|
|
backendApp = mkBackendApp {
|
|
|
|
type = "backend";
|
|
|
|
fromDir = "backend";
|
|
|
|
pyproject = ./backend/pyproject.toml;
|
|
|
|
poetrylock = ./backend/poetry.lock;
|
|
|
|
srcExtra = ''
|
|
|
|
substituteInPlace "$out/src/baserow/config/settings/base.py" \
|
|
|
|
--replace 'APPLICATION_TEMPLATES_DIR = os.path.join(BASE_DIR, "../../../templates")' "APPLICATION_TEMPLATES_DIR = '${templates}'"
|
|
|
|
'';
|
|
|
|
postInstall = ''
|
|
|
|
install -m 0755 ${./backend/gunicorn.py} $out/bin/baserow-gunicorn
|
|
|
|
install -m 0755 ${./backend/celery.py} $out/bin/baserow-celery
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
premiumBackendApp = mkBackendApp {
|
|
|
|
type = "premium-backend";
|
|
|
|
fromDir = "premium/backend";
|
|
|
|
pyproject = ./premium-backend/pyproject.toml;
|
|
|
|
poetrylock = ./premium-backend/poetry.lock;
|
2021-12-21 00:18:16 +00:00
|
|
|
};
|
2023-04-02 01:20:15 +00:00
|
|
|
enterpriseBackendApp = mkBackendApp {
|
|
|
|
type = "enterprise-backend";
|
|
|
|
fromDir = "enterprise/backend";
|
|
|
|
pyproject = ./enterprise-backend/pyproject.toml;
|
|
|
|
poetrylock = ./enterprise-backend/poetry.lock;
|
|
|
|
};
|
|
|
|
backendEnv = backendApp.python.buildEnv.override (old: {
|
|
|
|
extraLibs = [ backendApp ] ++ lib.optionals (!ossOnly) [ premiumBackendApp enterpriseBackendApp ];
|
|
|
|
});
|
2021-12-21 00:18:16 +00:00
|
|
|
in
|
|
|
|
{
|
2023-04-02 01:20:15 +00:00
|
|
|
inherit src web-frontend-deps;
|
2021-12-20 21:05:51 +00:00
|
|
|
|
|
|
|
web-frontend = stdenv.mkDerivation {
|
2021-12-21 19:39:11 +00:00
|
|
|
name = "baserow${suffix}-web-frontend";
|
2021-12-21 19:23:53 +00:00
|
|
|
inherit src version;
|
2021-12-20 21:05:51 +00:00
|
|
|
buildInputs = [ nodejs ];
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
nodeDependencies = web-frontend-deps.shell.nodeDependencies;
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
outpath="$out/share/baserow"
|
2021-12-21 19:39:11 +00:00
|
|
|
mkdir -p $outpath
|
2021-12-20 21:05:51 +00:00
|
|
|
cp -R web-frontend $outpath/web-frontend
|
2021-12-21 19:39:11 +00:00
|
|
|
|
|
|
|
${lib.optionalString (!ossOnly) ''
|
|
|
|
mkdir -p $outpath/premium
|
|
|
|
cp -R premium/web-frontend $outpath/premium/web-frontend
|
2023-01-14 21:26:29 +00:00
|
|
|
|
|
|
|
mkdir -p $outpath/enterprise
|
|
|
|
cp -R enterprise/web-frontend $outpath/enterprise/web-frontend
|
2021-12-21 19:39:11 +00:00
|
|
|
''}
|
2021-12-20 21:05:51 +00:00
|
|
|
|
|
|
|
# Disable prompts
|
|
|
|
export MINIMAL=true
|
2022-11-09 00:35:09 +00:00
|
|
|
export NODE_OPTIONS=--openssl-legacy-provider
|
2021-12-20 21:05:51 +00:00
|
|
|
|
|
|
|
pushd $outpath/web-frontend
|
|
|
|
mkdir node_modules
|
|
|
|
for f in $nodeDependencies/lib/node_modules/*; do
|
|
|
|
ln -s "$f" ./node_modules
|
|
|
|
done
|
|
|
|
export PATH="$nodeDependencies/bin:$PATH"
|
|
|
|
./node_modules/nuxt/bin/nuxt.js build --config-file config/nuxt.config.local.js
|
|
|
|
popd
|
|
|
|
|
|
|
|
mkdir $out/bin
|
|
|
|
makeWrapper $nodeDependencies/lib/node_modules/nuxt/bin/nuxt.js $out/bin/baserow-web-frontend \
|
|
|
|
--run "cd $outpath/web-frontend" \
|
|
|
|
--add-flags "start --config-file config/nuxt.config.local.js"
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
dontInstall = true;
|
|
|
|
};
|
2021-12-21 00:18:16 +00:00
|
|
|
|
2023-04-02 01:20:15 +00:00
|
|
|
backend = backendEnv;
|
2021-12-20 21:05:51 +00:00
|
|
|
}
|