<commit_before># based on: <nixpkgs/nixos/modules/virtualisation/amazon-image.nix>
# - does not install configuration.nix
# - does not use unionfs on instance-store instances
# - does not add extra software
{ config, lib, pkgs, ... }:

with lib;
let
  cfg = config.ec2;
in
{
  imports = [
    <nixpkgs/nixos/modules/profiles/headless.nix>
    <nixpkgs/nixos/modules/virtualisation/ec2-data.nix>
  ];

  options = {
    ec2 = {
      hvm = mkOption {
        default = true;
        description = ''
          Whether the EC2 instance is a HVM instance.
        '';
      };
    };
  };

  config = {
    system.build.amazonImage =
      pkgs.vmTools.runInLinuxVM (
        pkgs.runCommand "amazon-image"
          { preVM =
              ''
                mkdir $out
                diskImage=$out/nixos.img
                ${pkgs.vmTools.qemu}/bin/qemu-img create -f raw $diskImage "10G"
                mv closure xchg/
              '';
            buildInputs = [ pkgs.utillinux pkgs.perl ];
            exportReferencesGraph =
              [ "closure" config.system.build.toplevel ];
          }
          ''
            ${if cfg.hvm then ''
              # Create a single / partition.
              ${pkgs.parted}/sbin/parted /dev/vda mklabel msdos
              ${pkgs.parted}/sbin/parted /dev/vda -- mkpart primary ext2 1M -1s
              . /sys/class/block/vda1/uevent
              mknod /dev/vda1 b $MAJOR $MINOR

              # Create an empty filesystem and mount it.
              ${pkgs.e2fsprogs}/sbin/mkfs.ext4 -L nixos /dev/vda1<commit_msg>The option ec2.hvm has been added to default NixOS 14.12<commit_after># based on: <nixpkgs/nixos/modules/virtualisation/amazon-image.nix>
# - does not install configuration.nix
# - does not use unionfs on instance-store instances
# - does not add extra software
{ config, lib, pkgs, ... }:

with lib;
let
  cfg = config.ec2;
in
{
  imports = [
    <nixpkgs/nixos/modules/profiles/headless.nix>
    <nixpkgs/nixos/modules/virtualisation/ec2-data.nix>
  ];

  options = {
  };

  config = {
    system.build.amazonImage =
      pkgs.vmTools.runInLinuxVM (
        pkgs.runCommand "amazon-image"
          { preVM =
              ''
                mkdir $out
                diskImage=$out/nixos.img
                ${pkgs.vmTools.qemu}/bin/qemu-img create -f raw $diskImage "10G"
                mv closure xchg/
              '';
            buildInputs = [ pkgs.utillinux pkgs.perl ];
            exportReferencesGraph =
              [ "closure" config.system.build.toplevel ];
          }
          ''
            ${if cfg.hvm then ''
              # Create a single / partition.
              ${pkgs.parted}/sbin/parted /dev/vda mklabel msdos
              ${pkgs.parted}/sbin/parted /dev/vda -- mkpart primary ext2 1M -1s
              . /sys/class/block/vda1/uevent
              mknod /dev/vda1 b $MAJOR $MINOR

              # Create an empty filesystem and mount it.
              ${pkgs.e2fsprogs}/sbin/mkfs.ext4 -L nixos /dev/vda1
{'fraction_non_alphanumeric': 0.11414309484193012, 'fraction_numerical': 0.010316139767054908, 'mean_word_length': 1.6578249336870026, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7527128', 'n_tokens_mistral': 1030, 'n_tokens_neox': 971, 'n_words': 206}