nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 stdenv,
3 lib,
4 python3,
5 fetchFromGitHub,
6 nixosTests,
7 fetchYarnDeps,
8 nodejs,
9 yarnBuildHook,
10 yarnConfigHook,
11}:
12let
13 python = python3.override {
14 self = python3;
15 packageOverrides = self: super: {
16 django = super.django_5;
17 };
18 };
19
20 version = "4.4.0";
21 src = fetchFromGitHub {
22 owner = "suitenumerique";
23 repo = "docs";
24 tag = "v${version}";
25 hash = "sha256-Cm/Ch7dBKInQYPFGfSlSMLgj8uQR6E3S+6gCFUyvFSU=";
26 };
27
28 mail-templates = stdenv.mkDerivation {
29 name = "lasuite-docs-${version}-mjml";
30 inherit src;
31
32 sourceRoot = "source/src/mail";
33
34 env.DOCS_DIR_MAILS = "${placeholder "out"}";
35
36 offlineCache = fetchYarnDeps {
37 yarnLock = "${src}/src/mail/yarn.lock";
38 hash = "sha256-g71OGg0PAo60h0bC+oOyvLvPOCg0pYXuYD8vsR5X9/k=";
39 };
40
41 nativeBuildInputs = [
42 nodejs
43 yarnConfigHook
44 yarnBuildHook
45 ];
46
47 dontInstall = true;
48 };
49in
50
51python.pkgs.buildPythonApplication rec {
52 pname = "lasuite-docs";
53 pyproject = true;
54 inherit version src;
55
56 sourceRoot = "source/src/backend";
57
58 patches = [
59 # Support configuration throught environment variables for SECURE_*
60 ./secure_settings.patch
61 # Fix creation of unsafe C function in postgresql migrations
62 ./postgresql_fix.patch
63 ];
64
65 build-system = with python.pkgs; [ setuptools ];
66
67 dependencies =
68 with python.pkgs;
69 [
70 beautifulsoup4
71 boto3
72 celery
73 django
74 django-configurations
75 django-cors-headers
76 django-countries
77 django-csp
78 django-extensions
79 django-filter
80 django-lasuite
81 django-parler
82 django-redis
83 django-storages
84 django-timezone-field
85 django-treebeard
86 djangorestframework
87 drf-spectacular
88 drf-spectacular-sidecar
89 dockerflow
90 easy-thumbnails
91 factory-boy
92 gunicorn
93 jsonschema
94 langfuse
95 lxml
96 markdown
97 mozilla-django-oidc
98 nested-multipart-parser
99 openai
100 psycopg
101 pycrdt
102 pyjwt
103 pyopenssl
104 python-magic
105 redis
106 requests
107 sentry-sdk
108 whitenoise
109 ]
110 ++ celery.optional-dependencies.redis
111 ++ django-lasuite.optional-dependencies.all
112 ++ django-storages.optional-dependencies.s3;
113
114 pythonRelaxDeps = true;
115
116 postBuild = ''
117 export DATA_DIR=$(pwd)/data
118 ${python.pythonOnBuildForHost.interpreter} manage.py collectstatic --no-input --clear
119 '';
120
121 postInstall =
122 let
123 pythonPath = python.pkgs.makePythonPath dependencies;
124 in
125 ''
126 mkdir -p $out/{bin,share}
127
128 cp ./manage.py $out/bin/.manage.py
129 cp -r data/static $out/share
130 chmod +x $out/bin/.manage.py
131
132 makeWrapper $out/bin/.manage.py $out/bin/docs \
133 --prefix PYTHONPATH : "${pythonPath}"
134 makeWrapper ${lib.getExe python.pkgs.celery} $out/bin/celery \
135 --prefix PYTHONPATH : "${pythonPath}:$out/${python.sitePackages}"
136 makeWrapper ${lib.getExe python.pkgs.gunicorn} $out/bin/gunicorn \
137 --prefix PYTHONPATH : "${pythonPath}:$out/${python.sitePackages}"
138
139 mkdir -p $out/${python.sitePackages}/core/templates
140 ln -sv ${mail-templates}/ $out/${python.sitePackages}/core/templates/mail
141 '';
142
143 passthru.tests = {
144 login-and-create-doc = nixosTests.lasuite-docs;
145 };
146
147 meta = {
148 description = "Collaborative note taking, wiki and documentation platform that scales. Built with Django and React. Opensource alternative to Notion or Outline";
149 homepage = "https://github.com/suitenumerique/docs";
150 changelog = "https://github.com/suitenumerique/docs/blob/${src.tag}/CHANGELOG.md";
151 license = lib.licenses.mit;
152 maintainers = with lib.maintainers; [ soyouzpanda ];
153 mainProgram = "docs";
154 platforms = lib.platforms.all;
155 };
156}