Skip to content

Commit

Permalink
weblate: sync module as far as possible with NixOS PR NixOS/nixpkgs#3…
Browse files Browse the repository at this point in the history
  • Loading branch information
erictapen committed Aug 12, 2024
1 parent 6c6af57 commit 19936ea
Show file tree
Hide file tree
Showing 4 changed files with 211 additions and 222 deletions.
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

0 comments on commit 19936ea

Please sign in to comment.