15 json = pkgs.formats.json { };
17 cfg = config.services.zenohd;
23 enable = lib.mkEnableOption "Zenoh daemon.";
26 description = "The zenoh package to use.";
29 defaultText = "pkgs.zenoh";
34 Config options for `zenoh.json5` configuration file.
36 See <https://github.com/eclipse-zenoh/zenoh/blob/main/DEFAULT_CONFIG.json5>
40 type = types.submodule {
41 freeformType = json.type;
46 description = "Plugin packages to add to zenohd search paths.";
47 type = with types; listOf package;
49 example = lib.literalExpression ''
50 [ pkgs.zenoh-plugin-mqtt ]
55 description = "Storage backend packages to add to zenohd search paths.";
56 type = with types; listOf package;
58 example = lib.literalExpression ''
59 [ pkgs.zenoh-backend-rocksdb ]
64 description = "Base directory for zenohd related files defined via ZENOH_HOME.";
66 default = "/var/lib/zenoh";
71 Set environment variables consumed by zenohd and its plugins.
73 type = with types; attrsOf str;
77 extraOptions = mkOption {
78 description = "Extra command line options for zenohd.";
79 type = with types; listOf str;
85 config = lib.mkIf cfg.enable {
86 systemd.services.zenohd =
88 cfgFile = json.generate "zenohd.json" cfg.settings;
92 wantedBy = [ "multi-user.target" ];
93 wants = [ "network-online.target" ];
94 after = [ "network-online.target" ];
96 environment = cfg.env;
103 "${lib.getExe cfg.package} -c ${cfgFile} " + (lib.concatStringsSep " " cfg.extraOptions);
109 description = "Zenoh daemon user";
118 env.ZENOH_HOME = cfg.home;
122 enabled = mkDefault true;
123 search_dirs = mkDefault (
124 (map (x: "${lib.getLib x}/lib") cfg.plugins) ++ [ "${lib.getLib cfg.package}/lib" ]
125 ); # needed for internal plugins
128 plugins.storage_manager.backend_search_dirs = mkDefault (
129 map (x: "${lib.getLib x}/lib") cfg.backends
134 systemd.tmpfiles.rules = [ "d ${cfg.home} 750 zenohd zenohd -" ];