diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 8a269d55a3c4..b2ae30aa9ff2 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -1082,6 +1082,7 @@ ./services/web-apps/nexus.nix ./services/web-apps/nifi.nix ./services/web-apps/node-red.nix + ./services/web-apps/phylactery.nix ./services/web-apps/pict-rs.nix ./services/web-apps/peertube.nix ./services/web-apps/plantuml-server.nix diff --git a/nixos/modules/services/web-apps/phylactery.nix b/nixos/modules/services/web-apps/phylactery.nix new file mode 100644 index 000000000000..f0e97da1f202 --- /dev/null +++ b/nixos/modules/services/web-apps/phylactery.nix @@ -0,0 +1,51 @@ +{ config, lib, pkgs, ... }: + +with lib; +let cfg = config.services.phylactery; +in { + options.services.phylactery = { + enable = mkEnableOption "Whether to enable Phylactery server"; + + host = mkOption { + type = types.str; + default = "localhost"; + description = "Listen host for Phylactery"; + }; + + port = mkOption { + type = types.port; + description = "Listen port for Phylactery"; + }; + + library = mkOption { + type = types.path; + description = "Path to CBZ library"; + }; + + package = mkOption { + type = types.package; + default = pkgs.phylactery; + defaultText = literalExpression "pkgs.phylactery"; + description = "The Phylactery package to use"; + }; + }; + + config = mkIf cfg.enable { + systemd.services.phylactery = { + environment = { + PHYLACTERY_ADDRESS = "${cfg.host}:${toString cfg.port}"; + PHYLACTERY_LIBRARY = "${cfg.library}"; + }; + + wantedBy = [ "multi-user.target" ]; + + serviceConfig = { + ConditionPathExists = cfg.library; + DynamicUser = true; + ExecStart = "${cfg.package}/bin/phylactery"; + }; + }; + }; + + meta.maintainers = with maintainers; [ McSinyx ]; +} diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 6a72130be5f8..162e117796a2 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -426,6 +426,7 @@ in { php = handleTest ./php {}; php80 = handleTest ./php { php = pkgs.php80; }; php81 = handleTest ./php { php = pkgs.php81; }; + phylactery = handleTest ./web-apps/phylactery.nix {}; pict-rs = handleTest ./pict-rs.nix {}; pinnwand = handleTest ./pinnwand.nix {}; plasma5 = handleTest ./plasma5.nix {}; diff --git a/nixos/tests/web-apps/phylactery.nix b/nixos/tests/web-apps/phylactery.nix new file mode 100644 index 000000000000..cf2689d2300d --- /dev/null +++ b/nixos/tests/web-apps/phylactery.nix @@ -0,0 +1,20 @@ +import ../make-test-python.nix ({ pkgs, lib, ... }: { + name = "phylactery"; + + nodes.machine = { ... }: { + services.phylactery = rec { + enable = true; + port = 8080; + library = "/tmp"; + }; + }; + + testScript = '' + start_all() + machine.wait_for_unit('phylactery') + machine.wait_for_open_port(8080) + machine.wait_until_succeeds('curl localhost:8080') + ''; + + meta.maintainers = with lib.maintainers; [ McSinyx ]; +}) diff --git a/pkgs/servers/web-apps/phylactery/default.nix b/pkgs/servers/web-apps/phylactery/default.nix new file mode 100644 index 000000000000..a3cddf2fc8d5 --- /dev/null +++ b/pkgs/servers/web-apps/phylactery/default.nix @@ -0,0 +1,27 @@ +{ lib, buildGoPackage, fetchFromSourcehut, nixosTests }: + +buildGoPackage rec { + pname = "phylactery"; + version = "0.1.1"; + + goPackagePath = "git.sr.ht/~cnx/phylactery"; + + src = fetchFromSourcehut { + owner = "~cnx"; + repo = pname; + rev = version; + sha256 = "sha256-HcpdPQ1WOMFNdfsZb//GvUVBCbmS3jARbcXjchlv2oE="; + }; + + # Upstream repo doesn't provide any test. + doCheck = false; + passthru.tests.phylactery = nixosTests.phylactery; + + meta = with lib; { + description = "Old school comic web server"; + homepage = "https://git.sr.ht/~cnx/phylactery"; + license = licenses.agpl3Plus; + maintainers = with maintainers; [ McSinyx ]; + platforms = platforms.all; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 0b191ec63ab9..56109aae5c09 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -29313,6 +29313,8 @@ with pkgs; phrase-cli = callPackage ../tools/misc/phrase-cli { }; + phylactery = callPackage ../servers/web-apps/phylactery { }; + pianobar = callPackage ../applications/audio/pianobar { }; pianobooster = qt5.callPackage ../applications/audio/pianobooster { stdenv = gcc10StdenvCompat; };