Skip to content

Commit d116e8c

Browse files
committed
build(nix): Add profiling options to nixos service
1 parent fc89bce commit d116e8c

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

flake.nix

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,11 @@
399399
let
400400
pkgs' = self.legacyPackages.${pkgs.system};
401401
in {
402-
inherit (pkgs') cardanoLib schema cardano-db-sync;
402+
inherit (pkgs')
403+
cardanoLib
404+
schema
405+
cardano-db-sync
406+
cardano-db-sync-profiled;
403407

404408
# cardano-db-tool
405409
cardanoDbSyncHaskellPackages.cardano-db-tool.components.exes.cardano-db-tool =

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,27 @@ in {
1616
internal = true;
1717
type = lib.types.package;
1818
};
19+
profiling = lib.mkOption {
20+
type = lib.types.bool;
21+
default = false;
22+
description = ''
23+
Enable GHC profiling.
24+
'';
25+
};
26+
rtsArgs = lib.mkOption {
27+
type = lib.types.listOf lib.types.str;
28+
default =
29+
if cfg.profiling then
30+
[ "-p" "-hc" "-L200"]
31+
else
32+
[ ];
33+
apply = args:
34+
if (args != []) then
35+
["+RTS"] ++ args ++ ["-RTS"]
36+
else
37+
[];
38+
description = ''Extra CLI args, to be surrounded by "+RTS"/"-RTS"'';
39+
};
1940
takeSnapshot = lib.mkOption {
2041
type = lib.types.enum [ "never" "once" "always" ];
2142
default = "never";
@@ -146,7 +167,11 @@ in {
146167
};
147168
package = lib.mkOption {
148169
type = lib.types.package;
149-
default = self.cardano-db-sync;
170+
default =
171+
if cfg.profiling then
172+
self.cardano-db-sync-profiled
173+
else
174+
self.cardano-db-sync;
150175
};
151176
postgres = {
152177
generatePGPASS = lib.mkOption {
@@ -196,6 +221,7 @@ in {
196221
--config ${configFile} \
197222
--socket-path "$CARDANO_NODE_SOCKET_PATH" \
198223
--schema-dir ${self.schema} \
224+
${toString cfg.rtsArgs} \
199225
''${LEDGER_OPTS} \
200226
''${EXTRA_DB_SYNC_ARGS:-}
201227
'';

0 commit comments

Comments
 (0)