# Pastebin isfPDuUS { config, pkgs, ... }: { imports = [ ]; ec2.hvm = true; systemd.services.helloWorld = let helloWorld = pkgs.writeScriptBin "helloWorld" '' #!${pkgs.ruby}/bin/ruby require 'socket' server = TCPServer.new 5678 while session = server.accept request = session.gets puts request session.print "HTTP/1.1 200\r\n" # 1 session.print "Content-Type: text/html\r\n" # 2 session.print "\r\n" # 3 session.print "Hello world! The time is #{Time.now}" #4 session.close end ''; in { description = "Hello world service"; wantedBy = [ "multi-user.target" ]; serviceConfig = { Type = "simple"; ExecStart = helloWorld; }; }; }