2019-01-28 10:59:18 +00:00
|
|
|
{ pkgs, lib, ... }:
|
2017-02-24 21:17:52 +00:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
2019-02-06 11:16:22 +00:00
|
|
|
let
|
|
|
|
metadataFetcher = import ./ec2-metadata-fetcher.nix {
|
|
|
|
targetRoot = "/";
|
|
|
|
wgetExtraOptions = "--retry-connrefused";
|
|
|
|
};
|
|
|
|
in
|
2017-02-24 21:17:52 +00:00
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
../profiles/qemu-guest.nix
|
|
|
|
../profiles/headless.nix
|
2019-01-28 10:59:18 +00:00
|
|
|
# The Openstack Metadata service exposes data on an EC2 API also.
|
|
|
|
./ec2-data.nix
|
2019-01-28 13:44:41 +00:00
|
|
|
./amazon-init.nix
|
2017-02-24 21:17:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
config = {
|
2017-02-24 21:19:53 +00:00
|
|
|
fileSystems."/" = {
|
|
|
|
device = "/dev/disk/by-label/nixos";
|
2019-03-21 09:04:07 +00:00
|
|
|
fsType = "ext4";
|
2017-02-24 21:19:53 +00:00
|
|
|
autoResize = true;
|
|
|
|
};
|
|
|
|
|
2018-01-06 13:52:51 +00:00
|
|
|
boot.growPartition = true;
|
2017-02-24 21:17:52 +00:00
|
|
|
boot.kernelParams = [ "console=ttyS0" ];
|
|
|
|
boot.loader.grub.device = "/dev/vda";
|
|
|
|
boot.loader.timeout = 0;
|
|
|
|
|
|
|
|
# Allow root logins
|
2017-09-11 16:33:33 +00:00
|
|
|
services.openssh = {
|
|
|
|
enable = true;
|
|
|
|
permitRootLogin = "prohibit-password";
|
|
|
|
passwordAuthentication = mkDefault false;
|
|
|
|
};
|
|
|
|
|
2019-01-28 20:06:24 +00:00
|
|
|
# Force getting the hostname from Openstack metadata.
|
|
|
|
networking.hostName = mkDefault "";
|
|
|
|
|
2019-01-28 14:09:48 +00:00
|
|
|
systemd.services.openstack-init = {
|
2019-01-28 10:59:18 +00:00
|
|
|
path = [ pkgs.wget ];
|
|
|
|
description = "Fetch Metadata on startup";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
2019-01-28 13:44:41 +00:00
|
|
|
before = [ "apply-ec2-data.service" "amazon-init.service"];
|
2019-01-28 10:59:18 +00:00
|
|
|
wants = [ "network-online.target" ];
|
|
|
|
after = [ "network-online.target" ];
|
2019-02-06 11:16:22 +00:00
|
|
|
script = metadataFetcher;
|
2019-01-28 10:59:18 +00:00
|
|
|
restartIfChanged = false;
|
|
|
|
unitConfig.X-StopOnRemoval = false;
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = true;
|
|
|
|
};
|
|
|
|
};
|
2017-02-24 21:17:52 +00:00
|
|
|
};
|
|
|
|
}
|