mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03: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
2 changed files with 26 additions and 10 deletions
|
@ -13,17 +13,22 @@ let
|
||||||
then "hedgedoc"
|
then "hedgedoc"
|
||||||
else "codimd";
|
else "codimd";
|
||||||
|
|
||||||
|
settingsFormat = pkgs.formats.json {};
|
||||||
|
|
||||||
prettyJSON = conf:
|
prettyJSON = conf:
|
||||||
pkgs.runCommandLocal "hedgedoc-config.json" {
|
pkgs.runCommandLocal "hedgedoc-config.json" {
|
||||||
nativeBuildInputs = [ pkgs.jq ];
|
nativeBuildInputs = [ pkgs.jq ];
|
||||||
} ''
|
} ''
|
||||||
echo '${builtins.toJSON conf}' | jq \
|
jq '{production:del(.[]|nulls)|del(.[][]?|nulls)}' \
|
||||||
'{production:del(.[]|nulls)|del(.[][]?|nulls)}' > $out
|
< ${settingsFormat.generate "hedgedoc-ugly.json" cfg.settings} \
|
||||||
|
> $out
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
(mkRenamedOptionModule [ "services" "codimd" ] [ "services" "hedgedoc" ])
|
(mkRenamedOptionModule [ "services" "codimd" ] [ "services" "hedgedoc" ])
|
||||||
|
(mkRenamedOptionModule
|
||||||
|
[ "services" "hedgedoc" "configuration" ] [ "services" "hedgedoc" "settings" ])
|
||||||
];
|
];
|
||||||
|
|
||||||
options.services.hedgedoc = {
|
options.services.hedgedoc = {
|
||||||
|
@ -45,7 +50,7 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
configuration = {
|
settings = let options = {
|
||||||
debug = mkEnableOption "debug mode";
|
debug = mkEnableOption "debug mode";
|
||||||
domain = mkOption {
|
domain = mkOption {
|
||||||
type = types.nullOr types.str;
|
type = types.nullOr types.str;
|
||||||
|
@ -960,6 +965,16 @@ in
|
||||||
default = null;
|
default = null;
|
||||||
description = "Configure the SAML integration.";
|
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 {
|
environmentFile = mkOption {
|
||||||
|
@ -1000,12 +1015,13 @@ in
|
||||||
Package that provides HedgeDoc.
|
Package that provides HedgeDoc.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
assertions = [
|
assertions = [
|
||||||
{ assertion = cfg.configuration.db == {} -> (
|
{ assertion = cfg.settings.db == {} -> (
|
||||||
cfg.configuration.dbURL != "" && cfg.configuration.dbURL != null
|
cfg.settings.dbURL != "" && cfg.settings.dbURL != null
|
||||||
);
|
);
|
||||||
message = "Database configuration for HedgeDoc missing."; }
|
message = "Database configuration for HedgeDoc missing."; }
|
||||||
];
|
];
|
||||||
|
@ -1026,12 +1042,12 @@ in
|
||||||
preStart = ''
|
preStart = ''
|
||||||
${pkgs.envsubst}/bin/envsubst \
|
${pkgs.envsubst}/bin/envsubst \
|
||||||
-o ${cfg.workDir}/config.json \
|
-o ${cfg.workDir}/config.json \
|
||||||
-i ${prettyJSON cfg.configuration}
|
-i ${prettyJSON cfg.settings}
|
||||||
mkdir -p ${cfg.configuration.uploadsPath}
|
mkdir -p ${cfg.settings.uploadsPath}
|
||||||
'';
|
'';
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
WorkingDirectory = cfg.workDir;
|
WorkingDirectory = cfg.workDir;
|
||||||
StateDirectory = [ cfg.workDir cfg.configuration.uploadsPath ];
|
StateDirectory = [ cfg.workDir cfg.settings.uploadsPath ];
|
||||||
ExecStart = "${cfg.package}/bin/hedgedoc";
|
ExecStart = "${cfg.package}/bin/hedgedoc";
|
||||||
EnvironmentFile = mkIf (cfg.environmentFile != null) [ cfg.environmentFile ];
|
EnvironmentFile = mkIf (cfg.environmentFile != null) [ cfg.environmentFile ];
|
||||||
Environment = [
|
Environment = [
|
||||||
|
|
|
@ -11,7 +11,7 @@ import ./make-test-python.nix ({ pkgs, lib, ... }:
|
||||||
services = {
|
services = {
|
||||||
hedgedoc = {
|
hedgedoc = {
|
||||||
enable = true;
|
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 = {
|
services = {
|
||||||
hedgedoc = {
|
hedgedoc = {
|
||||||
enable = true;
|
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
|
* Do not use pkgs.writeText for secrets as
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue