diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 9f9bf3bc532..d4e6f753e9f 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -606,6 +606,7 @@
./services/networking/dnsmasq.nix
./services/networking/ejabberd.nix
./services/networking/epmd.nix
+ ./services/networking/ergo.nix
./services/networking/eternal-terminal.nix
./services/networking/fakeroute.nix
./services/networking/ferm.nix
diff --git a/nixos/modules/services/networking/ergo.nix b/nixos/modules/services/networking/ergo.nix
new file mode 100644
index 00000000000..c52de30dc36
--- /dev/null
+++ b/nixos/modules/services/networking/ergo.nix
@@ -0,0 +1,141 @@
+{ config, lib, pkgs, ... }:
+
+let
+ cfg = config.services.ergo;
+
+ inherit (lib) mkEnableOption mkIf mkOption optionalString types;
+
+ configFile = pkgs.writeText "ergo.conf" (''
+ergo {
+ directory = "${cfg.dataDir}"
+ node {
+ mining = false
+ }
+ wallet.secretStorage.secretDir = "${cfg.dataDir}/wallet/keystore"
+}
+
+scorex {
+ network {
+ bindAddress = "${cfg.listen.ip}:${toString cfg.listen.port}"
+ }
+'' + optionalString (cfg.api.keyHash != null) ''
+ restApi {
+ apiKeyHash = "${cfg.api.keyHash}"
+ bindAddress = "${cfg.api.listen.ip}:${toString cfg.api.listen.port}"
+ }
+'' + ''
+}
+'');
+
+in {
+
+ options = {
+
+ services.ergo = {
+ enable = mkEnableOption "Ergo service";
+
+ dataDir = mkOption {
+ type = types.path;
+ default = "/var/lib/ergo";
+ description = "The data directory for the Ergo node.";
+ };
+
+ listen = {
+ ip = mkOption {
+ type = types.str;
+ default = "0.0.0.0";
+ description = "IP address on which the Ergo node should listen.";
+ };
+
+ port = mkOption {
+ type = types.port;
+ default = 9006;
+ description = "Listen port for the Ergo node.";
+ };
+ };
+
+ api = {
+ keyHash = mkOption {
+ type = types.nullOr types.str;
+ default = null;
+ example = "324dcf027dd4a30a932c441f365a25e86b173defa4b8e58948253471b81b72cf";
+ description = "Hex-encoded Blake2b256 hash of an API key as a 64-chars long Base16 string.";
+ };
+
+ listen = {
+ ip = mkOption {
+ type = types.str;
+ default = "0.0.0.0";
+ description = "IP address that the Ergo node API should listen on if is defined.";
+ };
+
+ port = mkOption {
+ type = types.port;
+ default = 9052;
+ description = "Listen port for the API endpoint if is defined.";
+ };
+ };
+ };
+
+ testnet = mkOption {
+ type = types.bool;
+ default = false;
+ description = "Connect to testnet network instead of the default mainnet.";
+ };
+
+ user = mkOption {
+ type = types.str;
+ default = "ergo";
+ description = "The user as which to run the Ergo node.";
+ };
+
+ group = mkOption {
+ type = types.str;
+ default = cfg.user;
+ description = "The group as which to run the Ergo node.";
+ };
+
+ openFirewall = mkOption {
+ type = types.bool;
+ default = false;
+ description = "Open ports in the firewall for the Ergo node as well as the API.";
+ };
+ };
+ };
+
+ config = mkIf cfg.enable {
+
+ systemd.tmpfiles.rules = [
+ "d '${cfg.dataDir}' 0770 '${cfg.user}' '${cfg.group}' - -"
+ ];
+
+ systemd.services.ergo = {
+ description = "ergo server";
+ wantedBy = [ "multi-user.target" ];
+ after = [ "network-online.target" ];
+ serviceConfig = {
+ User = cfg.user;
+ Group = cfg.group;
+ ExecStart = ''${pkgs.ergo}/bin/ergo \
+ ${optionalString (!cfg.testnet)
+ "--mainnet"} \
+ -c ${configFile}'';
+ };
+ };
+
+ networking.firewall = mkIf cfg.openFirewall {
+ allowedTCPPorts = [ cfg.listen.port ] ++ [ cfg.api.listen.port ];
+ };
+
+ users.users.${cfg.user} = {
+ name = cfg.user;
+ group = cfg.group;
+ description = "Ergo daemon user";
+ home = cfg.dataDir;
+ isSystemUser = true;
+ };
+
+ users.groups.${cfg.group} = {};
+
+ };
+}
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 47ca015632c..611e89b7285 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -90,6 +90,7 @@ in
engelsystem = handleTest ./engelsystem.nix {};
enlightenment = handleTest ./enlightenment.nix {};
env = handleTest ./env.nix {};
+ ergo = handleTest ./ergo.nix {};
etcd = handleTestOn ["x86_64-linux"] ./etcd.nix {};
etcd-cluster = handleTestOn ["x86_64-linux"] ./etcd-cluster.nix {};
fancontrol = handleTest ./fancontrol.nix {};
diff --git a/nixos/tests/ergo.nix b/nixos/tests/ergo.nix
new file mode 100644
index 00000000000..8cdbbf62a95
--- /dev/null
+++ b/nixos/tests/ergo.nix
@@ -0,0 +1,18 @@
+import ./make-test-python.nix ({ pkgs, ... }: {
+ name = "ergo";
+ meta = with pkgs.stdenv.lib.maintainers; {
+ maintainers = [ mmahut ];
+ };
+
+ nodes = {
+ machine = { ... }: {
+ services.ergo.enable = true;
+ services.ergo.api.keyHash = "324dcf027dd4a30a932c441f365a25e86b173defa4b8e58948253471b81b72cf";
+ };
+ };
+
+ testScript = ''
+ start_all()
+ machine.wait_for_unit("ergo.service")
+ '';
+})
diff --git a/pkgs/applications/blockchains/ergo/default.nix b/pkgs/applications/blockchains/ergo/default.nix
new file mode 100644
index 00000000000..bae7326c255
--- /dev/null
+++ b/pkgs/applications/blockchains/ergo/default.nix
@@ -0,0 +1,27 @@
+{ stdenv, fetchurl, makeWrapper, jre }:
+
+stdenv.mkDerivation rec {
+ pname = "ergo";
+ version = "3.2.5";
+
+ src = fetchurl {
+ url = "https://github.com/ergoplatform/ergo/releases/download/v${version}/ergo-${version}.jar";
+ sha256 = "0vaq6cqz03ps0fg3rvk298jnbf8mazvmyfcj7zsf1cgw41xdjjcf";
+ };
+
+ nativeBuildInputs = [ makeWrapper ];
+
+ dontUnpack = true;
+
+ installPhase = ''
+ makeWrapper ${jre}/bin/java $out/bin/ergo --add-flags "-jar $src"
+ '';
+
+ meta = with stdenv.lib; {
+ description = "Open protocol that implements modern scientific ideas in the blockchain area";
+ homepage = "https://ergoplatform.org/en/";
+ license = licenses.cc0;
+ platforms = platforms.all;
+ maintainers = with maintainers; [ mmahut ];
+ };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 8774a23c70c..bbac14b4852 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -23294,6 +23294,8 @@ in
dogecoin = callPackage ../applications/blockchains/dogecoin.nix { boost = boost165; withGui = true; };
dogecoind = callPackage ../applications/blockchains/dogecoin.nix { boost = boost165; withGui = false; };
+ ergo = callPackage ../applications/blockchains/ergo { };
+
exodus = callPackage ../applications/blockchains/exodus { };
freicoin = callPackage ../applications/blockchains/freicoin.nix { boost = boost155; };