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:
K900 2023-02-14 21:00:44 +03:00 committed by GitHub
commit 34f3085148
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 37 additions and 18 deletions

View File

@ -11,6 +11,8 @@ let
else lib.concatMapStrings (s: "\n ${generators.mkValueStringDefault {} s}") l; else lib.concatMapStrings (s: "\n ${generators.mkValueStringDefault {} s}") l;
mkKeyValue = generators.mkKeyValueDefault {} ":"; mkKeyValue = generators.mkKeyValueDefault {} ":";
}; };
unifiedConfigDir = cfg.stateDir + "/config";
in { in {
options = { options = {
services.moonraker = { services.moonraker = {
@ -30,11 +32,10 @@ in {
}; };
configDir = mkOption { configDir = mkOption {
type = types.path; type = types.nullOr types.path;
default = cfg.stateDir + "/config"; default = null;
defaultText = literalExpression ''config.${opt.stateDir} + "/config"'';
description = lib.mdDoc '' 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. 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 { config = mkIf cfg.enable {
warnings = optional (cfg.settings ? update_manager) warnings = []
''Enabling update_manager is not supported on NixOS and will lead to non-removable warnings in some clients.''; ++ 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 = [ assertions = [
{ {
@ -124,20 +135,20 @@ in {
port = cfg.port; port = cfg.port;
klippy_uds_address = cfg.klipperSocket; klippy_uds_address = cfg.klipperSocket;
}; };
machine = {
validate_service = false;
};
} // (lib.optionalAttrs (cfg.configDir != null) {
file_manager = { file_manager = {
config_path = cfg.configDir; config_path = cfg.configDir;
}; };
database = { });
database_path = "${cfg.stateDir}/database";
};
};
fullConfig = recursiveUpdate cfg.settings forcedConfig; fullConfig = recursiveUpdate cfg.settings forcedConfig;
in format.generate "moonraker.cfg" fullConfig; in format.generate "moonraker.cfg" fullConfig;
systemd.tmpfiles.rules = [ systemd.tmpfiles.rules = [
"d '${cfg.stateDir}' - ${cfg.user} ${cfg.group} - -" "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 = { systemd.services.moonraker = {
description = "Moonraker, an API web server for Klipper"; description = "Moonraker, an API web server for Klipper";
@ -147,9 +158,16 @@ in {
# Moonraker really wants its own config to be writable... # Moonraker really wants its own config to be writable...
script = '' script = ''
cp /etc/moonraker.cfg ${cfg.configDir}/moonraker-temp.cfg config_path=${
chmod u+w ${cfg.configDir}/moonraker-temp.cfg # Deprecated separate config dir
exec ${pkg}/bin/moonraker -c ${cfg.configDir}/moonraker-temp.cfg 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 # Needs `ip` command
@ -184,5 +202,6 @@ in {
meta.maintainers = with maintainers; [ meta.maintainers = with maintainers; [
cab404 cab404
vtuan10 vtuan10
zhaofengli
]; ];
} }

View File

@ -20,13 +20,13 @@ let
]); ]);
in stdenvNoCC.mkDerivation rec { in stdenvNoCC.mkDerivation rec {
pname = "moonraker"; pname = "moonraker";
version = "unstable-2022-04-23"; version = "unstable-2022-11-18";
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "Arksine"; owner = "Arksine";
repo = "moonraker"; repo = "moonraker";
rev = "cd520ba91728abb5a3d959269fbd8e4f40d1eb0b"; rev = "362bc1a3d3ad397416f7fc48b8efe33837428b90";
sha256 = "sha256-sopX9t+LjYldx+syKwU3I0x/VYy4hLyXfitG0uumayE="; sha256 = "sha256-cebRHOx2hg470jM1CoQAk13Whv+KN2qx97BTlpjxSZg=";
}; };
nativeBuildInputs = [ makeWrapper ]; nativeBuildInputs = [ makeWrapper ];