nixos/services.octoprint: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-24 22:05:51 +02:00
parent a99bf84530
commit d40cf96f75

View File

@ -1,7 +1,4 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.octoprint;
@ -13,7 +10,7 @@ let
webcam.ffmpeg = "${pkgs.ffmpeg.bin}/bin/ffmpeg";
};
fullConfig = recursiveUpdate cfg.extraConfig baseConfig;
fullConfig = lib.recursiveUpdate cfg.extraConfig baseConfig;
cfgUpdate = pkgs.writeText "octoprint-config.yaml" (builtins.toJSON fullConfig);
@ -29,58 +26,58 @@ in
services.octoprint = {
enable = mkEnableOption "OctoPrint, web interface for 3D printers";
enable = lib.mkEnableOption "OctoPrint, web interface for 3D printers";
host = mkOption {
type = types.str;
host = lib.mkOption {
type = lib.types.str;
default = "0.0.0.0";
description = ''
Host to bind OctoPrint to.
'';
};
port = mkOption {
type = types.port;
port = lib.mkOption {
type = lib.types.port;
default = 5000;
description = ''
Port to bind OctoPrint to.
'';
};
openFirewall = mkOption {
type = types.bool;
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = "Open ports in the firewall for OctoPrint.";
};
user = mkOption {
type = types.str;
user = lib.mkOption {
type = lib.types.str;
default = "octoprint";
description = "User for the daemon.";
};
group = mkOption {
type = types.str;
group = lib.mkOption {
type = lib.types.str;
default = "octoprint";
description = "Group for the daemon.";
};
stateDir = mkOption {
type = types.path;
stateDir = lib.mkOption {
type = lib.types.path;
default = "/var/lib/octoprint";
description = "State directory of the daemon.";
};
plugins = mkOption {
type = types.functionTo (types.listOf types.package);
plugins = lib.mkOption {
type = lib.types.functionTo (lib.types.listOf lib.types.package);
default = plugins: [ ];
defaultText = literalExpression "plugins: []";
example = literalExpression "plugins: with plugins; [ themeify stlviewer ]";
defaultText = lib.literalExpression "plugins: []";
example = lib.literalExpression "plugins: with plugins; [ themeify stlviewer ]";
description = "Additional plugins to be used. Available plugins are passed through the plugins input.";
};
extraConfig = mkOption {
type = types.attrs;
extraConfig = lib.mkOption {
type = lib.types.attrs;
default = { };
description = "Extra options which are added to OctoPrint's YAML configuration file.";
};
@ -91,16 +88,16 @@ in
##### implementation
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
users.users = optionalAttrs (cfg.user == "octoprint") {
users.users = lib.optionalAttrs (cfg.user == "octoprint") {
octoprint = {
group = cfg.group;
uid = config.ids.uids.octoprint;
};
};
users.groups = optionalAttrs (cfg.group == "octoprint") {
users.groups = lib.optionalAttrs (cfg.group == "octoprint") {
octoprint.gid = config.ids.gids.octoprint;
};
@ -137,6 +134,6 @@ in
};
};
networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ];
networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [ cfg.port ];
};
}