1 { config, pkgs, lib, ... }:
4 # hw_firmware_type=uefi
7 inherit (lib) mkIf mkDefault;
8 cfg = config.openstack;
9 metadataFetcher = import ./openstack-metadata-fetcher.nix {
11 wgetExtraOptions = "--retry-connrefused";
16 ../profiles/qemu-guest.nix
18 # Note: While we do use the headless profile, we also explicitly
19 # turn on the serial console on tty1 below.
20 # Note that I could not find any documentation indicating tty1 was
21 # the correct choice. I picked tty1 because that is what one
22 # particular host was using.
23 ../profiles/headless.nix
25 # The Openstack Metadata service exposes data on an EC2 API also.
31 fileSystems."/" = mkIf (!cfg.zfs.enable) {
32 device = "/dev/disk/by-label/nixos";
37 fileSystems."/boot" = mkIf (cfg.efi || cfg.zfs.enable) {
38 # The ZFS image uses a partition labeled ESP whether or not we're
40 device = "/dev/disk/by-label/ESP";
44 boot.growPartition = true;
45 boot.kernelParams = [ "console=tty1" ];
46 boot.loader.grub.device = if (!cfg.efi) then "/dev/vda" else "nodev";
47 boot.loader.grub.efiSupport = cfg.efi;
48 boot.loader.grub.efiInstallAsRemovable = cfg.efi;
49 boot.loader.timeout = 1;
50 boot.loader.grub.extraConfig = ''
51 serial --unit=1 --speed=115200 --word=8 --parity=no --stop=1
52 terminal_output console serial
53 terminal_input console serial
56 services.zfs.expandOnBoot = mkIf cfg.zfs.enable (lib.mkDefault "all");
57 boot.zfs.devNodes = mkIf cfg.zfs.enable "/dev/";
62 settings.PermitRootLogin = "prohibit-password";
63 settings.PasswordAuthentication = mkDefault false;
66 # Enable the serial console on tty1
67 systemd.services."serial-getty@tty1".enable = true;
69 # Force getting the hostname from Openstack metadata.
70 networking.hostName = mkDefault "";
72 systemd.services.openstack-init = {
74 description = "Fetch Metadata on startup";
75 wantedBy = [ "multi-user.target" ];
76 before = [ "apply-ec2-data.service" "amazon-init.service" ];
77 wants = [ "network-online.target" ];
78 after = [ "network-online.target" ];
79 script = metadataFetcher;
80 restartIfChanged = false;
81 unitConfig.X-StopOnRemoval = false;
84 RemainAfterExit = true;