mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-03 05:53:07 +00:00
configObject option is used to define the configuration which is then dumped to a toml file and is used as input to codex binary(conditionally). Signed-off-by: markoburcul <marko@status.im>
59 lines
1.6 KiB
Nix
59 lines
1.6 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
inherit (lib)
|
|
types mkEnableOption mkOption mkIf literalExpression;
|
|
|
|
toml = pkgs.formats.toml { };
|
|
|
|
cfg = config.services.codex;
|
|
in
|
|
{
|
|
options = {
|
|
services.codex = {
|
|
enable = mkEnableOption "Codex Node service.";
|
|
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = pkgs.callPackage ./default.nix { };
|
|
defaultText = literalExpression "pkgs.codex";
|
|
description = lib.mdDoc "Package to use as Codex node.";
|
|
};
|
|
|
|
configFile = mkOption {
|
|
type = types.nullOr types.str;
|
|
default = null;
|
|
description = "Path to the Codex configuration file.";
|
|
};
|
|
|
|
configObject = lib.mkOption {
|
|
default = { };
|
|
type = toml.type;
|
|
description = ''Structured settings object that will be used to generate a TOML config file.'';
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
environment.etc = {
|
|
"codex/config.toml".source = toml.generate "config.toml" cfg.configObject;
|
|
};
|
|
systemd.services.codex = {
|
|
description = "Codex Node";
|
|
wantedBy = [ "multi-user.target" ];
|
|
requires = [ "network.target" ];
|
|
serviceConfig = {
|
|
DynamicUser = true;
|
|
PrivateTmp = true;
|
|
ProtectHome = true;
|
|
ProtectSystem = "full";
|
|
NoNewPrivileges = true;
|
|
PrivateDevices = true;
|
|
MemoryDenyWriteExecute = true;
|
|
ExecStart = ''${cfg.package}/bin/codex --config-file=${if cfg.configFile != null then cfg.configFile else "/etc/codex/config.toml"}'';
|
|
Restart = "on-failure";
|
|
};
|
|
};
|
|
};
|
|
}
|