|
| 1 | +{ withSystem, ... }: |
| 2 | +{ |
| 3 | + flake.modules.nixos.aztec-sequencer = |
| 4 | + { |
| 5 | + pkgs, |
| 6 | + config, |
| 7 | + lib, |
| 8 | + ... |
| 9 | + }: |
| 10 | + let |
| 11 | + cfg = config.services.aztec-sequencer; |
| 12 | + package = withSystem pkgs.stdenv.hostPlatform.system ({ config, ... }: config.packages.aztec); |
| 13 | + in |
| 14 | + { |
| 15 | + options.services.aztec-sequencer = with lib; { |
| 16 | + enable = mkEnableOption (lib.mdDoc "Aztec Sequencer"); |
| 17 | + ethereumHosts = mkOption { |
| 18 | + type = types.listOf types.str; |
| 19 | + description = "Ethereum hosts for the sequencer"; |
| 20 | + }; |
| 21 | + l1ConsensusHostUrls = mkOption { |
| 22 | + type = types.listOf types.str; |
| 23 | + description = "L1 consensus host URLs for the sequencer"; |
| 24 | + }; |
| 25 | + coinbase = mkOption { |
| 26 | + type = types.str; |
| 27 | + description = "Coinbase for the sequencer"; |
| 28 | + }; |
| 29 | + p2pIp = mkOption { |
| 30 | + type = types.str; |
| 31 | + description = "P2P IP for the computer running the node (you can get this by running, curl api.ipify.org, on your node)"; |
| 32 | + }; |
| 33 | + p2pPort = mkOption { |
| 34 | + type = types.port; |
| 35 | + default = 40400; |
| 36 | + description = "The port for the P2P service."; |
| 37 | + }; |
| 38 | + validatorPrivateKeys = mkOption { |
| 39 | + type = types.path; |
| 40 | + description = "Path to private key of testnet L1 EOA that defines the sequencer identity that holds Sepolia ETH."; |
| 41 | + }; |
| 42 | + }; |
| 43 | + config = lib.mkIf cfg.enable { |
| 44 | + virtualisation.docker.enable = true; |
| 45 | + |
| 46 | + systemd.tmpfiles.rules = [ |
| 47 | + "d /var/lib/aztec-sequencer 0755 root root -" |
| 48 | + ]; |
| 49 | + systemd.services.aztec-sequencer = { |
| 50 | + description = "Aztec Sequencer"; |
| 51 | + wantedBy = [ "multi-user.target" ]; |
| 52 | + path = [ pkgs.docker ]; |
| 53 | + environment = { |
| 54 | + HOME = "/var/lib/aztec-sequencer"; |
| 55 | + }; |
| 56 | + serviceConfig = { |
| 57 | + WorkingDirectory = "/var/lib/aztec-sequencer"; |
| 58 | + |
| 59 | + ExecStart = pkgs.writeShellScript "aztec-sequencer" '' |
| 60 | + ${lib.getExe package} start --node --archiver --sequencer \ |
| 61 | + --network alpha-testnet \ |
| 62 | + --l1-rpc-urls ${lib.concatStringsSep "," cfg.ethereumHosts} \ |
| 63 | + --l1-consensus-host-urls ${lib.concatStringsSep "," cfg.l1ConsensusHostUrls} \ |
| 64 | + --sequencer.validatorPrivateKeys "$(cat ${cfg.validatorPrivateKeys})" \ |
| 65 | + --sequencer.coinbase ${cfg.coinbase} \ |
| 66 | + --p2p.p2pIp ${cfg.p2pIp} \ |
| 67 | + --p2p.p2pPort ${toString cfg.p2pPort} |
| 68 | + ''; |
| 69 | + }; |
| 70 | + }; |
| 71 | + |
| 72 | + }; |
| 73 | + }; |
| 74 | +} |
0 commit comments