at 18.09-beta 1.9 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4let 5 diskSize = 2048; 6in 7{ 8 system.build.azureImage = import ../../lib/make-disk-image.nix { 9 name = "azure-image"; 10 postVM = '' 11 ${pkgs.vmTools.qemu}/bin/qemu-img convert -f raw -o subformat=fixed,force_size -O vpc $diskImage $out/disk.vhd 12 ''; 13 configFile = ./azure-config-user.nix; 14 format = "raw"; 15 inherit diskSize; 16 inherit config lib pkgs; 17 }; 18 19 imports = [ ./azure-common.nix ]; 20 21 # Azure metadata is available as a CD-ROM drive. 22 fileSystems."/metadata".device = "/dev/sr0"; 23 24 systemd.services.fetch-ssh-keys = 25 { description = "Fetch host keys and authorized_keys for root user"; 26 27 wantedBy = [ "sshd.service" "waagent.service" ]; 28 before = [ "sshd.service" "waagent.service" ]; 29 after = [ "local-fs.target" ]; 30 31 path = [ pkgs.coreutils ]; 32 script = 33 '' 34 eval "$(cat /metadata/CustomData.bin)" 35 if ! [ -z "$ssh_host_ecdsa_key" ]; then 36 echo "downloaded ssh_host_ecdsa_key" 37 echo "$ssh_host_ecdsa_key" > /etc/ssh/ssh_host_ed25519_key 38 chmod 600 /etc/ssh/ssh_host_ed25519_key 39 fi 40 41 if ! [ -z "$ssh_host_ecdsa_key_pub" ]; then 42 echo "downloaded ssh_host_ecdsa_key_pub" 43 echo "$ssh_host_ecdsa_key_pub" > /etc/ssh/ssh_host_ed25519_key.pub 44 chmod 644 /etc/ssh/ssh_host_ed25519_key.pub 45 fi 46 47 if ! [ -z "$ssh_root_auth_key" ]; then 48 echo "downloaded ssh_root_auth_key" 49 mkdir -m 0700 -p /root/.ssh 50 echo "$ssh_root_auth_key" > /root/.ssh/authorized_keys 51 chmod 600 /root/.ssh/authorized_keys 52 fi 53 ''; 54 serviceConfig.Type = "oneshot"; 55 serviceConfig.RemainAfterExit = true; 56 serviceConfig.StandardError = "journal+console"; 57 serviceConfig.StandardOutput = "journal+console"; 58 }; 59 60}