{ lib , modulesPath , pkgs , ... }: { imports = [ "${toString modulesPath}/profiles/minimal.nix" "${toString modulesPath}/profiles/qemu-guest.nix" ]; services.vector.enable = true; services.vector.settings = { api.enabled = false; sources = { otlp = { type = "opentelemetry"; grpc = { address = "127.0.0.1:4317"; }; http = { address = "127.0.0.1:4318"; keepalive = { max_connection_age_jitter_factor = 0.1; max_connection_age_secs = 300; }; }; }; }; sinks = { console = { inputs = [ "otlp.logs" ]; target = "stdout"; type = "console"; encoding = { codec = "json"; }; }; kafka = { type = "kafka"; inputs = [ "otlp.logs" ]; bootstrap_servers = "\${KAFKA_URLS:-127.0.0.1:0}"; topic = "\${KAFKA_TOPIC:-tdx-google}"; encoding = { codec = "json"; compression = "lz4"; }; }; }; }; systemd.services.vector.path = [ pkgs.curl pkgs.coreutils ]; # `-` means, that the file can be missing, so that `ExecStartPre` can execute and create it systemd.services.vector.serviceConfig.EnvironmentFile = "-/run/vector/env"; # `+` means, that the process has access to all files, to be able to write to `/run` systemd.services.vector.serviceConfig.ExecStartPre = "+" + toString ( pkgs.writeShellScript "vector-start-pre" '' set -eu -o pipefail : "''${KAFKA_URLS:=$(curl --silent --fail "http://metadata.google.internal/computeMetadata/v1/instance/attributes/kafka_urls" -H "Metadata-Flavor: Google")}" : "''${KAFKA_TOPIC:=$(curl --silent --fail "http://metadata.google.internal/computeMetadata/v1/instance/attributes/kafka_topic" -H "Metadata-Flavor: Google")}" KAFKA_TOPIC="''${KAFKA_TOPIC:-tdx-google}" mkdir -p /run/vector cat >/run/vector/env </run/container/env <&2 test -c /dev/tdx_guest && tdx-extend --digest "$DIGEST" --rtmr 3 exec docker run --env "GOOGLE_METADATA=1" --network=host --init --privileged "sha256:$DIGEST" ''; postStop = lib.mkDefault '' shutdown --reboot +5 ''; }; services.prometheus.exporters.node = { enable = true; port = 9100; enabledCollectors = [ "logind" "systemd" ]; disabledCollectors = [ "textfile" ]; }; environment.systemPackages = with pkgs; [ teepot.teepot ]; # /var is on tmpfs anyway services.journald.storage = "volatile"; # we can't rely on/trust the hypervisor services.timesyncd.enable = false; services.chrony = { enable = true; enableNTS = true; servers = [ "time.cloudflare.com" "ntppool1.time.nl" "ntppool2.time.nl" ]; }; systemd.services."chronyd".after = [ "network-online.target" ]; boot.kernelPackages = lib.mkForce pkgs.linuxPackages_6_12; boot.kernelPatches = [ { name = "tdx-rtmr"; patch = pkgs.fetchurl { url = "https://github.com/haraldh/linux/commit/12d08008a5c94175e7a7dfcee40dff33431d9033.patch"; hash = "sha256-sVDhvC3qnXpL5FRxWiQotH7Nl/oqRBQGjJGyhsKeBTA="; }; } ]; boot.kernelParams = [ "console=ttyS0,115200n8" "random.trust_cpu=on" ]; boot.consoleLogLevel = 7; boot.initrd.includeDefaultModules = false; boot.initrd.availableKernelModules = [ "tdx_guest" "nvme" "sd_mod" "dm_mod" "ata_piix" ]; boot.initrd.systemd.enable = lib.mkDefault true; services.logind.extraConfig = '' NAutoVTs=0 ReserveVT=0 ''; services.dbus.implementation = "broker"; boot.initrd.systemd.tpm2.enable = lib.mkForce false; systemd.tpm2.enable = lib.mkForce false; nix.enable = false; # it's a read-only nix store anyway security.pam.services.su.forwardXAuth = lib.mkForce false; users.mutableUsers = false; users.allowNoPasswordLogin = true; system.stateVersion = lib.version; system.switch.enable = lib.mkForce false; documentation.info.enable = lib.mkForce false; documentation.nixos.enable = lib.mkForce false; documentation.man.enable = lib.mkForce false; documentation.enable = lib.mkForce false; services.udisks2.enable = false; # udisks has become too bloated to have in a headless system # Get rid of the perl ecosystem to minimize the TCB and disk size # Remove perl from activation system.etc.overlay.enable = lib.mkDefault true; services.userborn.enable = lib.mkDefault true; # Random perl remnants system.disableInstallerTools = lib.mkForce true; programs.less.lessopen = lib.mkDefault null; programs.command-not-found.enable = lib.mkDefault false; boot.enableContainers = lib.mkForce false; boot.loader.grub.enable = lib.mkDefault false; environment.defaultPackages = lib.mkDefault [ ]; # Check that the system does not contain a Nix store path that contains the # string "perl". system.forbiddenDependenciesRegexes = [ "perl" ]; }