forked from DGNum/infrastructure
feat(django-apps): Factorize overlays
This commit is contained in:
parent
c58f68bab2
commit
ec564b46f4
8 changed files with 136 additions and 151 deletions
|
@ -2,16 +2,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
{
|
||||
pkgs,
|
||||
sources,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
nix-pkgs = import sources.nix-pkgs { inherit pkgs; };
|
||||
in
|
||||
{ config, ... }:
|
||||
|
||||
{
|
||||
services.django-apps.sites.annuaire = {
|
||||
|
@ -26,15 +17,19 @@ in
|
|||
|
||||
webHookSecret = config.age.secrets."webhook-annuaire_token".path;
|
||||
|
||||
python = pkgs.python3.override {
|
||||
packageOverrides = _: _: { inherit (nix-pkgs) authens loadcredential; };
|
||||
};
|
||||
overlays.nix-pkgs = [
|
||||
"authens"
|
||||
"loadcredential"
|
||||
|
||||
# Dependencies
|
||||
"python-cas"
|
||||
];
|
||||
|
||||
dependencies = ps: [
|
||||
ps.django
|
||||
ps.pillow
|
||||
ps.loadcredential
|
||||
ps.authens
|
||||
ps.django
|
||||
ps.loadcredential
|
||||
ps.pillow
|
||||
ps.python-dateutil
|
||||
];
|
||||
|
||||
|
|
|
@ -2,16 +2,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
{
|
||||
pkgs,
|
||||
sources,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
nix-pkgs = import sources.nix-pkgs { inherit pkgs; };
|
||||
in
|
||||
{ config, ... }:
|
||||
|
||||
{
|
||||
services.django-apps.sites.bocal = {
|
||||
|
@ -26,9 +17,14 @@ in
|
|||
|
||||
webHookSecret = config.age.secrets."webhook-bocal_token".path;
|
||||
|
||||
python = pkgs.python3.override {
|
||||
packageOverrides = _: _: { inherit (nix-pkgs) django-cas-ng django-solo loadcredential; };
|
||||
};
|
||||
overlays.nix-pkgs = [
|
||||
"django-cas-ng"
|
||||
"django-solo"
|
||||
"loadcredential"
|
||||
|
||||
# Dependencies
|
||||
"python-cas"
|
||||
];
|
||||
|
||||
dependencies = ps: [
|
||||
ps.django
|
||||
|
|
|
@ -2,16 +2,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
{
|
||||
pkgs,
|
||||
sources,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
nix-pkgs = import sources.nix-pkgs { inherit pkgs; };
|
||||
in
|
||||
{ config, ... }:
|
||||
|
||||
{
|
||||
services.django-apps.sites.ernestophone = {
|
||||
|
@ -31,16 +22,12 @@ in
|
|||
|
||||
webHookSecret = config.age.secrets."webhook-ernestophone_token".path;
|
||||
|
||||
python = pkgs.python3.override {
|
||||
packageOverrides = _: _: {
|
||||
inherit (nix-pkgs)
|
||||
django-avatar
|
||||
django-cas-ng
|
||||
django-solo
|
||||
loadcredential
|
||||
;
|
||||
};
|
||||
};
|
||||
overlays.nix-pkgs = [
|
||||
"django-avatar"
|
||||
"django-cas-ng"
|
||||
"django-solo"
|
||||
"loadcredential"
|
||||
];
|
||||
|
||||
dependencies = ps: [
|
||||
ps.django
|
||||
|
|
|
@ -2,16 +2,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
{
|
||||
pkgs,
|
||||
sources,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (import "${sources.nix-pkgs}/overlay.nix") mkOverlay;
|
||||
in
|
||||
{ config, ... }:
|
||||
|
||||
{
|
||||
services.django-apps.sites.gestiobds = {
|
||||
|
@ -26,21 +17,16 @@ in
|
|||
|
||||
webHookSecret = config.age.secrets."webhook-gestiobds_token".path;
|
||||
|
||||
python = pkgs.python3.override {
|
||||
packageOverrides = mkOverlay {
|
||||
folder = "python-modules";
|
||||
plist = [
|
||||
# Required packages
|
||||
"authens"
|
||||
"django-bootstrap-form"
|
||||
"django-cas-ng"
|
||||
"loadcredential"
|
||||
overlays.nix-pkgs = [
|
||||
# Required packages
|
||||
"authens"
|
||||
"django-bootstrap-form"
|
||||
"django-cas-ng"
|
||||
"loadcredential"
|
||||
|
||||
# Dependencies
|
||||
"python-cas"
|
||||
];
|
||||
};
|
||||
};
|
||||
# Dependencies
|
||||
"python-cas"
|
||||
];
|
||||
|
||||
dependencies = ps: [
|
||||
ps.authens
|
||||
|
|
|
@ -2,16 +2,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
{
|
||||
pkgs,
|
||||
sources,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (import "${sources.nix-pkgs}/overlay.nix") mkOverlay;
|
||||
in
|
||||
{ config, ... }:
|
||||
|
||||
{
|
||||
services.django-apps.sites.gestiocof = {
|
||||
|
@ -26,33 +17,25 @@ in
|
|||
|
||||
webHookSecret = config.age.secrets."webhook-gestiocof_token".path;
|
||||
|
||||
python = pkgs.python3.override {
|
||||
packageOverrides =
|
||||
self: super:
|
||||
(
|
||||
(mkOverlay {
|
||||
folder = "python-modules";
|
||||
plist = [
|
||||
# Required packages
|
||||
"authens"
|
||||
"django-bootstrap-form"
|
||||
"django-cas-ng"
|
||||
"loadcredential"
|
||||
overlays = {
|
||||
kat-pkgs = [
|
||||
"django-djconfig"
|
||||
"django-hCaptcha"
|
||||
"wagtail-modeltranslation"
|
||||
"wagtailmenus"
|
||||
"django-cogwheels"
|
||||
];
|
||||
|
||||
# Dependencies
|
||||
"python-cas"
|
||||
];
|
||||
})
|
||||
self
|
||||
super
|
||||
)
|
||||
// (super.lib.genAttrs [
|
||||
"django-djconfig"
|
||||
"django-hCaptcha"
|
||||
"wagtail-modeltranslation"
|
||||
"wagtailmenus"
|
||||
"django-cogwheels"
|
||||
] (name: self.callPackage "${sources.kat-pkgs}/python-pkgs/${name}.nix" { }));
|
||||
nix-pkgs = [
|
||||
# Required packages
|
||||
"authens"
|
||||
"django-bootstrap-form"
|
||||
"django-cas-ng"
|
||||
"loadcredential"
|
||||
|
||||
# Dependencies
|
||||
"python-cas"
|
||||
];
|
||||
};
|
||||
|
||||
dependencies = ps: [
|
||||
|
|
|
@ -2,16 +2,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
{
|
||||
pkgs,
|
||||
sources,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
nix-pkgs = import sources.nix-pkgs { inherit pkgs; };
|
||||
in
|
||||
{ config, ... }:
|
||||
|
||||
{
|
||||
services.django-apps.sites.gestiojeux = {
|
||||
|
@ -31,16 +22,15 @@ in
|
|||
module = "gestiojeux";
|
||||
};
|
||||
|
||||
python = pkgs.python3.override {
|
||||
packageOverrides = _: _: {
|
||||
inherit (nix-pkgs)
|
||||
django-autoslug
|
||||
django-cas-ng
|
||||
loadcredential
|
||||
markdown-icons
|
||||
;
|
||||
};
|
||||
};
|
||||
overlays.nix-pkgs = [
|
||||
"django-autoslug"
|
||||
"django-cas-ng"
|
||||
"loadcredential"
|
||||
"markdown-icons"
|
||||
|
||||
# Dependencies
|
||||
"python-cas"
|
||||
];
|
||||
|
||||
django = ps: ps.django_4;
|
||||
dependencies = ps: [
|
||||
|
|
|
@ -2,16 +2,7 @@
|
|||
#
|
||||
# SPDX-License-Identifier: EUPL-1.2
|
||||
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
sources,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
nix-pkgs = import sources.nix-pkgs { inherit pkgs; };
|
||||
in
|
||||
{ config, ... }:
|
||||
|
||||
{
|
||||
services.webhook.extraArgs = [ "-debug" ];
|
||||
|
@ -36,9 +27,10 @@ in
|
|||
|
||||
dbType = "sqlite";
|
||||
|
||||
python = pkgs.python3.override {
|
||||
packageOverrides = _: _: { inherit (nix-pkgs) python-cas loadcredential; };
|
||||
};
|
||||
overlays.nix-pkgs = [
|
||||
"loadcredential"
|
||||
"python-cas"
|
||||
];
|
||||
|
||||
django = ps: ps.django_4;
|
||||
dependencies = ps: [
|
||||
|
|
|
@ -8,12 +8,14 @@
|
|||
options,
|
||||
pkgs,
|
||||
utils,
|
||||
sources,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
inherit (lib)
|
||||
attrNames
|
||||
composeManyExtensions
|
||||
concatLists
|
||||
concatMapAttrs
|
||||
filterAttrs
|
||||
|
@ -30,6 +32,7 @@ let
|
|||
mkPackageOption
|
||||
nameValuePair
|
||||
optional
|
||||
optionalString
|
||||
optionals
|
||||
recursiveUpdate
|
||||
toUpper
|
||||
|
@ -42,6 +45,7 @@ let
|
|||
enum
|
||||
functionTo
|
||||
ints
|
||||
lines
|
||||
listOf
|
||||
nullOr
|
||||
package
|
||||
|
@ -192,6 +196,24 @@ in
|
|||
|
||||
python = mkPackageOption pkgs "python3" { };
|
||||
|
||||
overlays = {
|
||||
kat-pkgs = mkOption {
|
||||
type = listOf str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
List of python packages to pull from [kat-pkgs](https://git.dgnum.eu/lbailly/kat-pkgs).
|
||||
'';
|
||||
};
|
||||
|
||||
nix-pkgs = mkOption {
|
||||
type = listOf str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
List of python packages to pull from [nix-pkgs](https://git.hubrecht.ovh/hubrecht/nix-pkgs).
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
django = mkOption {
|
||||
type = functionTo package;
|
||||
default = ps: ps.django;
|
||||
|
@ -203,14 +225,38 @@ in
|
|||
|
||||
djangoEnv = mkOption {
|
||||
type = package;
|
||||
default = config.python.withPackages (
|
||||
ps:
|
||||
[ (config.django ps) ]
|
||||
++ (optional (config.application.type != "daphne") ps.gunicorn)
|
||||
++ (optional (config.application.type == "asgi") ps.uvicorn)
|
||||
++ (optional (config.dbType == "postgresql") ps.psycopg)
|
||||
++ (config.dependencies ps)
|
||||
);
|
||||
default =
|
||||
let
|
||||
overlays =
|
||||
(optional (config.overlays.nix-pkgs != [ ]) (
|
||||
(import "${sources.nix-pkgs}/overlay.nix").mkOverlay {
|
||||
folder = "python-modules";
|
||||
plist = config.overlays.nix-pkgs;
|
||||
}
|
||||
))
|
||||
++ (optional (config.overlays.kat-pkgs != [ ]) (
|
||||
self: super:
|
||||
super.lib.genAttrs config.overlays.kat-pkgs (
|
||||
name: self.callPackage "${sources.kat-pkgs}/python-pkgs/${name}.nix" { }
|
||||
)
|
||||
));
|
||||
in
|
||||
(
|
||||
if (overlays != [ ]) then
|
||||
config.python.override {
|
||||
packageOverrides = composeManyExtensions overlays;
|
||||
}
|
||||
else
|
||||
config.python
|
||||
).withPackages
|
||||
(
|
||||
ps:
|
||||
[ (config.django ps) ]
|
||||
++ (optional (config.application.type != "daphne") ps.gunicorn)
|
||||
++ (optional (config.application.type == "asgi") ps.uvicorn)
|
||||
++ (optional (config.dbType == "postgresql") ps.psycopg)
|
||||
++ (config.dependencies ps)
|
||||
);
|
||||
description = ''
|
||||
The python version used to run the app, with the correct dependencies.
|
||||
'';
|
||||
|
@ -303,6 +349,7 @@ in
|
|||
git pull
|
||||
python3 ${config.managePath} migrate
|
||||
python3 ${config.managePath} collectstatic --no-input
|
||||
${optionalString (config.extraUpdateSteps != null) config.extraUpdateSteps}
|
||||
'';
|
||||
};
|
||||
description = ''
|
||||
|
@ -310,6 +357,15 @@ in
|
|||
'';
|
||||
};
|
||||
|
||||
extraUpdateSteps = mkOption {
|
||||
type = nullOr lines;
|
||||
default = null;
|
||||
description = ''
|
||||
Steps taken during the update after the migration is done
|
||||
and the static files have been collected.
|
||||
'';
|
||||
};
|
||||
|
||||
webHookSecret = mkOption {
|
||||
type = path;
|
||||
description = ''
|
||||
|
@ -425,7 +481,7 @@ in
|
|||
trigger-rule = {
|
||||
and = [
|
||||
{
|
||||
or = [
|
||||
"or" = [
|
||||
{
|
||||
match = {
|
||||
type = "payload-hmac-sha256";
|
||||
|
|
Loading…
Add table
Reference in a new issue