|
|
@ -5,6 +5,7 @@
|
|
|
|
(guix gexp)
|
|
|
|
(guix gexp)
|
|
|
|
(guix modules)
|
|
|
|
(guix modules)
|
|
|
|
(gnu services shepherd)
|
|
|
|
(gnu services shepherd)
|
|
|
|
|
|
|
|
(gnu packages certs)
|
|
|
|
(guix packages)
|
|
|
|
(guix packages)
|
|
|
|
(guix build-system trivial)
|
|
|
|
(guix build-system trivial)
|
|
|
|
(gnu system shadow)
|
|
|
|
(gnu system shadow)
|
|
|
@ -45,35 +46,26 @@
|
|
|
|
#~(begin
|
|
|
|
#~(begin
|
|
|
|
(use-modules (ice-9
|
|
|
|
(use-modules (ice-9
|
|
|
|
receive)
|
|
|
|
receive)
|
|
|
|
|
|
|
|
|
|
|
|
(guix
|
|
|
|
(guix
|
|
|
|
build
|
|
|
|
build
|
|
|
|
download)
|
|
|
|
download)
|
|
|
|
|
|
|
|
|
|
|
|
(web
|
|
|
|
(web
|
|
|
|
uri)
|
|
|
|
uri)
|
|
|
|
|
|
|
|
|
|
|
|
(web
|
|
|
|
(web
|
|
|
|
client)
|
|
|
|
client)
|
|
|
|
|
|
|
|
|
|
|
|
(ice-9
|
|
|
|
(ice-9
|
|
|
|
binary-ports))
|
|
|
|
binary-ports))
|
|
|
|
(call-with-output-file "/etc/ssh/authorized_keys.d/aws"
|
|
|
|
(call-with-output-file "/etc/ssh/authorized_keys.d/aws"
|
|
|
|
(lambda (port)
|
|
|
|
(lambda (port)
|
|
|
|
|
|
|
|
|
|
|
|
(begin
|
|
|
|
(begin
|
|
|
|
|
|
|
|
|
|
|
|
(format (current-error-port)
|
|
|
|
(format (current-error-port)
|
|
|
|
"opened-file\n")
|
|
|
|
"opened-file\n")
|
|
|
|
|
|
|
|
|
|
|
|
(put-bytevector
|
|
|
|
(put-bytevector
|
|
|
|
port
|
|
|
|
port
|
|
|
|
|
|
|
|
|
|
|
|
(receive (header
|
|
|
|
(receive (header
|
|
|
|
body)
|
|
|
|
body)
|
|
|
|
(let ((uri
|
|
|
|
(let ((uri
|
|
|
|
"http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key"))
|
|
|
|
"http://169.254.169.254/latest/meta-data/public-keys/0/openssh-key"))
|
|
|
|
|
|
|
|
|
|
|
|
(http-get
|
|
|
|
(http-get
|
|
|
|
uri
|
|
|
|
uri
|
|
|
|
#:port (open-connection-for-uri
|
|
|
|
#:port (open-connection-for-uri
|
|
|
@ -94,13 +86,16 @@
|
|
|
|
(respawn? #t)
|
|
|
|
(respawn? #t)
|
|
|
|
(start #~(make-forkexec-constructor (list #$aws-pubkey-prog))))))
|
|
|
|
(start #~(make-forkexec-constructor (list #$aws-pubkey-prog))))))
|
|
|
|
|
|
|
|
|
|
|
|
(define aws-pubkey-service-type
|
|
|
|
(define aws-service-type
|
|
|
|
(service-type (name 'aws-pubkey)
|
|
|
|
(service-type (name 'aws)
|
|
|
|
(description "AWS public key service")
|
|
|
|
(description "AWS public key service")
|
|
|
|
(extensions (list (service-extension
|
|
|
|
(extensions (list (service-extension profile-service-type
|
|
|
|
|
|
|
|
(lambda (val)
|
|
|
|
|
|
|
|
val))
|
|
|
|
|
|
|
|
(service-extension
|
|
|
|
shepherd-root-service-type
|
|
|
|
shepherd-root-service-type
|
|
|
|
aws-pubkey-service)))
|
|
|
|
aws-pubkey-service)))
|
|
|
|
(default-value '())))
|
|
|
|
(default-value (list le-certs nss-certs))))
|
|
|
|
|
|
|
|
|
|
|
|
(operating-system
|
|
|
|
(operating-system
|
|
|
|
(host-name "guix-ami")
|
|
|
|
(host-name "guix-ami")
|
|
|
@ -133,7 +128,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
(services
|
|
|
|
(services
|
|
|
|
(cons* (service dhcp-client-service-type)
|
|
|
|
(cons* (service dhcp-client-service-type)
|
|
|
|
(service aws-pubkey-service-type)
|
|
|
|
(service aws-service-type)
|
|
|
|
(service openssh-service-type
|
|
|
|
(service openssh-service-type
|
|
|
|
(openssh-configuration (port-number 22) (password-authentication? #f))) %base-services)))
|
|
|
|
(openssh-configuration (port-number 22)
|
|
|
|
|
|
|
|
(password-authentication? #f)))
|
|
|
|
|
|
|
|
%base-services)))
|
|
|
|
|
|
|
|
|
|
|
|