This repository has been archived by the owner on Aug 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
flake.nix
175 lines (166 loc) · 8.21 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
{
description = "Weblate package and module";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
poetry2nix.url = "github:nix-community/poetry2nix";
poetry2nix.inputs.nixpkgs.follows = "nixpkgs";
weblate.url = "github:WeblateOrg/weblate/weblate-5.0.2";
weblate.flake = false;
aeidon-src.url = "github:otsaloma/gaupol/1.12";
aeidon-src.flake = false;
};
outputs = { self, nixpkgs, flake-utils, weblate, aeidon-src, poetry2nix }:
let
systems = [ "x86_64-linux" "aarch64-linux" ];
inherit (flake-utils.lib) eachSystem;
in
eachSystem systems
(system:
let
pkgs = nixpkgs.legacyPackages.${system};
poetry2nix_instanciated = poetry2nix.lib.mkPoetry2Nix { inherit pkgs; };
in
{
packages =
{
default = self.packages.${system}.weblate;
weblate = poetry2nix_instanciated.mkPoetryApplication {
src = weblate;
pyproject = ./pyproject.toml;
poetrylock = ./poetry.lock;
patches = [
# The default timeout for the celery check is much too short upstream, so
# we increase it. I guess this is due to the fact that we test the setup
# very early into the initialization of the server, so the load might be
# higher compared to production setups?
./longer-celery-wait-time.patch
# FIXME This shouldn't be necessary and probably has to do with some dependency mismatch.
./cache.lock.patch
];
meta = with pkgs.lib; {
description = "Web based translation tool with tight version control integration";
homepage = "https://weblate.org/";
license = licenses.gpl3Plus;
maintainers = with maintainers; [ erictapen ];
};
overrides = poetry2nix_instanciated.overrides.withDefaults (
self: super: {
aeidon = super.aeidon.overridePythonAttrs (old: {
src = aeidon-src;
nativeBuildInputs = [ pkgs.gettext self.flake8 ];
buildInputs = [ pkgs.isocodes ];
installPhase = ''
${self.python.interpreter} setup.py --without-gaupol install --prefix=$out
'';
});
fluent-syntax = super.fluent-syntax.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.setuptools ];
});
phply = super.phply.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.setuptools ];
});
pygobject = super.pygobject.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.setuptools ];
});
pyicumessageformat = super.pyicumessageformat.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.setuptools ];
});
borgbackup = super.borgbackup.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.setuptools-scm ];
});
siphashc = super.siphashc.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.setuptools ];
});
translate-toolkit = super.translate-toolkit.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.setuptools ];
});
weblate-language-data = super.weblate-language-data.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.setuptools ];
});
translation-finder = super.translation-finder.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.setuptools ];
});
weblate-schemas = super.weblate-schemas.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.setuptools ];
});
diff-match-patch = super.diff-match-patch.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.flit-core ];
});
editables = super.editables.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.flit-core ];
});
nh3 = super.nh3.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [
pkgs.maturin
pkgs.rustPlatform.maturinBuildHook
pkgs.rustPlatform.cargoSetupHook
];
cargoDeps =
let
getCargoHash = version: {
"0.2.14" = "sha256-EzlwSic1Qgs4NZAde/KWg0Qjs+PNEPcnE8HyIPoYZQ0=";
}.${version};
in
pkgs.rustPlatform.fetchCargoTarball {
inherit (old) src;
name = "${old.pname}-${old.version}";
hash = getCargoHash old.version;
};
});
crispy-bootstrap3 = super.crispy-bootstrap3.overridePythonAttrs (old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ self.setuptools ];
});
psycopg = super.psycopg.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ])
++ pkgs.lib.optional pkgs.stdenv.isDarwin pkgs.openssl;
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.postgresql ];
}
);
tesserocr = super.tesserocr.overridePythonAttrs (
old: {
buildInputs = (old.buildInputs or [ ]) ++ [ pkgs.leptonica pkgs.tesseract ];
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [ pkgs.pkg-config ];
}
);
ahocorasick-rs = super.ahocorasick-rs.overridePythonAttrs (
old: {
nativeBuildInputs = (old.nativeBuildInputs or [ ]) ++ [
pkgs.rustPlatform.maturinBuildHook
pkgs.rustPlatform.cargoSetupHook
];
cargoDeps = pkgs.rustPlatform.fetchCargoTarball {
inherit (old) src;
name = "${old.pname}-${old.version}";
hash = "sha256-/sel54PV58y6oUgIzHXSCL4RMljPL9kZ6ER/pRTAjAI=";
};
}
);
}
);
};
};
checks = {
integrationTest =
let
# As pkgs doesn't contain the weblate package and module, we have to
# evaluate Nixpkgs again.
pkgsWeblate = import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
};
in
pkgsWeblate.nixosTest (import ./integration-test.nix {
inherit nixpkgs;
weblateModule = self.nixosModules.weblate;
});
package = self.packages.${system}.weblate;
};
}) // {
nixosModules.weblate = import ./module.nix;
overlays.default = final: prev: {
inherit (self.packages.${prev.system}) weblate;
};
};
}