nixos/moonraker: Deprecate configDir
The config_path setting has been deprecated upstream. Mutable config files are now supposed to live under the unified data path.
This commit is contained in:
parent
7658372185
commit
7856ac79ac
|
@ -11,6 +11,8 @@ let
|
|||
else lib.concatMapStrings (s: "\n ${generators.mkValueStringDefault {} s}") l;
|
||||
mkKeyValue = generators.mkKeyValueDefault {} ":";
|
||||
};
|
||||
|
||||
unifiedConfigDir = cfg.stateDir + "/config";
|
||||
in {
|
||||
options = {
|
||||
services.moonraker = {
|
||||
|
@ -30,11 +32,10 @@ in {
|
|||
};
|
||||
|
||||
configDir = mkOption {
|
||||
type = types.path;
|
||||
default = cfg.stateDir + "/config";
|
||||
defaultText = literalExpression ''config.${opt.stateDir} + "/config"'';
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
description = lib.mdDoc ''
|
||||
The directory containing client-writable configuration files.
|
||||
Deprecated directory containing client-writable configuration files.
|
||||
|
||||
Clients will be able to edit files in this directory via the API. This directory must be writable.
|
||||
'';
|
||||
|
@ -96,8 +97,18 @@ in {
|
|||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
warnings = optional (cfg.settings ? update_manager)
|
||||
''Enabling update_manager is not supported on NixOS and will lead to non-removable warnings in some clients.'';
|
||||
warnings = []
|
||||
++ optional (cfg.settings ? update_manager)
|
||||
''Enabling update_manager is not supported on NixOS and will lead to non-removable warnings in some clients.''
|
||||
++ optional (cfg.configDir != null)
|
||||
''
|
||||
services.moonraker.configDir has been deprecated upstream and will be removed.
|
||||
|
||||
Action: ${
|
||||
if cfg.configDir == unifiedConfigDir then "Simply remove services.moonraker.configDir from your config."
|
||||
else "Move files from `${cfg.configDir}` to `${unifiedConfigDir}` then remove services.moonraker.configDir from your config."
|
||||
}
|
||||
'';
|
||||
|
||||
assertions = [
|
||||
{
|
||||
|
@ -124,20 +135,20 @@ in {
|
|||
port = cfg.port;
|
||||
klippy_uds_address = cfg.klipperSocket;
|
||||
};
|
||||
file_manager = {
|
||||
config_path = cfg.configDir;
|
||||
};
|
||||
database = {
|
||||
database_path = "${cfg.stateDir}/database";
|
||||
};
|
||||
};
|
||||
} // (lib.optionalAttrs (cfg.configDir != null) {
|
||||
file_manager = {
|
||||
config_path = cfg.configDir;
|
||||
};
|
||||
});
|
||||
fullConfig = recursiveUpdate cfg.settings forcedConfig;
|
||||
in format.generate "moonraker.cfg" fullConfig;
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"d '${cfg.stateDir}' - ${cfg.user} ${cfg.group} - -"
|
||||
"d '${cfg.configDir}' - ${cfg.user} ${cfg.group} - -"
|
||||
];
|
||||
] ++ lib.optional (cfg.configDir != null) "d '${cfg.configDir}' - ${cfg.user} ${cfg.group} - -";
|
||||
|
||||
systemd.services.moonraker = {
|
||||
description = "Moonraker, an API web server for Klipper";
|
||||
|
@ -147,9 +158,16 @@ in {
|
|||
|
||||
# Moonraker really wants its own config to be writable...
|
||||
script = ''
|
||||
cp /etc/moonraker.cfg ${cfg.configDir}/moonraker-temp.cfg
|
||||
chmod u+w ${cfg.configDir}/moonraker-temp.cfg
|
||||
exec ${pkg}/bin/moonraker -d ${cfg.stateDir} -c ${cfg.configDir}/moonraker-temp.cfg
|
||||
config_path=${
|
||||
# Deprecated separate config dir
|
||||
if cfg.configDir != null then "${cfg.configDir}/moonraker-temp.cfg"
|
||||
# Config in unified data path
|
||||
else "${unifiedConfigDir}/moonraker-temp.cfg"
|
||||
}
|
||||
mkdir -p $(dirname "$config_path")
|
||||
cp /etc/moonraker.cfg "$config_path"
|
||||
chmod u+w "$config_path"
|
||||
exec ${pkg}/bin/moonraker -d ${cfg.stateDir} -c "$config_path"
|
||||
'';
|
||||
|
||||
# Needs `ip` command
|
||||
|
|
Loading…
Reference in a new issue