diff --git a/definitions/nixos64/configuration.nix b/definitions/nixos64/configuration.nix new file mode 100644 index 0000000..31b1807 --- /dev/null +++ b/definitions/nixos64/configuration.nix @@ -0,0 +1,39 @@ +{ config, pkgs, ... }: +{ + require = [ ./hardware-configuration.nix ]; + boot = { + loader.grub.device = "/dev/sda"; + }; + environment.systemPackages = with pkgs; [ git ruby rubygems gnumake gcc ]; + fileSystems = [ { mountPoint = "/"; label = "nixos"; } ]; + security.sudo.configFile = + '' + Defaults:root,%wheel env_keep+=LOCALE_ARCHIVE + Defaults:root,%wheel env_keep+=NIX_PATH + Defaults:root,%wheel env_keep+=TERMINFO_DIRS + Defaults env_keep+=SSH_AUTH_SOCK + Defaults lecture = never + root ALL=(ALL) SETENV: ALL + %wheel ALL=(ALL) NOPASSWD: ALL, SETENV: ALL + ''; + services = { + dbus.enable = true; + openssh.enable = true; + }; + users = { + extraGroups = [ { name = "vagrant"; } { name = "vboxsf"; } ]; + extraUsers = [ { + description = "Vagrant User"; + name = "vagrant"; + group = "vagrant"; + extraGroups = [ "users" "vboxsf" "wheel" ]; + password = "vagrant"; + home = "/home/vagrant"; + createHome = true; + useDefaultShell = true; + openssh.authorizedKeys.keys = [ + "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key" + ]; + } ]; + }; +} diff --git a/definitions/nixos64/definition.rb b/definitions/nixos64/definition.rb new file mode 100644 index 0000000..b746203 --- /dev/null +++ b/definitions/nixos64/definition.rb @@ -0,0 +1,50 @@ +iso = { + :url => 'http://nixos.org/releases/nixos/nixos-0.2pre4587_9000fd8-cfbdb33/nixos-minimal-0.2pre4587_9000fd8-cfbdb33-x86_64-linux.iso', + :md5 => 'f61180f387e72ee85b8f68273e5ff884', +} + +session = { + :boot_cmd_sequence => + [ + '', ''*15, + 'root', '', + 'stop sshd', '', # Make sure we don't accept connections until reboot + 'fdisk /dev/sda', '', + 'n', ''*5, + 'a', '', + '1', '', + 'w', '', + 'mkfs.ext4 -j -L nixos /dev/sda1', '', + 'mount LABEL=nixos /mnt', '', + 'nixos-option --install', '', + 'curl http://%IP%:%PORT%/configuration.nix > /mnt/etc/nixos/configuration.nix &&', '', + 'nixos-install &&', '', + 'reboot', '', + ], + :boot_wait => '5', + :cpu_count => '1', + :disk_format => 'VDI', + :disk_size => '20400', + :hostiocache => 'off', + :iso_download_timeout => '1000', + :iso_file => File.basename(iso[:url]), + :iso_md5 => iso[:md5], + :iso_src => iso[:url], + :kickstart_file => 'configuration.nix', + :kickstart_port => '7122', + :kickstart_timeout => '10000', + :memory_size => '256', + :os_type_id => 'Linux26', + :postinstall_files => [ 'postinstall.sh' ], + :postinstall_timeout => '10000', + :shutdown_cmd => 'shutdown -h now', + :ssh_guest_port => '22', + :ssh_host_port => '7222', + :ssh_key => '', + :ssh_login_timeout => '10000', + :ssh_password => 'vagrant', + :ssh_user => 'vagrant', + :sudo_cmd => "sudo '%f'" +} + +Veewee::Definition.declare session diff --git a/definitions/nixos64/postinstall.sh b/definitions/nixos64/postinstall.sh new file mode 100755 index 0000000..6e3e215 --- /dev/null +++ b/definitions/nixos64/postinstall.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +# Remove VirtualBox Guest Additions ISO that the Veewee put in our +# home dir + +rm -f ~/*.iso + +# Install chef & puppet + +su - vagrant -c 'gem install chef puppet --user-install \ + --bindir=$HOME/bin --no-rdoc --no-ri' + +# Make sure we are totally up to date + +nixos-rebuild --upgrade switch + +# Cleanup any previous generations and delete old packages that can be +# pruned. + +for x in `seq 0 2` ; do + nix-env --delete-generations old + nix-collect-garbage -d +done + +# Zero out the disk (for better compression) + +dd if=/dev/zero of=/EMPTY bs=1M +rm -rf /EMPTY