From 512670498f288c98279bfae0910a2811b9dd51e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Gia=20Phong?= Date: Tue, 28 Jun 2022 15:43:04 +0900 Subject: [PATCH 1/3] phylactery: init at 0.1.1 --- pkgs/servers/web-apps/phylactery/default.nix | 26 ++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 ++ 2 files changed, 28 insertions(+) create mode 100644 pkgs/servers/web-apps/phylactery/default.nix diff --git a/pkgs/servers/web-apps/phylactery/default.nix b/pkgs/servers/web-apps/phylactery/default.nix new file mode 100644 index 000000000000..72687e2065dc --- /dev/null +++ b/pkgs/servers/web-apps/phylactery/default.nix @@ -0,0 +1,26 @@ +{ lib, buildGoPackage, fetchFromSourcehut }: + +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; + + 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 45a89043efa6..cee5e07c1161 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -29169,6 +29169,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; }; From f5f338c8468a84b624980c2fd2cf2fa32d14741b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Gia=20Phong?= Date: Tue, 28 Jun 2022 16:41:44 +0900 Subject: [PATCH 2/3] nixos/phylactery: init --- nixos/modules/module-list.nix | 1 + .../modules/services/web-apps/phylactery.nix | 51 +++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 nixos/modules/services/web-apps/phylactery.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index c1e41c8951ca..7258df33cfc5 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -1078,6 +1078,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 ]; +} From ce910fca8841061e86bfbfd15f8976132c2bfd78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Gia=20Phong?= Date: Wed, 29 Jun 2022 04:17:38 +0900 Subject: [PATCH 3/3] nixos/tests: add phlactery --- nixos/tests/all-tests.nix | 1 + nixos/tests/web-apps/phylactery.nix | 20 ++++++++++++++++++++ pkgs/servers/web-apps/phylactery/default.nix | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 nixos/tests/web-apps/phylactery.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 87bed40eac9e..70904d61077b 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -424,6 +424,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 index 72687e2065dc..a3cddf2fc8d5 100644 --- a/pkgs/servers/web-apps/phylactery/default.nix +++ b/pkgs/servers/web-apps/phylactery/default.nix @@ -1,4 +1,4 @@ -{ lib, buildGoPackage, fetchFromSourcehut }: +{ lib, buildGoPackage, fetchFromSourcehut, nixosTests }: buildGoPackage rec { pname = "phylactery"; @@ -15,6 +15,7 @@ buildGoPackage rec { # Upstream repo doesn't provide any test. doCheck = false; + passthru.tests.phylactery = nixosTests.phylactery; meta = with lib; { description = "Old school comic web server";