Skip to content

Commit

Permalink
feat: pass through rocket options in nixos-module
Browse files Browse the repository at this point in the history
  • Loading branch information
Erin van der Veen committed Apr 12, 2024
1 parent 8af8853 commit 53de4c5
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 8 deletions.
17 changes: 14 additions & 3 deletions nix/configuration.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{ ... }:

let
port = 9000;
in
{
virtualisation.vmVariant = {
virtualisation = {
Expand All @@ -8,8 +11,8 @@
forwardPorts = [
{
from = "host";
guest.port = 8000;
host.port = 8000;
guest.port = port;
host.port = port;
}
];
};
Expand All @@ -21,6 +24,14 @@
password = "genealogos";
};

services.genealogos.enable = true;
services.genealogos = {
enable = true;
rocketConfig = {
release = {
port = port;
address = "0.0.0.0";
};
};
};
}

38 changes: 33 additions & 5 deletions nix/genealogos-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ with lib;

let
cfg = config.services.genealogos;
rocketConfigFormat = pkgs.formats.toml { };
in
{
options = {
Expand All @@ -19,16 +20,43 @@ in
The genealogos-api package to use.
'';
};

rocketConfig = lib.mkOption {
type = rocketConfigFormat.type;
default = { };
example = lib.literalExpression ''
{
release = {
address = "0.0.0.0";
port = "8000";
limits = {
form = "64 kB";
json = "1 MiB";
};
};
}
'';

description = lib.mdDoc ''
Configuration file for Genealogos.
Genealogos-api uses rocket as its http implementation.
For all configuration options, see https://rocket.rs/guide/v0.5/configuration/#configuration-parameters
'';
};
};
};

config = mkIf (cfg.enable) {
systemd.services.genealogos =
{
description = "Genealogos sbom generator";
wantedBy = [ "multi-user.target" ];
systemd.services.genealogos = {
description = "Genealogos sbom generator";
wantedBy = [ "multi-user.target" ];

serviceConfig.ExecStart = "${cfg.package}/bin/genealogos-api";
serviceConfig.ExecStart = "${cfg.package}/bin/genealogos-api";

environment = {
ROCKET_CONFIG = rocketConfigFormat.generate "Rocket.toml" cfg.rocketConfig;
};
};
};
}

0 comments on commit 53de4c5

Please sign in to comment.