{ lib, config, pkgs, self, ... }: let inherit (lib) mkIf mkOption mkEnableOption types ; inherit (pkgs) stdenv; inherit (stdenv.hostPlatform) system; cfg = config.services.specimen; in { options.services.specimen = { enable = mkEnableOption "specimen application"; package = mkOption { type = types.package; description = "specimen package to use."; default = self.packages.${system}.default; }; port = mkOption { type = types.port; default = 4444; description = "port that specimen will listen on."; }; listenAddress = mkOption { type = types.str; default = "0.0.0.0"; description = "address that specimen will listen on."; }; openFirewall = mkOption { type = types.bool; default = false; description = "open specimen port in firewall for incoming connections."; }; namePath = mkOption { type = types.path; description = "path from which specimen will get the content to reply with."; }; }; config = mkIf cfg.enable { networking.firewall.allowedTCPPorts = mkIf cfg.openFirewall [ cfg.port ]; systemd.services.specimen = { description = "specimen application service"; wantedBy = [ "multi-user.target" ]; wants = [ "network.target" ]; after = [ "network.target" ]; serviceConfig = { DynamicUser = true; Type = "exec"; Restart = "always"; ExecStart = "${cfg.package}/bin/specimen -address ${cfg.listenAddress} -port ${toString cfg.port} -name ${cfg.namePath}"; }; }; }; }