mirror of
https://github.com/status-im/nim-dagger.git
synced 2025-01-30 16:36:26 +00:00
0cffa02748
Referenced issue: https://github.com/codex-storage/nim-codex/issues/940 Signed-off-by: markoburcul <marko@status.im>
57 lines
1.5 KiB
Nix
57 lines
1.5 KiB
Nix
{ self, config, lib, pkgs, circomCompatPkg, ... }:
|
|
|
|
let
|
|
inherit (lib)
|
|
types mkEnableOption mkOption mkIf literalExpression
|
|
mdDoc;
|
|
|
|
toml = pkgs.formats.toml { };
|
|
|
|
cfg = config.services.nim-codex;
|
|
in
|
|
{
|
|
options = {
|
|
services.nim-codex = {
|
|
enable = mkEnableOption "Nim Codex Node service.";
|
|
|
|
package = mkOption {
|
|
type = types.package;
|
|
default = pkgs.callPackage ./default.nix { src = self; inherit circomCompatPkg; };
|
|
defaultText = literalExpression "pkgs.codex";
|
|
description = mdDoc "Package to use as Nim Codex node.";
|
|
};
|
|
|
|
settings = 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 = {
|
|
"nim-codex/config.toml".source = toml.generate "config.toml" cfg.settings;
|
|
};
|
|
systemd.services.nim-codex = {
|
|
description = "Nim 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=/etc/nim-codex/config.toml";
|
|
Restart = "on-failure";
|
|
};
|
|
restartIfChanged = true;
|
|
restartTriggers = [
|
|
"/etc/nim-codex/config.toml"
|
|
];
|
|
};
|
|
};
|
|
} |