szurubooru: Host option and fixes for backwards compatibility (#451178)

This commit is contained in:
numinit
2025-12-14 08:39:31 +00:00
committed by GitHub
4 changed files with 31 additions and 22 deletions
+13 -20
View File
@@ -72,6 +72,13 @@ in
'';
};
host = lib.mkOption {
type = types.str;
default = "127.0.0.1";
example = "0.0.0.0";
description = "The host address for Szurubooru to bind to.";
};
threads = mkOption {
type = types.int;
default = 4;
@@ -265,9 +272,6 @@ in
(lib.filterAttrsRecursive (_: x: x != null))
]
);
pyenv = python.buildEnv.override {
extraLibs = [ (python.pkgs.toPythonModule cfg.server.package) ];
};
in
{
description = "Server of Szurubooru, an image board engine dedicated for small and medium communities";
@@ -283,20 +287,9 @@ in
];
wants = [ "network-online.target" ];
environment = {
PYTHONPATH = "${pyenv}/${pyenv.sitePackages}/";
};
path =
with pkgs;
[
envsubst
ffmpeg_4-full
]
++ (with python.pkgs; [
alembic
waitress
]);
path = with pkgs; [
ffmpeg_4-full
];
script = ''
export SZURUBOORU_SECRET="$(<$CREDENTIALS_DIRECTORY/secret)"
@@ -307,10 +300,10 @@ in
install -m0640 ${cfg.server.package.src}/config.yaml.dist ${cfg.dataDir}/config.yaml.dist
touch ${cfg.dataDir}/config.yaml
chmod 0640 ${cfg.dataDir}/config.yaml
envsubst -i ${configFile} -o ${cfg.dataDir}/config.yaml
${lib.getExe pkgs.envsubst} -i ${configFile} -o ${cfg.dataDir}/config.yaml
sed 's|script_location = |script_location = ${cfg.server.package.src}/|' ${cfg.server.package.src}/alembic.ini > ${cfg.dataDir}/alembic.ini
alembic upgrade head
waitress-serve --port ${toString cfg.server.port} --threads ${toString cfg.server.threads} szurubooru.facade:app
${lib.getExe cfg.server.package.alembic} upgrade head
${lib.getExe cfg.server.package.waitress} --host ${cfg.server.host} --port ${toString cfg.server.port} --threads ${toString cfg.server.threads} szurubooru.facade:app
'';
serviceConfig = {
+1
View File
@@ -26,6 +26,7 @@ import ./make-test-python.nix (
server = {
port = 6666;
host = "127.0.0.1";
settings = {
domain = "http://127.0.0.1";
secretFile = pkgs.writeText "secret" "secret";
+2 -1
View File
@@ -14,7 +14,8 @@ let
};
in
lib.recurseIntoAttrs {
lib.recurseIntoAttrs rec {
client = callPackage ./client.nix { inherit src version; };
server = callPackage ./server.nix { inherit src version; };
inherit (server) tests;
}
+15 -1
View File
@@ -6,6 +6,7 @@
fetchPypi,
python3,
ffmpeg_4-full,
szurubooru,
}:
let
@@ -53,7 +54,6 @@ python.pkgs.buildPythonApplication {
nativeBuildInputs = with python.pkgs; [ setuptools ];
propagatedBuildInputs = with python.pkgs; [
alembic
certifi
coloredlogs
legacy-cgi
@@ -80,6 +80,20 @@ python.pkgs.buildPythonApplication {
passthru.tests.szurubooru = nixosTests.szurubooru;
# Database migration. Needs the szurubooru server in its environment for the
# migration to complete successfully.
passthru.alembic = python.pkgs.alembic.overrideAttrs (old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [
szurubooru.server
];
});
# Waitress is used to run the serer.
passthru.waitress = python.pkgs.waitress.overrideAttrs (old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [
szurubooru.server
];
});
meta = {
description = "Server of szurubooru, an image board engine for small and medium communities";
homepage = "https://github.com/rr-/szurubooru";