Merge pull request #201963 from zhaofengli/moonraker-2022-11-18
moonraker: unstable-2022-04-23 -> unstable-2022-11-18, nixos/moonraker: fixes
This commit is contained in:
commit
34f3085148
@ -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;
|
||||
};
|
||||
machine = {
|
||||
validate_service = false;
|
||||
};
|
||||
} // (lib.optionalAttrs (cfg.configDir != null) {
|
||||
file_manager = {
|
||||
config_path = cfg.configDir;
|
||||
};
|
||||
database = {
|
||||
database_path = "${cfg.stateDir}/database";
|
||||
};
|
||||
};
|
||||
});
|
||||
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 -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
|
||||
@ -184,5 +202,6 @@ in {
|
||||
meta.maintainers = with maintainers; [
|
||||
cab404
|
||||
vtuan10
|
||||
zhaofengli
|
||||
];
|
||||
}
|
||||
|
@ -20,13 +20,13 @@ let
|
||||
]);
|
||||
in stdenvNoCC.mkDerivation rec {
|
||||
pname = "moonraker";
|
||||
version = "unstable-2022-04-23";
|
||||
version = "unstable-2022-11-18";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "Arksine";
|
||||
repo = "moonraker";
|
||||
rev = "cd520ba91728abb5a3d959269fbd8e4f40d1eb0b";
|
||||
sha256 = "sha256-sopX9t+LjYldx+syKwU3I0x/VYy4hLyXfitG0uumayE=";
|
||||
rev = "362bc1a3d3ad397416f7fc48b8efe33837428b90";
|
||||
sha256 = "sha256-cebRHOx2hg470jM1CoQAk13Whv+KN2qx97BTlpjxSZg=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
Loading…
Reference in New Issue
Block a user