-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
baserow: 1.14.0 -> 1.28.0, baserow-front: init at 1.28.0, nixos/baserow: init, nixos/tests/baserow: init #324777
Draft
onny
wants to merge
8
commits into
NixOS:master
Choose a base branch
from
onny:baserow-update2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+953
−14
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e3fb1f5
baserow: 1.14.0 -> 1.28.0
onny 2c70d38
baserow.frontend: init at 1.28.0
JulienMalka 44bcef9
nixos/web-apps/baserow: init
RaitoBezarius da71989
nixos/tests/web-apps/baserow: init
RaitoBezarius 5539ed6
baserow package
onny 4f25252
FIXME: disable moto checks
onny 5277c5a
FIXME check fail with django 5
onny f95a071
nodejs21
onny File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,254 @@ | ||
{ lib, pkgs, config, ... }: | ||
# TODO: OTEL stuff | ||
let | ||
inherit (lib) mkIf mkOption mkEnableOption mkPackageOptionMD mkDefault mdDoc concatStringsSep mapAttrsToList; | ||
cfg = config.services.baserow; | ||
penv = cfg.package.python.buildEnv.override { | ||
extraLibs = [ | ||
(cfg.package.python.pkgs.toPythonModule cfg.package) | ||
]; | ||
}; | ||
ui = cfg.package.ui; | ||
pythonPath = "${penv}/${cfg.package.python.sitePackages}/"; | ||
defaultEnvironment = cfg.environment // { | ||
PYTHONPATH = pythonPath; | ||
}; | ||
<<<<<<< HEAD | ||
======= | ||
templateNuxtProdConfig = pkgs.writeText "nuxt.config.prod.js.in" '' | ||
import base from './nuxt.config.base.js'; | ||
|
||
export default base( | ||
@baseModules@, | ||
@premiumModules@, | ||
@enterpriseModules@ | ||
) | ||
''; | ||
environmentAsFile = pkgs.writeText "baserow-environment" (concatStringsSep "\n" | ||
(mapAttrsToList (key: value: "${key}=\"${toString value}\"") cfg.environment)); | ||
# TODO: handle env file and secrets. | ||
baserowManageScript = pkgs.writeShellScriptBin "baserow-manage" '' | ||
set -a | ||
export PYTHONPATH=${cfg.package.pythonPath} | ||
source ${cfg.secretFile} | ||
source ${environmentAsFile} | ||
sudo=exec | ||
if [[ "$USER" != baserow ]]; then | ||
sudo='exec /run/wrappers/bin/sudo -u baserow --preserve-env' | ||
fi | ||
$sudo ${cfg.package}/bin/baserow "$@" | ||
''; | ||
in | ||
{ | ||
options.services.baserow = { | ||
enable = mkEnableOption (mdDoc "baserow, you need to provide your own reverse proxy server"); | ||
package = mkPackageOptionMD pkgs "baserow" {}; | ||
|
||
listenAddress = mkOption { | ||
type = lib.types.str; | ||
default = "[::1]"; | ||
description = lib.mdDoc '' | ||
Address the server will listen on. | ||
''; | ||
}; | ||
|
||
port = mkOption { | ||
type = lib.types.port; | ||
default = 8000; | ||
description = lib.mdDoc '' | ||
Port the server will listen on. | ||
''; | ||
}; | ||
|
||
environment = mkOption { | ||
type = lib.types.submodule { | ||
freeformType = with lib.types; attrsOf (oneOf [ int str path ]); | ||
}; | ||
default = {}; | ||
description = "Environment variables passed to Baserow, use this to configure the service."; | ||
}; | ||
secretFile = mkOption { | ||
default = null; | ||
type = lib.types.nullOr lib.types.path; | ||
description = "Secrets that should not end up in the Nix store."; | ||
}; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
services.baserow.environment = { | ||
DATABASE_URL = mkDefault "postgresql:///baserow"; | ||
REDIS_URL = mkDefault "redis+socket://${config.services.redis.servers.baserow.unixSocket}"; | ||
REDIS_BEAT_URL = mkDefault "unix://${config.services.redis.servers.baserow.unixSocket}"; | ||
DJANGO_REDIS_URL = mkDefault "unix://${config.services.redis.servers.baserow.unixSocket}"; | ||
DJANGO_CHANNEL_REDIS_URL = mkDefault "unix://${config.services.redis.servers.baserow.unixSocket}"; | ||
DJANGO_SETTINGS_MODULE = mkDefault "baserow.config.settings.base"; | ||
BASEROW_TRIGGER_SYNC_TEMPLATES_AFTER_MIGRATION = mkDefault "false"; | ||
NUXT_TELEMETRY_DISABLED = mkDefault "1"; | ||
}; | ||
|
||
services.redis.servers.baserow.enable = true; | ||
services.postgresql = { | ||
enable = true; | ||
ensureDatabases = [ "baserow" ]; | ||
ensureUsers = [ | ||
{ | ||
name = "baserow"; | ||
ensurePermissions."DATABASE baserow" = "ALL PRIVILEGES"; | ||
} | ||
]; | ||
}; | ||
|
||
environment.systemPackages = [ baserowManageScript ]; | ||
systemd.targets.baserow = { | ||
description = "Target for all Baserow services"; | ||
wantedBy = [ "multi-user.target" ]; | ||
after = [ "network-online.target" "redis-baserow.service" ]; | ||
}; | ||
|
||
systemd.services = | ||
let | ||
defaultServiceConfig = { | ||
WorkingDirectory = "/var/lib/baserow"; | ||
User = "baserow"; | ||
Group = "baserow"; | ||
StateDirectory = "baserow"; | ||
StateDirectoryMode = "0750"; | ||
Restart = "on-failure"; | ||
|
||
EnvironmentFile = mkIf (cfg.secretFile != null) [ cfg.secretFile ]; | ||
}; | ||
in | ||
{ | ||
baserow-prepare = { | ||
description = "Baserow migrations & misc service"; | ||
wantedBy = [ "baserow.target" ]; | ||
after = [ "postgresql.service" ]; | ||
|
||
environment = defaultEnvironment; | ||
path = [ baserowManageScript ]; | ||
|
||
serviceConfig = defaultServiceConfig // { | ||
Type = "oneshot"; | ||
ExecStart = '' | ||
${baserowManageScript}/bin/baserow-manage migrate | ||
${baserowManageScript}/bin/baserow-manage sync_templates | ||
''; | ||
}; | ||
}; | ||
baserow-nuxt = { | ||
description = "Baserow Nuxt service (frontend)"; | ||
wantedBy = [ "baserow.target" ]; | ||
requires = [ "baserow-prepare.service" ]; | ||
after = [ "baserow-prepare.service" ]; | ||
|
||
environment = defaultEnvironment // { | ||
NODE_MODULES = "${ui}/node_modules"; | ||
NODE_OPTIONS = "--openssl-legacy-provider"; | ||
}; | ||
|
||
preStart = '' | ||
ln -sf ${ui}/.nuxt /var/lib/baserow/.nuxt | ||
''; | ||
|
||
serviceConfig = defaultServiceConfig // { | ||
WorkingDirectory = "/var/lib/baserow"; | ||
# https://github.com/nuxt/nuxt/issues/20714 | ||
ExecStart = '' | ||
${ui}/node_modules/.bin/nuxt start | ||
======= | ||
NODE_OPTIONS = "--openssl-legacy-provider --dns-result-order=verbatim"; | ||
}; | ||
|
||
preStart = '' | ||
ln -sf ${ui}/web-frontend/.nuxt /var/lib/baserow/frontend/ | ||
ln -sf ${ui}/premium /var/lib/baserow/ | ||
ln -sf ${ui}/enterprise /var/lib/baserow/ | ||
ln -sf ${ui}/web-frontend/modules /var/lib/baserow/frontend/ | ||
mkdir -p /var/lib/baserow/frontend/config | ||
${pkgs.xorg.lndir}/bin/lndir -ignorelinks ${ui}/web-frontend/config /var/lib/baserow/frontend/config | ||
ln -sf ${(pkgs.substituteAll { | ||
src = templateNuxtProdConfig; | ||
baseImport = "${ui}/web-frontend/config/nuxt.config.base.js"; | ||
baseModules = "${ui}/web-frontend"; | ||
premiumModules = "${ui}/premium/web-frontend"; | ||
enterpriseModules = "${ui}/enterprise/web-frontend"; | ||
})} /var/lib/baserow/frontend/config/nuxt.config.prod.js | ||
''; | ||
|
||
serviceConfig = defaultServiceConfig // { | ||
WorkingDirectory = "/var/lib/baserow/frontend"; | ||
StateDirectory = [ "baserow" "baserow/frontend" ]; | ||
# https://github.com/nuxt/nuxt/issues/20714 | ||
ExecStart = '' | ||
${ui}/web-frontend/node_modules/.bin/nuxt start --config-file config/nuxt.config.local.js | ||
>>>>>>> e3b5d8d20811 (nixos module) | ||
''; | ||
}; | ||
}; | ||
baserow-wsgi = { | ||
description = "Baserow WSGI service (backend)"; | ||
wantedBy = [ "baserow.target" ]; | ||
requires = [ "baserow-prepare.service" ]; | ||
after = [ "baserow-prepare.service" ]; | ||
|
||
environment = defaultEnvironment; | ||
|
||
# On worker temp dir: https://github.com/bram2w/baserow/blob/master/backend/docker/docker-entrypoint.sh#L205C12-L206 | ||
serviceConfig = defaultServiceConfig // { | ||
RuntimeDirectory = "baserow"; | ||
ExecStart = '' | ||
${cfg.package.python.pkgs.gunicorn}/bin/gunicorn \ | ||
-k uvicorn.workers.UvicornWorker \ | ||
baserow.config.asgi:application \ | ||
--worker-tmp-dir=/run/baserow \ | ||
--log-file=- \ | ||
--access-logfile=- \ | ||
--capture-output \ | ||
--bind ${cfg.listenAddress}:${toString cfg.port} \ | ||
''; | ||
}; | ||
}; | ||
baserow-celery-worker = { | ||
description = "Baserow Celery workers service"; | ||
wantedBy = [ "baserow.target" ]; | ||
requires = [ "baserow-wsgi.service" ]; | ||
after = [ "baserow-wsgi.service" ]; | ||
|
||
environment = defaultEnvironment; | ||
|
||
serviceConfig = defaultServiceConfig // { | ||
ExecStart = '' | ||
${cfg.package.python.pkgs.celery}/bin/celery -A baserow worker \ | ||
-l INFO \ | ||
-Q celery,export \ | ||
-n "default-worker@%h" | ||
''; | ||
}; | ||
}; | ||
# baserow-celery-exportworker = {}; | ||
baserow-celery-beat = { | ||
description = "Baserow scheduler service"; | ||
wantedBy = [ "baserow.target" ]; | ||
requires = [ "baserow-celery-worker.service" ]; | ||
after = [ "baserow-celery-worker.service" ]; | ||
|
||
environment = defaultEnvironment; | ||
|
||
serviceConfig = defaultServiceConfig // { | ||
ExecStart = '' | ||
${cfg.package.python.pkgs.celery}/bin/celery -A baserow beat \ | ||
-l INFO \ | ||
-S redbeat.RedBeatScheduler | ||
''; | ||
}; | ||
}; | ||
}; | ||
|
||
users.users.baserow = { | ||
isSystemUser = true; | ||
group = "baserow"; | ||
}; | ||
users.groups.baserow = {}; | ||
users.groups."${config.services.redis.servers.baserow.user}".members = [ "baserow" ]; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import ../make-test-python.nix ({ lib, pkgs, ... }: { | ||
name = "baserow"; | ||
|
||
meta = with lib.maintainers; { | ||
maintainers = [ raitobezarius julienmalka ]; | ||
}; | ||
|
||
nodes.machine = { ... }: { | ||
services.baserow = { | ||
enable = true; | ||
environment = { | ||
# Needed for the frontend. | ||
PUBLIC_BACKEND_URL = "http://localhost/api/"; | ||
BASEROW_DISABLE_PUBLIC_URL_CHECK = "1"; | ||
PRIVATE_BACKEND_URL = "http://[::1]:8000"; | ||
BASEROW_PUBLIC_URL = "http://localhost"; | ||
BASEROW_BACKEND_DEBUG = "on"; | ||
BASEROW_BACKEND_LOG_LEVEL = "DEBUG"; | ||
# Ensure we are allowed to do those requests. | ||
BASEROW_EXTRA_ALLOWED_HOSTS = "localhost,[::1],127.0.0.1"; | ||
}; | ||
# Do not do this in production. | ||
secretFile = pkgs.writeText "secret" '' | ||
SECRET_KEY=aaaaaaaaaaaaaaaaaaaaaaaa | ||
''; | ||
}; | ||
|
||
services.nginx = { | ||
enable = true; | ||
recommendedProxySettings = true; | ||
virtualHosts."localhost" = { | ||
locations."~ ^/(api|ws)/" = { | ||
proxyPass = "http://[::1]:8000"; | ||
proxyWebsockets = true; | ||
}; | ||
locations."/media/" = { | ||
extraConfig = '' | ||
if ($arg_dl) { | ||
add_header Content-disposition "attachment; filename=$arg_dl"; | ||
} | ||
alias /var/lib/baserow/media; | ||
''; | ||
}; | ||
locations."/" = { | ||
proxyPass = "http://[::1]:3000"; | ||
}; | ||
}; | ||
}; | ||
}; | ||
|
||
testScript = { nodes }: '' | ||
machine.start() | ||
machine.wait_for_unit("baserow.target") | ||
machine.wait_for_open_port(8000) | ||
|
||
print(machine.succeed( | ||
"curl -H 'Host: localhost' -sSfL http://[::1]:8000/api/settings/" | ||
)) | ||
# [::1] is not an allowed host. | ||
machine.fail( | ||
"curl -sSfL http://[::1]:8000/api/settings/" | ||
) | ||
machine.wait_for_unit("nginx.service") | ||
machine.wait_for_open_port(80) | ||
|
||
# Backend | ||
print(machine.succeed( | ||
"curl -sSfL http://localhost/api/_health/" | ||
)) | ||
|
||
# Frontend | ||
machine.wait_for_unit("baserow-nuxt.service") | ||
machine.wait_for_open_port(3000) | ||
# Test connection to backend through frontend | ||
print(machine.succeed( | ||
"curl -sSfL http://localhost/login/" | ||
)) | ||
print(machine.succeed( | ||
"curl -sSfL http://localhost/_health/" | ||
)) | ||
''; | ||
}) |
26 changes: 26 additions & 0 deletions
26
pkgs/by-name/ba/baserow/0001-backend-package-HTML-templates.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
From d30489f46fec68ee2ddd369963fe22ed37999d81 Mon Sep 17 00:00:00 2001 | ||
From: Raito Bezarius <[email protected]> | ||
Date: Mon, 8 May 2023 07:44:16 +0200 | ||
Subject: [PATCH] backend: package HTML templates | ||
|
||
--- | ||
setup.py | 3 +++ | ||
1 file changed, 3 insertions(+) | ||
|
||
diff --git a/setup.py b/setup.py | ||
index 0309d164..bee79602 100644 | ||
--- a/setup.py | ||
+++ b/setup.py | ||
@@ -30,6 +30,9 @@ setup( | ||
"technical expertise. Build a table and define custom fields " | ||
"like text, number, file and many more.", | ||
platforms=["linux"], | ||
+ package_data={ | ||
+ 'baserow.core': ['templates/*.html', 'templates/*.eta', 'templates/**/*.eta', 'templates/**/*.html'] | ||
+ }, | ||
package_dir={"": "src"}, | ||
packages=find_packages("src"), | ||
include_package_data=True, | ||
-- | ||
2.40.1 | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bad merge