Skip to content
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

weblate: sync module as far as possible with NixOS PR #331

Merged
merged 3 commits into from
Aug 13, 2024
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
56 changes: 44 additions & 12 deletions pkgs/by-name/weblate/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
stdenv,
lib,
fetchFromGitHub,
writeText,
poetry2nix,
python3,
pkg-config,
openssl,
isocodes,
Expand All @@ -12,11 +14,15 @@
postgresql,
leptonica,
tesseract,
gobject-introspection,
wrapGAppsNoGuiHook,
zlib,
pango,
harfbuzz,
librsvg,
gdk-pixbuf,
glib,
git,
}:
poetry2nix.mkPoetryApplication {
poetry2nix.mkPoetryApplication rec {
src = fetchFromGitHub {
owner = "WeblateOrg";
repo = "weblate";
Expand All @@ -27,21 +33,25 @@ poetry2nix.mkPoetryApplication {
pyproject = ./pyproject.toml;
poetrylock = ./poetry.lock;

outputs = [
"out"
"static"
];

patches = [
# FIXME This shouldn't be necessary and probably has to do with some dependency mismatch.
./cache.lock.patch
];

makeWrapperArgs = [
"\${gappsWrapperArgs[@]}"
];

nativeBuildInputs = [
wrapGAppsNoGuiHook
gobject-introspection
# We don't just use wrapGAppsNoGuiHook because we need to expose GI_TYPELIB_PATH
GI_TYPELIB_PATH = lib.makeSearchPathOutput "out" "lib/girepository-1.0" [
pango
harfbuzz
librsvg
gdk-pixbuf
glib
];

dontWrapGApps = true;
makeWrapperArgs = ["--set GI_TYPELIB_PATH \"$GI_TYPELIB_PATH\""];

overrides = poetry2nix.overrides.withDefaults (
self: super: {
Expand Down Expand Up @@ -153,6 +163,28 @@ poetry2nix.mkPoetryApplication {
}
);

nativeBuildInputs = [git];

# Build static files into a separate output
postBuild = let
staticSettings = writeText "static_settings.py" ''
STATIC_ROOT = os.environ["static"] + "/static"
COMPRESS_ENABLED = True
COMPRESS_OFFLINE = True
COMPRESS_ROOT = os.environ["static"] + "/compressor-cache"
# So we don't need postgres dependencies
DATABASES = {}
'';
in ''
mkdir $static
cat weblate/settings_example.py ${staticSettings} > weblate/settings_static.py
export DJANGO_SETTINGS_MODULE="weblate.settings_static"
${python3.pythonOnBuildForHost.interpreter} manage.py collectstatic --no-input
${python3.pythonOnBuildForHost.interpreter} manage.py compress
'';

passthru = {inherit GI_TYPELIB_PATH;};

meta = with lib; {
description = "Web based translation tool with tight version control integration";
homepage = "https://weblate.org/";
Expand Down
4 changes: 3 additions & 1 deletion projects/Weblate/examples/base.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@
# `weblate-generate-secret-key > django-secret` when run as the weblate user.
djangoSecretKeyFile = "/var/lib/weblate/django-secret";
smtp = {
# either use smtp.createLocally or specify a valid account on your mail provider.
enable = true;
# Specify a valid account and server for your mail provider.
user = "weblate@example.org";
host = "mail.example.org";
# Manually deployed secret
passwordFile = "/var/lib/weblate/smtp-password";
};
Expand Down
Loading