nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 python3,
4 fetchFromGitLab,
5 fetchpatch,
6 openldap,
7 nixosTests,
8}:
9
10let
11 python = python3;
12in
13python.pkgs.buildPythonApplication rec {
14 pname = "canaille";
15 version = "0.0.74";
16 pyproject = true;
17
18 src = fetchFromGitLab {
19 owner = "yaal";
20 repo = "canaille";
21 tag = version;
22 hash = "sha256-FL02ADM7rUU43XR71UWr4FLr/NeUau7zRwTMOSFm1T4=";
23 };
24
25 patches = [
26 # https://gitlab.com/yaal/canaille/-/merge_requests/275
27 (fetchpatch {
28 url = "https://gitlab.com/yaal/canaille/-/commit/1c7fc8b1034a4423f7f46ad8adeced854910b702.patch";
29 hash = "sha256-fu7D010NG7yUChOve7HY3e7mm2c/UGpfcTAiTU8BnGg=";
30 })
31 ];
32
33 build-system = with python.pkgs; [
34 hatchling
35 babel
36 setuptools
37 ];
38
39 dependencies =
40 with python.pkgs;
41 [
42 blinker
43 flask
44 flask-caching
45 flask-wtf
46 pydantic-settings
47 httpx
48 wtforms
49 ]
50 ++ sentry-sdk.optional-dependencies.flask;
51
52 nativeCheckInputs =
53 with python.pkgs;
54 [
55 pytestCheckHook
56 coverage
57 flask-webtest
58 pyquery
59 pytest-cov-stub
60 pytest-httpserver
61 pytest-lazy-fixtures
62 pytest-smtpd
63 pytest-xdist
64 scim2-tester
65 slapd
66 toml
67 faker
68 time-machine
69 pytest-scim2-server
70 ]
71 ++ optional-dependencies.front
72 ++ optional-dependencies.oidc
73 ++ optional-dependencies.scim
74 ++ optional-dependencies.ldap
75 ++ optional-dependencies.postgresql
76 ++ optional-dependencies.otp
77 ++ optional-dependencies.sms;
78
79 postInstall = ''
80 mkdir -p $out/etc/schema
81 cp $out/${python.sitePackages}/canaille/backends/ldap/schemas/* $out/etc/schema/
82 '';
83
84 preCheck = ''
85 # Needed by tests to setup a mockup ldap server.
86 export BIN="${openldap}/bin"
87 export SBIN="${openldap}/bin"
88 export SLAPD="${openldap}/libexec/slapd"
89 export SCHEMA="${openldap}/etc/schema"
90
91 # Just use their example config for testing
92 export CONFIG=tests/app/fixtures/default-config.toml
93 '';
94
95 optional-dependencies = with python.pkgs; {
96 front = [
97 email-validator
98 flask-babel
99 flask-talisman
100 flask-themer
101 pycountry
102 pytz
103 tomlkit
104 zxcvbn-rs-py
105 ];
106 oidc = [
107 authlib
108 joserfc
109 ];
110 scim = [
111 httpx
112 scim2-models
113 authlib
114 scim2-client
115 ];
116 ldap = [ python-ldap ];
117 sentry = [ sentry-sdk ];
118 postgresql = [
119 flask-alembic
120 passlib
121 sqlalchemy
122 sqlalchemy-json
123 sqlalchemy-utils
124 ]
125 ++ sqlalchemy.optional-dependencies.postgresql_psycopg2binary;
126 otp = [
127 otpauth
128 pillow
129 qrcode
130 ];
131 sms = [ smpplib ];
132 server = [ hypercorn ];
133 };
134
135 passthru = {
136 inherit python;
137 tests = {
138 inherit (nixosTests) canaille;
139 };
140 };
141
142 meta = {
143 description = "Lightweight Identity and Authorization Management";
144 homepage = "https://canaille.readthedocs.io/en/latest/index.html";
145 changelog = "https://gitlab.com/yaal/canaille/-/blob/${src.rev}/CHANGES.rst";
146 license = lib.licenses.mit;
147 platforms = lib.platforms.linux;
148 maintainers = with lib.maintainers; [ erictapen ];
149 mainProgram = "canaille";
150 };
151
152}