rework stirling-pdf to be more generic with test
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
{ lib, ... }:
|
||||
{ ... }:
|
||||
{
|
||||
_class = "clan.service";
|
||||
manifest.name = "stirling-pdf";
|
||||
@@ -6,43 +6,18 @@
|
||||
manifest.categories = [ "System" ];
|
||||
|
||||
roles.default = {
|
||||
interface.options = {
|
||||
domain = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "pdf";
|
||||
description = "Sub domain or Stirling PDF service";
|
||||
};
|
||||
};
|
||||
|
||||
perInstance =
|
||||
perInstance.nixosModule =
|
||||
{
|
||||
settings,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
nixosModule =
|
||||
{
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
domain = "${settings.domain}.${config.networking.fqdn}";
|
||||
in
|
||||
{
|
||||
services.stirling-pdf = {
|
||||
enable = true;
|
||||
environment = {
|
||||
SERVER_PORT = 8080;
|
||||
};
|
||||
};
|
||||
services.nginx.virtualHosts."${domain}" = {
|
||||
forceSSL = true;
|
||||
useACMEHost = "${config.networking.fqdn}";
|
||||
locations."/" = {
|
||||
proxyPass = "http://localhost:${builtins.toString config.services.stirling-pdf.environment.SERVER_PORT}";
|
||||
};
|
||||
};
|
||||
services.stirling-pdf = {
|
||||
enable = lib.mkDefault true;
|
||||
environment = {
|
||||
SERVER_PORT = lib.mkDefault 8080;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
19
modules/clan/stirling-pdf/flake-module.nix
Normal file
19
modules/clan/stirling-pdf/flake-module.nix
Normal file
@@ -0,0 +1,19 @@
|
||||
{ lib, ... }:
|
||||
let
|
||||
module = lib.modules.importApply ./default.nix { };
|
||||
in
|
||||
{
|
||||
clan.modules = {
|
||||
stirling-pdf = module;
|
||||
};
|
||||
|
||||
perSystem =
|
||||
{ ... }:
|
||||
{
|
||||
clan.nixosTests.stirling-pdf = {
|
||||
imports = [ ./tests/vm/default.nix ];
|
||||
|
||||
clan.modules."@clan/stirling-pdf" = module;
|
||||
};
|
||||
};
|
||||
}
|
34
modules/clan/stirling-pdf/tests/vm/default.nix
Normal file
34
modules/clan/stirling-pdf/tests/vm/default.nix
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
...
|
||||
}:
|
||||
{
|
||||
name = "service-stirling-pdf";
|
||||
|
||||
clan = {
|
||||
directory = ./.;
|
||||
inventory = {
|
||||
machines.server = { };
|
||||
|
||||
instances = {
|
||||
actual-budget-test = {
|
||||
module.name = "@clan/stirling-pdf";
|
||||
module.input = "self";
|
||||
roles.default.machines."server".settings = { };
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nodes = {
|
||||
server = { };
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
start_all()
|
||||
|
||||
server.wait_for_unit("stirling-pdf")
|
||||
|
||||
server.succeed("systemctl status stirling-pdf")
|
||||
|
||||
'';
|
||||
}
|
Reference in New Issue
Block a user