rework stirling-pdf to be more generic with test
This commit is contained in:
@@ -8,7 +8,6 @@
|
|||||||
{
|
{
|
||||||
clan = {
|
clan = {
|
||||||
modules = {
|
modules = {
|
||||||
stirling-pdf = ../modules/clan/stirling-pdf;
|
|
||||||
victoria-metrics = ../modules/clan/victoria-metrics;
|
victoria-metrics = ../modules/clan/victoria-metrics;
|
||||||
};
|
};
|
||||||
inventory = {
|
inventory = {
|
||||||
|
26
machines/b4l/services/stirling-pdf.nix
Normal file
26
machines/b4l/services/stirling-pdf.nix
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{ config, ... }:
|
||||||
|
let
|
||||||
|
stDomain = "${config.clan.core.vars.generators.b4l-stirling-pdf.files.subdomain.value}.${config.networking.fqdn}";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
clan.core.vars.generators.b4l-stirling-pdf = {
|
||||||
|
files.subdomain.secret = false;
|
||||||
|
|
||||||
|
prompts = {
|
||||||
|
subdomain = {
|
||||||
|
persist = true;
|
||||||
|
type = "line";
|
||||||
|
description = "Sub-domain for Stirling PDF app. Default:(pdf)";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
script = ''cat $prompts/subdomain || echo -n "pdf" > $out/subdomain'';
|
||||||
|
};
|
||||||
|
|
||||||
|
services.nginx.virtualHosts."${stDomain}" = {
|
||||||
|
forceSSL = true;
|
||||||
|
useACMEHost = "${config.networking.fqdn}";
|
||||||
|
locations."/" = {
|
||||||
|
proxyPass = "http://localhost:${builtins.toString config.services.stirling-pdf.environment.SERVER_PORT}";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
@@ -1,4 +1,4 @@
|
|||||||
{ lib, ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
_class = "clan.service";
|
_class = "clan.service";
|
||||||
manifest.name = "stirling-pdf";
|
manifest.name = "stirling-pdf";
|
||||||
@@ -6,43 +6,18 @@
|
|||||||
manifest.categories = [ "System" ];
|
manifest.categories = [ "System" ];
|
||||||
|
|
||||||
roles.default = {
|
roles.default = {
|
||||||
interface.options = {
|
perInstance.nixosModule =
|
||||||
domain = lib.mkOption {
|
|
||||||
type = lib.types.str;
|
|
||||||
default = "pdf";
|
|
||||||
description = "Sub domain or Stirling PDF service";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
perInstance =
|
|
||||||
{
|
{
|
||||||
settings,
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
nixosModule =
|
services.stirling-pdf = {
|
||||||
{
|
enable = lib.mkDefault true;
|
||||||
config,
|
environment = {
|
||||||
...
|
SERVER_PORT = lib.mkDefault 8080;
|
||||||
}:
|
|
||||||
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}";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
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")
|
||||||
|
|
||||||
|
'';
|
||||||
|
}
|
1
vars/per-machine/b4l/b4l-stirling-pdf/subdomain/value
Normal file
1
vars/per-machine/b4l/b4l-stirling-pdf/subdomain/value
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pdf
|
Reference in New Issue
Block a user