diff --git a/modules/aztec/default.nix b/modules/aztec/default.nix new file mode 100644 index 00000000..d39241b3 --- /dev/null +++ b/modules/aztec/default.nix @@ -0,0 +1,74 @@ +{ withSystem, ... }: +{ + flake.modules.nixos.aztec-sequencer = + { + pkgs, + config, + lib, + ... + }: + let + cfg = config.services.aztec-sequencer; + package = withSystem pkgs.stdenv.hostPlatform.system ({ config, ... }: config.packages.aztec); + in + { + options.services.aztec-sequencer = with lib; { + enable = mkEnableOption (lib.mdDoc "Aztec Sequencer"); + ethereumHosts = mkOption { + type = types.listOf types.str; + description = "Ethereum hosts for the sequencer"; + }; + l1ConsensusHostUrls = mkOption { + type = types.listOf types.str; + description = "L1 consensus host URLs for the sequencer"; + }; + coinbase = mkOption { + type = types.str; + description = "Coinbase for the sequencer"; + }; + p2pIp = mkOption { + type = types.str; + description = "P2P IP for the computer running the node (you can get this by running, curl api.ipify.org, on your node)"; + }; + p2pPort = mkOption { + type = types.port; + default = 40400; + description = "The port for the P2P service."; + }; + validatorPrivateKeys = mkOption { + type = types.path; + description = "Path to private key of testnet L1 EOA that defines the sequencer identity that holds Sepolia ETH."; + }; + }; + config = lib.mkIf cfg.enable { + virtualisation.docker.enable = true; + + systemd.tmpfiles.rules = [ + "d /var/lib/aztec-sequencer 0755 root root -" + ]; + systemd.services.aztec-sequencer = { + description = "Aztec Sequencer"; + wantedBy = [ "multi-user.target" ]; + path = [ pkgs.docker ]; + environment = { + HOME = "/var/lib/aztec-sequencer"; + }; + serviceConfig = { + WorkingDirectory = "/var/lib/aztec-sequencer"; + + ExecStart = pkgs.writeShellScript "aztec-sequencer" '' + ${lib.getExe package} start --node --archiver --sequencer \ + --network alpha-testnet \ + --l1-rpc-urls ${lib.concatStringsSep "," cfg.ethereumHosts} \ + --l1-consensus-host-urls ${lib.concatStringsSep "," cfg.l1ConsensusHostUrls} \ + --sequencer.validatorPrivateKeys "$(cat ${cfg.validatorPrivateKeys})" \ + --sequencer.coinbase ${cfg.coinbase} \ + --p2p.p2pIp ${cfg.p2pIp} \ + --p2p.p2pPort ${toString cfg.p2pPort} + ''; + }; + }; + + }; + }; +} diff --git a/modules/default.nix b/modules/default.nix index 5698129d..09b7bee6 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -2,6 +2,7 @@ imports = [ ./lido ./pyroscope + ./aztec ./folder-size-metrics ./shard-split ./random-alerts diff --git a/packages/aztec/default.nix b/packages/aztec/default.nix new file mode 100644 index 00000000..2b5a4525 --- /dev/null +++ b/packages/aztec/default.nix @@ -0,0 +1,42 @@ +{ + stdenv, + fetchurl, + lib, +}: +stdenv.mkDerivation { + name = "aztec"; + srcs = [ + (fetchurl { + url = "https://install.aztec.network/.aztec-run"; + hash = "sha256-hLLneMb+RE/+btcIz/pK54Diz5N8i4tsKz+1zZatlPQ="; + }) + (fetchurl { + url = "https://install.aztec.network/aztec"; + hash = "sha256-Z3tst1Fn5dQibZzaSnXzPz3DPwY6bkiRSeilM5DZbro="; + }) + (fetchurl { + url = "https://install.aztec.network/aztec-up"; + hash = "sha256-9mJWn+cj8loFkw/RhpV/y1rGapMYYTmiCiDmUJqeqdc="; + }) + (fetchurl { + url = "https://install.aztec.network/aztec-nargo"; + hash = "sha256-9T9m/Ops1O/uYKNIaBxZ9RC+q7ADQnMjRDU4oTbSORA="; + }) + (fetchurl { + url = "https://install.aztec.network/aztec-wallet"; + hash = "sha256-WZvmrVWEnxVRh/zwhaTk6PWSHBD8ElgX8ivODFUUZzU="; + }) + ]; + sourceRoot = "."; + unpackCmd = '' + curTrg=$(basename $(stripHash $curSrc)) + cp $curSrc $curTrg + chmod +x $curTrg + ''; + installPhase = '' + mkdir -p $out/bin + cp -r * .* $out/bin/ + mv $out/bin/aztec-run $out/bin/.aztec-run + ''; + meta.mainProgram = "aztec"; +} diff --git a/packages/default.nix b/packages/default.nix index c73d456b..394fd7ee 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -60,6 +60,7 @@ } // optionalAttrs (system == "x86_64-linux" || system == "aarch64-darwin") { secret = import ./secret { inherit inputs' pkgs; }; + aztec = pkgs.callPackage ./aztec { }; } // optionalAttrs isLinux { folder-size-metrics = pkgs.callPackage ./folder-size-metrics { };