diff options
author | Marek Mahut <marek.mahut@gmail.com> | 2019-08-21 19:53:51 +0200 |
---|---|---|
committer | Marek Mahut <marek.mahut@gmail.com> | 2019-08-22 07:10:16 +0200 |
commit | ddc0521ebf64c75b02f58fa28ef29c31a8f423f5 (patch) | |
tree | e78d35a039bd3bc968f5a83ea5617d6812f21ac0 /nixos/modules | |
parent | d1bfaf54af12e6a9eb6bf8b7fd22ae1782ca27c6 (diff) | |
download | nixlib-ddc0521ebf64c75b02f58fa28ef29c31a8f423f5.tar nixlib-ddc0521ebf64c75b02f58fa28ef29c31a8f423f5.tar.gz nixlib-ddc0521ebf64c75b02f58fa28ef29c31a8f423f5.tar.bz2 nixlib-ddc0521ebf64c75b02f58fa28ef29c31a8f423f5.tar.lz nixlib-ddc0521ebf64c75b02f58fa28ef29c31a8f423f5.tar.xz nixlib-ddc0521ebf64c75b02f58fa28ef29c31a8f423f5.tar.zst nixlib-ddc0521ebf64c75b02f58fa28ef29c31a8f423f5.zip |
nixos: adding jormungandr service
Diffstat (limited to 'nixos/modules')
-rw-r--r-- | nixos/modules/module-list.nix | 1 | ||||
-rw-r--r-- | nixos/modules/services/networking/jormungandr.nix | 97 |
2 files changed, 98 insertions, 0 deletions
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 27df3c39117d..50b648d0629e 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -608,6 +608,7 @@ ./services/networking/iodine.nix ./services/networking/iperf3.nix ./services/networking/ircd-hybrid/default.nix + ./services/networking/jormungandr.nix ./services/networking/iwd.nix ./services/networking/keepalived/default.nix ./services/networking/keybase.nix diff --git a/nixos/modules/services/networking/jormungandr.nix b/nixos/modules/services/networking/jormungandr.nix new file mode 100644 index 000000000000..c1a16a316b7a --- /dev/null +++ b/nixos/modules/services/networking/jormungandr.nix @@ -0,0 +1,97 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.services.jormungandr; + + inherit (lib) mkEnableOption mkIf mkOption; + inherit (lib) optionalString types; + + dataDir = "/var/lib/jormungandr"; + + # Default settings so far, as the service matures we will + # move these out as separate settings + configSettings = { + storage = dataDir; + p2p = { + public_address = "/ip4/127.0.0.1/tcp/8606"; + messages = "high"; + blocks = "high"; + }; + rest = { + listen = "127.0.0.1:8607"; + }; + }; + + configFile = if cfg.configFile == null then + pkgs.writeText "jormungandr.yaml" (builtins.toJSON configSettings) + else cfg.configFile; + +in { + + options = { + + services.jormungandr = { + enable = mkEnableOption "jormungandr service"; + + configFile = mkOption { + type = types.nullOr types.path; + default = null; + example = "/var/lib/jormungandr/node.yaml"; + description = '' + The path of the jormungandr blockchain configuration file in YAML format. + If no file is specified, a file is generated using the other options. + ''; + }; + + secretFile = mkOption { + type = types.nullOr types.path; + default = null; + example = "/etc/secret/jormungandr.yaml"; + description = '' + The path of the jormungandr blockchain secret node configuration file in + YAML format. Do not store this in nix store! + ''; + }; + + genesisBlockHash = mkOption { + type = types.nullOr types.string; + default = null; + example = "d70495af81ae8600aca3e642b2427327cb6001ec4d7a0037e96a00dabed163f9"; + description = '' + Set the genesis block hash (the hash of the block0) so we can retrieve + the genesis block (and the blockchain configuration) from the existing + storage or from the network. + ''; + }; + + genesisBlockFile = mkOption { + type = types.nullOr types.path; + default = null; + example = "/var/lib/jormungandr/block-0.bin"; + description = '' + The path of the genesis block file if we are hosting it locally. + ''; + }; + + }; + }; + + config = mkIf cfg.enable { + + systemd.services.jormungandr = { + description = "jormungandr server"; + wantedBy = [ "multi-user.target" ]; + after = [ "network-online.target" ]; + serviceConfig = { + DynamicUser = true; + StateDirectory = baseNameOf dataDir; + ExecStart = '' + ${pkgs.jormungandr}/bin/jormungandr --config ${configFile} \ + ${optionalString (cfg.secretFile != null) " --secret ${cfg.secretFile}"} \ + ${optionalString (cfg.genesisBlockHash != null) " --genesis-block-hash ${cfg.genesisBlockHash}"} \ + ${optionalString (cfg.genesisBlockFile != null) " --genesis-block ${cfg.genesisBlockFile}"} + ''; + }; + }; + }; +} |