mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 04:35:41 +03:00
nixos/services.zwave-js: remove with lib;
This commit is contained in:
parent
5645a33f6a
commit
5eba86d6f2
1 changed files with 13 additions and 16 deletions
|
@ -1,35 +1,32 @@
|
|||
{config, pkgs, lib, ...}:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.zwave-js;
|
||||
mergedConfigFile = "/run/zwave-js/config.json";
|
||||
settingsFormat = pkgs.formats.json {};
|
||||
in {
|
||||
options.services.zwave-js = {
|
||||
enable = mkEnableOption "the zwave-js server on boot";
|
||||
enable = lib.mkEnableOption "the zwave-js server on boot";
|
||||
|
||||
package = mkPackageOption pkgs "zwave-js-server" { };
|
||||
package = lib.mkPackageOption pkgs "zwave-js-server" { };
|
||||
|
||||
port = mkOption {
|
||||
type = types.port;
|
||||
port = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
default = 3000;
|
||||
description = ''
|
||||
Port for the server to listen on.
|
||||
'';
|
||||
};
|
||||
|
||||
serialPort = mkOption {
|
||||
type = types.path;
|
||||
serialPort = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = ''
|
||||
Serial port device path for Z-Wave controller.
|
||||
'';
|
||||
example = "/dev/ttyUSB0";
|
||||
};
|
||||
|
||||
secretsConfigFile = mkOption {
|
||||
type = types.path;
|
||||
secretsConfigFile = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = ''
|
||||
JSON file containing secret keys. A dummy example:
|
||||
|
||||
|
@ -62,14 +59,14 @@ in {
|
|||
example = "/secrets/zwave-js-keys.json";
|
||||
};
|
||||
|
||||
settings = mkOption {
|
||||
settings = lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
freeformType = settingsFormat.type;
|
||||
|
||||
options = {
|
||||
storage = {
|
||||
cacheDir = mkOption {
|
||||
type = types.path;
|
||||
cacheDir = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
default = "/var/cache/zwave-js";
|
||||
readOnly = true;
|
||||
description = "Cache directory";
|
||||
|
@ -94,7 +91,7 @@ in {
|
|||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
config = lib.mkIf cfg.enable {
|
||||
systemd.services.zwave-js = let
|
||||
configFile = settingsFormat.generate "zwave-js-config.json" cfg.settings;
|
||||
in {
|
||||
|
@ -110,7 +107,7 @@ in {
|
|||
"--config ${mergedConfigFile}"
|
||||
"--port ${toString cfg.port}"
|
||||
cfg.serialPort
|
||||
(escapeShellArgs cfg.extraFlags)
|
||||
(lib.escapeShellArgs cfg.extraFlags)
|
||||
];
|
||||
Restart = "on-failure";
|
||||
User = "zwave-js";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue