about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorFelix Buehler2024-08-24 22:05:49 +0200
committerFelix Buehler2024-08-30 23:00:53 +0200
commite00ab2106aca2fd4bdb0524f969cf46fb6622ccb (patch)
tree0237f61f6907f11f9e883ddf42ae7ca075798ea7 /nixos
parenta4db992d510782ec5620e181354989297f1a94c0 (diff)
nixos/services.moonraker: remove `with lib;`
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/misc/moonraker.nix63
1 files changed, 31 insertions, 32 deletions
diff --git a/nixos/modules/services/misc/moonraker.nix b/nixos/modules/services/misc/moonraker.nix
index 1461f1048b03..b9ddace19e91 100644
--- a/nixos/modules/services/misc/moonraker.nix
+++ b/nixos/modules/services/misc/moonraker.nix
@@ -1,5 +1,4 @@
 { config, lib, options, pkgs, ... }:
-with lib;
 let
   cfg = config.services.moonraker;
   pkg = cfg.package;
@@ -7,37 +6,37 @@ let
   format = pkgs.formats.ini {
     # https://github.com/NixOS/nixpkgs/pull/121613#issuecomment-885241996
     listToValue = l:
-      if builtins.length l == 1 then generators.mkValueStringDefault {} (head l)
-      else lib.concatMapStrings (s: "\n  ${generators.mkValueStringDefault {} s}") l;
-    mkKeyValue = generators.mkKeyValueDefault {} ":";
+      if builtins.length l == 1 then lib.generators.mkValueStringDefault {} (lib.head l)
+      else lib.concatMapStrings (s: "\n  ${lib.generators.mkValueStringDefault {} s}") l;
+    mkKeyValue = lib.generators.mkKeyValueDefault {} ":";
   };
 
   unifiedConfigDir = cfg.stateDir + "/config";
 in {
   options = {
     services.moonraker = {
-      enable = mkEnableOption "Moonraker, an API web server for Klipper";
+      enable = lib.mkEnableOption "Moonraker, an API web server for Klipper";
 
-      package = mkPackageOption pkgs "moonraker" {
+      package = lib.mkPackageOption pkgs "moonraker" {
         nullable = true;
         example = "moonraker.override { useGpiod = true; }";
       };
 
-      klipperSocket = mkOption {
-        type = types.path;
+      klipperSocket = lib.mkOption {
+        type = lib.types.path;
         default = config.services.klipper.apiSocket;
-        defaultText = literalExpression "config.services.klipper.apiSocket";
+        defaultText = lib.literalExpression "config.services.klipper.apiSocket";
         description = "Path to Klipper's API socket.";
       };
 
-      stateDir = mkOption {
-        type = types.path;
+      stateDir = lib.mkOption {
+        type = lib.types.path;
         default = "/var/lib/moonraker";
         description = "The directory containing the Moonraker databases.";
       };
 
-      configDir = mkOption {
-        type = types.nullOr types.path;
+      configDir = lib.mkOption {
+        type = lib.types.nullOr lib.types.path;
         default = null;
         description = ''
           Deprecated directory containing client-writable configuration files.
@@ -46,32 +45,32 @@ in {
         '';
       };
 
-      user = mkOption {
-        type = types.str;
+      user = lib.mkOption {
+        type = lib.types.str;
         default = "moonraker";
         description = "User account under which Moonraker runs.";
       };
 
-      group = mkOption {
-        type = types.str;
+      group = lib.mkOption {
+        type = lib.types.str;
         default = "moonraker";
         description = "Group account under which Moonraker runs.";
       };
 
-      address = mkOption {
-        type = types.str;
+      address = lib.mkOption {
+        type = lib.types.str;
         default = "127.0.0.1";
         example = "0.0.0.0";
         description = "The IP or host to listen on.";
       };
 
-      port = mkOption {
-        type = types.ints.unsigned;
+      port = lib.mkOption {
+        type = lib.types.ints.unsigned;
         default = 7125;
         description = "The port to listen on.";
       };
 
-      settings = mkOption {
+      settings = lib.mkOption {
         type = format.type;
         default = { };
         example = {
@@ -86,8 +85,8 @@ in {
         '';
       };
 
-      allowSystemControl = mkOption {
-        type = types.bool;
+      allowSystemControl = lib.mkOption {
+        type = lib.types.bool;
         default = false;
         description = ''
           Whether to allow Moonraker to perform system-level operations.
@@ -101,12 +100,12 @@ in {
     };
   };
 
-  config = mkIf cfg.enable {
+  config = lib.mkIf cfg.enable {
     warnings = []
-      ++ (optional (head (cfg.settings.update_manager.enable_system_updates or [false])) ''
+      ++ (lib.optional (lib.head (cfg.settings.update_manager.enable_system_updates or [false])) ''
         Enabling system updates is not supported on NixOS and will lead to non-removable warnings in some clients.
       '')
-      ++ (optional (cfg.configDir != null) ''
+      ++ (lib.optional (cfg.configDir != null) ''
         services.moonraker.configDir has been deprecated upstream and will be removed.
 
         Action: ${
@@ -123,14 +122,14 @@ in {
       }
     ];
 
-    users.users = optionalAttrs (cfg.user == "moonraker") {
+    users.users = lib.optionalAttrs (cfg.user == "moonraker") {
       moonraker = {
         group = cfg.group;
         uid = config.ids.uids.moonraker;
       };
     };
 
-    users.groups = optionalAttrs (cfg.group == "moonraker") {
+    users.groups = lib.optionalAttrs (cfg.group == "moonraker") {
       moonraker.gid = config.ids.gids.moonraker;
     };
 
@@ -149,7 +148,7 @@ in {
           config_path = cfg.configDir;
         };
       });
-      fullConfig = recursiveUpdate cfg.settings forcedConfig;
+      fullConfig = lib.recursiveUpdate cfg.settings forcedConfig;
     in format.generate "moonraker.cfg" fullConfig;
 
     systemd.tmpfiles.rules = [
@@ -160,7 +159,7 @@ in {
       description = "Moonraker, an API web server for Klipper";
       wantedBy = [ "multi-user.target" ];
       after = [ "network.target" ]
-        ++ optional config.services.klipper.enable "klipper.service";
+        ++ lib.optional config.services.klipper.enable "klipper.service";
 
       # Moonraker really wants its own config to be writable...
       script = ''
@@ -211,7 +210,7 @@ in {
     '';
   };
 
-  meta.maintainers = with maintainers; [
+  meta.maintainers = with lib.maintainers; [
     cab404
     vtuan10
     zhaofengli