pytrainer: unpin python 3.10
[NixPkgs.git] / pkgs / servers / web-apps / healthchecks / default.nix
blob5f366a255a0ff3293881db6f5f8a79e6174420fb
1 { lib
2 , writeText
3 , fetchFromGitHub
4 , nixosTests
5 , python3
6 }:
7 let
8   py = python3.override {
9     self = py;
10     packageOverrides = final: prev: {
11       django = prev.django_5;
12     };
13   };
15 py.pkgs.buildPythonApplication rec {
16   pname = "healthchecks";
17   version = "3.6";
18   format = "other";
20   src = fetchFromGitHub {
21     owner = "healthchecks";
22     repo = pname;
23     rev = "refs/tags/v${version}";
24     sha256 = "sha256-aKt9L3ZgZ8HffcNNJaR+hAI38raWuLp2q/6+rvkl2pM=";
25   };
27   propagatedBuildInputs = with py.pkgs; [
28     aiosmtpd
29     apprise
30     cronsim
31     django
32     django-compressor
33     django-stubs-ext
34     fido2
35     minio
36     oncalendar
37     psycopg2
38     pycurl
39     pydantic
40     pyotp
41     segno
42     statsd
43     whitenoise
44   ];
46   secrets = [
47     "DB_PASSWORD"
48     "DISCORD_CLIENT_SECRET"
49     "EMAIL_HOST_PASSWORD"
50     "LINENOTIFY_CLIENT_SECRET"
51     "MATRIX_ACCESS_TOKEN"
52     "PD_APP_ID"
53     "PUSHBULLET_CLIENT_SECRET"
54     "PUSHOVER_API_TOKEN"
55     "S3_SECRET_KEY"
56     "SECRET_KEY"
57     "SLACK_CLIENT_SECRET"
58     "TELEGRAM_TOKEN"
59     "TRELLO_APP_KEY"
60     "TWILIO_AUTH"
61   ];
63   localSettings = writeText "local_settings.py" ''
64     import os
66     STATIC_ROOT = os.getenv("STATIC_ROOT")
68     ${lib.concatLines (map
69       (secret: ''
70         ${secret}_FILE = os.getenv("${secret}_FILE")
71         if ${secret}_FILE:
72             with open(${secret}_FILE, "r") as file:
73                 ${secret} = file.readline()
74       '')
75       secrets)}
76   '';
78   installPhase = ''
79     mkdir -p $out/opt/healthchecks
80     cp -r . $out/opt/healthchecks
81     chmod +x $out/opt/healthchecks/manage.py
82     cp ${localSettings} $out/opt/healthchecks/hc/local_settings.py
83   '';
85   passthru = {
86     # PYTHONPATH of all dependencies used by the package
87     pythonPath = py.pkgs.makePythonPath propagatedBuildInputs;
89     tests = {
90       inherit (nixosTests) healthchecks;
91     };
92   };
94   meta = with lib; {
95     homepage = "https://github.com/healthchecks/healthchecks";
96     description = "Cron monitoring tool written in Python & Django";
97     license = licenses.bsd3;
98     maintainers = with maintainers; [ phaer ];
99   };