diff --git a/nixos/modules/services/web-apps/szurubooru.nix b/nixos/modules/services/web-apps/szurubooru.nix index a8fb063a770c..e1bfbfe27e8b 100644 --- a/nixos/modules/services/web-apps/szurubooru.nix +++ b/nixos/modules/services/web-apps/szurubooru.nix @@ -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 = { diff --git a/nixos/tests/szurubooru.nix b/nixos/tests/szurubooru.nix index adcfecdbf34b..a9a4ede9950b 100644 --- a/nixos/tests/szurubooru.nix +++ b/nixos/tests/szurubooru.nix @@ -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"; diff --git a/pkgs/servers/web-apps/szurubooru/server.nix b/pkgs/servers/web-apps/szurubooru/server.nix index 6a6f78ca0cc9..910b9fc6a538 100644 --- a/pkgs/servers/web-apps/szurubooru/server.nix +++ b/pkgs/servers/web-apps/szurubooru/server.nix @@ -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";