feat(django-apps): Factorize overlays

This commit is contained in:
Tom Hubrecht 2025-01-11 19:05:48 +01:00
parent c58f68bab2
commit ec564b46f4
Signed by: thubrecht
SSH key fingerprint: SHA256:r+nK/SIcWlJ0zFZJGHtlAoRwq1Rm+WcKAm5ADYMoQPc
8 changed files with 136 additions and 151 deletions

View file

@ -2,16 +2,7 @@
# #
# SPDX-License-Identifier: EUPL-1.2 # SPDX-License-Identifier: EUPL-1.2
{ { config, ... }:
pkgs,
sources,
config,
...
}:
let
nix-pkgs = import sources.nix-pkgs { inherit pkgs; };
in
{ {
services.django-apps.sites.annuaire = { services.django-apps.sites.annuaire = {
@ -26,15 +17,19 @@ in
webHookSecret = config.age.secrets."webhook-annuaire_token".path; webHookSecret = config.age.secrets."webhook-annuaire_token".path;
python = pkgs.python3.override { overlays.nix-pkgs = [
packageOverrides = _: _: { inherit (nix-pkgs) authens loadcredential; }; "authens"
}; "loadcredential"
# Dependencies
"python-cas"
];
dependencies = ps: [ dependencies = ps: [
ps.django
ps.pillow
ps.loadcredential
ps.authens ps.authens
ps.django
ps.loadcredential
ps.pillow
ps.python-dateutil ps.python-dateutil
]; ];

View file

@ -2,16 +2,7 @@
# #
# SPDX-License-Identifier: EUPL-1.2 # SPDX-License-Identifier: EUPL-1.2
{ { config, ... }:
pkgs,
sources,
config,
...
}:
let
nix-pkgs = import sources.nix-pkgs { inherit pkgs; };
in
{ {
services.django-apps.sites.bocal = { services.django-apps.sites.bocal = {
@ -26,9 +17,14 @@ in
webHookSecret = config.age.secrets."webhook-bocal_token".path; webHookSecret = config.age.secrets."webhook-bocal_token".path;
python = pkgs.python3.override { overlays.nix-pkgs = [
packageOverrides = _: _: { inherit (nix-pkgs) django-cas-ng django-solo loadcredential; }; "django-cas-ng"
}; "django-solo"
"loadcredential"
# Dependencies
"python-cas"
];
dependencies = ps: [ dependencies = ps: [
ps.django ps.django

View file

@ -2,16 +2,7 @@
# #
# SPDX-License-Identifier: EUPL-1.2 # SPDX-License-Identifier: EUPL-1.2
{ { config, ... }:
pkgs,
sources,
config,
...
}:
let
nix-pkgs = import sources.nix-pkgs { inherit pkgs; };
in
{ {
services.django-apps.sites.ernestophone = { services.django-apps.sites.ernestophone = {
@ -31,16 +22,12 @@ in
webHookSecret = config.age.secrets."webhook-ernestophone_token".path; webHookSecret = config.age.secrets."webhook-ernestophone_token".path;
python = pkgs.python3.override { overlays.nix-pkgs = [
packageOverrides = _: _: { "django-avatar"
inherit (nix-pkgs) "django-cas-ng"
django-avatar "django-solo"
django-cas-ng "loadcredential"
django-solo ];
loadcredential
;
};
};
dependencies = ps: [ dependencies = ps: [
ps.django ps.django

View file

@ -2,16 +2,7 @@
# #
# SPDX-License-Identifier: EUPL-1.2 # SPDX-License-Identifier: EUPL-1.2
{ { config, ... }:
pkgs,
sources,
config,
...
}:
let
inherit (import "${sources.nix-pkgs}/overlay.nix") mkOverlay;
in
{ {
services.django-apps.sites.gestiobds = { services.django-apps.sites.gestiobds = {
@ -26,10 +17,7 @@ in
webHookSecret = config.age.secrets."webhook-gestiobds_token".path; webHookSecret = config.age.secrets."webhook-gestiobds_token".path;
python = pkgs.python3.override { overlays.nix-pkgs = [
packageOverrides = mkOverlay {
folder = "python-modules";
plist = [
# Required packages # Required packages
"authens" "authens"
"django-bootstrap-form" "django-bootstrap-form"
@ -39,8 +27,6 @@ in
# Dependencies # Dependencies
"python-cas" "python-cas"
]; ];
};
};
dependencies = ps: [ dependencies = ps: [
ps.authens ps.authens

View file

@ -2,16 +2,7 @@
# #
# SPDX-License-Identifier: EUPL-1.2 # SPDX-License-Identifier: EUPL-1.2
{ { config, ... }:
pkgs,
sources,
config,
...
}:
let
inherit (import "${sources.nix-pkgs}/overlay.nix") mkOverlay;
in
{ {
services.django-apps.sites.gestiocof = { services.django-apps.sites.gestiocof = {
@ -26,13 +17,16 @@ in
webHookSecret = config.age.secrets."webhook-gestiocof_token".path; webHookSecret = config.age.secrets."webhook-gestiocof_token".path;
python = pkgs.python3.override { overlays = {
packageOverrides = kat-pkgs = [
self: super: "django-djconfig"
( "django-hCaptcha"
(mkOverlay { "wagtail-modeltranslation"
folder = "python-modules"; "wagtailmenus"
plist = [ "django-cogwheels"
];
nix-pkgs = [
# Required packages # Required packages
"authens" "authens"
"django-bootstrap-form" "django-bootstrap-form"
@ -42,17 +36,6 @@ in
# Dependencies # Dependencies
"python-cas" "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" { }));
}; };
dependencies = ps: [ dependencies = ps: [

View file

@ -2,16 +2,7 @@
# #
# SPDX-License-Identifier: EUPL-1.2 # SPDX-License-Identifier: EUPL-1.2
{ { config, ... }:
pkgs,
sources,
config,
...
}:
let
nix-pkgs = import sources.nix-pkgs { inherit pkgs; };
in
{ {
services.django-apps.sites.gestiojeux = { services.django-apps.sites.gestiojeux = {
@ -31,16 +22,15 @@ in
module = "gestiojeux"; module = "gestiojeux";
}; };
python = pkgs.python3.override { overlays.nix-pkgs = [
packageOverrides = _: _: { "django-autoslug"
inherit (nix-pkgs) "django-cas-ng"
django-autoslug "loadcredential"
django-cas-ng "markdown-icons"
loadcredential
markdown-icons # Dependencies
; "python-cas"
}; ];
};
django = ps: ps.django_4; django = ps: ps.django_4;
dependencies = ps: [ dependencies = ps: [

View file

@ -2,16 +2,7 @@
# #
# SPDX-License-Identifier: EUPL-1.2 # SPDX-License-Identifier: EUPL-1.2
{ { config, ... }:
config,
pkgs,
sources,
...
}:
let
nix-pkgs = import sources.nix-pkgs { inherit pkgs; };
in
{ {
services.webhook.extraArgs = [ "-debug" ]; services.webhook.extraArgs = [ "-debug" ];
@ -36,9 +27,10 @@ in
dbType = "sqlite"; dbType = "sqlite";
python = pkgs.python3.override { overlays.nix-pkgs = [
packageOverrides = _: _: { inherit (nix-pkgs) python-cas loadcredential; }; "loadcredential"
}; "python-cas"
];
django = ps: ps.django_4; django = ps: ps.django_4;
dependencies = ps: [ dependencies = ps: [

View file

@ -8,12 +8,14 @@
options, options,
pkgs, pkgs,
utils, utils,
sources,
... ...
}: }:
let let
inherit (lib) inherit (lib)
attrNames attrNames
composeManyExtensions
concatLists concatLists
concatMapAttrs concatMapAttrs
filterAttrs filterAttrs
@ -30,6 +32,7 @@ let
mkPackageOption mkPackageOption
nameValuePair nameValuePair
optional optional
optionalString
optionals optionals
recursiveUpdate recursiveUpdate
toUpper toUpper
@ -42,6 +45,7 @@ let
enum enum
functionTo functionTo
ints ints
lines
listOf listOf
nullOr nullOr
package package
@ -192,6 +196,24 @@ in
python = mkPackageOption pkgs "python3" { }; 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 { django = mkOption {
type = functionTo package; type = functionTo package;
default = ps: ps.django; default = ps: ps.django;
@ -203,7 +225,31 @@ in
djangoEnv = mkOption { djangoEnv = mkOption {
type = package; type = package;
default = config.python.withPackages ( 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: ps:
[ (config.django ps) ] [ (config.django ps) ]
++ (optional (config.application.type != "daphne") ps.gunicorn) ++ (optional (config.application.type != "daphne") ps.gunicorn)
@ -303,6 +349,7 @@ in
git pull git pull
python3 ${config.managePath} migrate python3 ${config.managePath} migrate
python3 ${config.managePath} collectstatic --no-input python3 ${config.managePath} collectstatic --no-input
${optionalString (config.extraUpdateSteps != null) config.extraUpdateSteps}
''; '';
}; };
description = '' 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 { webHookSecret = mkOption {
type = path; type = path;
description = '' description = ''
@ -425,7 +481,7 @@ in
trigger-rule = { trigger-rule = {
and = [ and = [
{ {
or = [ "or" = [
{ {
match = { match = {
type = "payload-hmac-sha256"; type = "payload-hmac-sha256";