Skip to content

Commit 9c504bf

Browse files
sgillespiekderme
authored andcommitted
Add disableLedger option to NixOS module (#1430)
1 parent 1f39c5e commit 9c504bf

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

nix/nixos/cardano-db-sync-service.nix

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ in {
126126
type = lib.types.nullOr lib.types.str;
127127
default = "/var/lib/cexplorer";
128128
};
129+
disableLedger = lib.mkOption {
130+
type = lib.types.bool;
131+
default = false;
132+
description = ''
133+
Disables the leger state. Drastically reduces memory usage
134+
and it syncs faster, but some data are missing.
135+
'';
136+
};
129137
dbSyncPkgs = lib.mkOption {
130138
type = lib.types.attrs;
131139
default = import ../. { };
@@ -177,6 +185,16 @@ in {
177185
(if (cfg.environment.nodeConfig.RequiresNetworkMagic == "RequiresNoMagic" )
178186
then "--mainnet"
179187
else "--testnet-magic $(jq '.networkMagic' ${cfg.environment.nodeConfig.ShelleyGenesisFile})");
188+
dbSyncCommand = ''
189+
exec ${exec} \
190+
--config ${configFile} \
191+
--socket-path "$CARDANO_NODE_SOCKET_PATH" \
192+
--schema-dir ${self.schema} \
193+
${if cfg.disableLedger then
194+
"--disable-ledger"
195+
else
196+
"--state-dir ${cfg.stateDir}"}
197+
'';
180198
in {
181199
pgpass = builtins.toFile "pgpass" "${cfg.postgres.socketdir}:${
182200
toString cfg.postgres.port
@@ -225,12 +243,7 @@ in {
225243
fi
226244
227245
mkdir -p log-dir
228-
exec ${exec} \
229-
--config ${configFile} \
230-
--socket-path "$CARDANO_NODE_SOCKET_PATH" \
231-
--schema-dir ${self.schema} \
232-
--state-dir ${cfg.stateDir} \
233-
''${EXTRA_DB_SYNC_ARGS:-}'';
246+
${dbSyncCommand}'';
234247
};
235248
systemd.services.cardano-db-sync = {
236249
wantedBy = [ "multi-user.target" ];

0 commit comments

Comments
 (0)