nixos/engelsystem: refactor option setup

This commit is contained in:
Martin Weinelt 2024-08-22 19:49:07 +02:00
parent fe0d323af5
commit 760b2b5562
No known key found for this signature in database
GPG Key ID: 87C1E9888F856759

View File

@ -1,40 +1,49 @@
{ config, lib, pkgs, utils, ... }:
{
config,
lib,
pkgs,
utils,
...
}:
let
inherit (lib) mkDefault mkEnableOption mkIf mkOption types mkPackageOption;
inherit (lib)
mkDefault
mkEnableOption
mkIf
mkOption
mkPackageOption
mkRenamedOptionModule
types
;
cfg = config.services.engelsystem;
in {
options = {
services.engelsystem = {
enable = mkOption {
default = false;
example = true;
description = ''
Whether to enable engelsystem, an online tool for coordinating volunteers
and shifts on large events.
'';
type = lib.types.bool;
};
imports = [
(mkRenamedOptionModule [ "services" "engelsystem" "config" ] [ "services" "engelsystem" "settings" ])
];
domain = mkOption {
type = types.str;
example = "engelsystem.example.com";
description = "Domain to serve on.";
};
options.services.engelsystem = {
enable = mkEnableOption "engelsystem, an online tool for coordinating volunteers and shifts on large events";
package = mkPackageOption pkgs "engelsystem" { };
package = mkPackageOption pkgs "engelsystem" { };
createDatabase = mkOption {
type = types.bool;
default = true;
description = ''
Whether to create a local database automatically.
This will override every database setting in {option}`services.engelsystem.config`.
'';
};
domain = mkOption {
type = types.str;
example = "engelsystem.example.com";
description = "Domain to serve on.";
};
services.engelsystem.config = mkOption {
createDatabase = mkOption {
type = types.bool;
default = true;
description = ''
Whether to create a local database automatically.
This will override every database setting in {option}`services.engelsystem.config`.
'';
};
settings = mkOption {
type = types.attrs;
default = {
database = {
@ -144,7 +153,7 @@ in {
script =
let
genConfigScript = pkgs.writeScript "engelsystem-gen-config.sh"
(utils.genJqSecretsReplacementSnippet cfg.config "config.json");
(utils.genJqSecretsReplacementSnippet cfg.settings "config.json");
in ''
umask 077
mkdir -p /var/lib/engelsystem/storage/app