mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-04-16 21:48:22 +00:00
nixos/hedgedoc: convert to settings-style configuration
Replace "services.hedgedoc.configuration" with ".settings" to be consistent with RFC0042. This allows control of settings not declared in the module.
This commit is contained in:
parent
215f1406e5
commit
429fc9aaf7
@ -13,17 +13,22 @@ let
|
||||
then "hedgedoc"
|
||||
else "codimd";
|
||||
|
||||
settingsFormat = pkgs.formats.json {};
|
||||
|
||||
prettyJSON = conf:
|
||||
pkgs.runCommandLocal "hedgedoc-config.json" {
|
||||
nativeBuildInputs = [ pkgs.jq ];
|
||||
} ''
|
||||
echo '${builtins.toJSON conf}' | jq \
|
||||
'{production:del(.[]|nulls)|del(.[][]?|nulls)}' > $out
|
||||
jq '{production:del(.[]|nulls)|del(.[][]?|nulls)}' \
|
||||
< ${settingsFormat.generate "hedgedoc-ugly.json" cfg.settings} \
|
||||
> $out
|
||||
'';
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
(mkRenamedOptionModule [ "services" "codimd" ] [ "services" "hedgedoc" ])
|
||||
(mkRenamedOptionModule
|
||||
[ "services" "hedgedoc" "configuration" ] [ "services" "hedgedoc" "settings" ])
|
||||
];
|
||||
|
||||
options.services.hedgedoc = {
|
||||
@ -45,7 +50,7 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
configuration = {
|
||||
settings = let options = {
|
||||
debug = mkEnableOption "debug mode";
|
||||
domain = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
@ -960,6 +965,16 @@ in
|
||||
default = null;
|
||||
description = "Configure the SAML integration.";
|
||||
};
|
||||
}; in lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
freeformType = settingsFormat.type;
|
||||
inherit options;
|
||||
};
|
||||
description = ''
|
||||
HedgeDoc configuration, see
|
||||
<link xlink:href="https://docs.hedgedoc.org/configuration/"/>
|
||||
for documentation.
|
||||
'';
|
||||
};
|
||||
|
||||
environmentFile = mkOption {
|
||||
@ -1000,12 +1015,13 @@ in
|
||||
Package that provides HedgeDoc.
|
||||
'';
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
assertions = [
|
||||
{ assertion = cfg.configuration.db == {} -> (
|
||||
cfg.configuration.dbURL != "" && cfg.configuration.dbURL != null
|
||||
{ assertion = cfg.settings.db == {} -> (
|
||||
cfg.settings.dbURL != "" && cfg.settings.dbURL != null
|
||||
);
|
||||
message = "Database configuration for HedgeDoc missing."; }
|
||||
];
|
||||
@ -1026,12 +1042,12 @@ in
|
||||
preStart = ''
|
||||
${pkgs.envsubst}/bin/envsubst \
|
||||
-o ${cfg.workDir}/config.json \
|
||||
-i ${prettyJSON cfg.configuration}
|
||||
mkdir -p ${cfg.configuration.uploadsPath}
|
||||
-i ${prettyJSON cfg.settings}
|
||||
mkdir -p ${cfg.settings.uploadsPath}
|
||||
'';
|
||||
serviceConfig = {
|
||||
WorkingDirectory = cfg.workDir;
|
||||
StateDirectory = [ cfg.workDir cfg.configuration.uploadsPath ];
|
||||
StateDirectory = [ cfg.workDir cfg.settings.uploadsPath ];
|
||||
ExecStart = "${cfg.package}/bin/hedgedoc";
|
||||
EnvironmentFile = mkIf (cfg.environmentFile != null) [ cfg.environmentFile ];
|
||||
Environment = [
|
||||
|
@ -11,7 +11,7 @@ import ./make-test-python.nix ({ pkgs, lib, ... }:
|
||||
services = {
|
||||
hedgedoc = {
|
||||
enable = true;
|
||||
configuration.dbURL = "sqlite:///var/lib/hedgedoc/hedgedoc.db";
|
||||
settings.dbURL = "sqlite:///var/lib/hedgedoc/hedgedoc.db";
|
||||
};
|
||||
};
|
||||
};
|
||||
@ -21,7 +21,7 @@ import ./make-test-python.nix ({ pkgs, lib, ... }:
|
||||
services = {
|
||||
hedgedoc = {
|
||||
enable = true;
|
||||
configuration.dbURL = "postgres://hedgedoc:\${DB_PASSWORD}@localhost:5432/hedgedocdb";
|
||||
settings.dbURL = "postgres://hedgedoc:\${DB_PASSWORD}@localhost:5432/hedgedocdb";
|
||||
|
||||
/*
|
||||
* Do not use pkgs.writeText for secrets as
|
||||
|
Loading…
Reference in New Issue
Block a user