commit 0e33fb92ec3d4003936c37d585c32b68fd608437 Author: Tim Dysinger Date: Mon Dec 24 17:02:03 2012 -1000 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d3930f2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.DS_Store +/*.box +/.bundle +/.vagrant +/Gemfile.lock +/iso +/vendor diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..980d66e --- /dev/null +++ b/Gemfile @@ -0,0 +1,17 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +source :rubygems + +gem 'rake', '~> 10.0.2' + +group :chef do + gem 'chef', '~> 10.16.2' + gem 'foodcritic', '~> 1.6.1' + gem 'test-kitchen', '~> 0.6.0' +end + +group :vagrant do + gem 'vagrant', '~> 1.0.5' + gem 'veewee', '~> 0.3.1' +end diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..2a89fa3 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,6 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant::Config.run do |config| + config.vm.box = 'nixos32' +end diff --git a/definitions/nixos32/configuration.nix b/definitions/nixos32/configuration.nix new file mode 100644 index 0000000..92cbe06 --- /dev/null +++ b/definitions/nixos32/configuration.nix @@ -0,0 +1,45 @@ +{ config, pkgs, ... }: +{ + require = [ + + + + ]; + boot = { + initrd.kernelModules = [ "ata_piix" "ahci" ]; + 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; + virtualbox.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/nixos32/definition.rb b/definitions/nixos32/definition.rb new file mode 100644 index 0000000..8187175 --- /dev/null +++ b/definitions/nixos32/definition.rb @@ -0,0 +1,50 @@ +iso = { + :file => 'nixos-minimal-0.1pre4019_3582393-45635e9-i686-linux.iso', + :md5 => '603bdbf453c47d1592ade77a0fcb7a40', +} + +session = { + :boot_cmd_sequence => + [ + '', ''*15, + 'root', '', + 'fdisk /dev/sda', '', + 'n', ''*5, + 'a', '', + '1', '', + 'w', '', + 'mkfs.ext4 -j -L nixos /dev/sda1', '', + 'mount LABEL=nixos /mnt', '', + 'curl -O http://10.0.2.2:7122/configuration.nix &&', '', + 'mkdir -p /mnt/etc/nixos &&', '', + 'mv configuration.nix /mnt/etc/nixos &&', '', + 'nixos-install &&', '', + 'reboot', '' + ], + :boot_wait => '5', + :cpu_count => '1', + :disk_format => 'VDI', + :disk_size => '20400', + :hostiocache => 'off', + :iso_download_timeout => '1000', + :iso_file => iso[:file], + :iso_md5 => iso[:md5], + :iso_src => "http://nixos.org/releases/nixos/#{iso[:file]}", + :kickstart_file => 'configuration.nix', + :kickstart_port => '7122', + :kickstart_timeout => '10000', + :memory_size => '256', + :os_type_id => 'Linux', + :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/nixos32/postinstall.sh b/definitions/nixos32/postinstall.sh new file mode 100755 index 0000000..b5d2414 --- /dev/null +++ b/definitions/nixos32/postinstall.sh @@ -0,0 +1,47 @@ +#!/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' + +# ***TEMPORARILY*** clone Tim Dysinger's nixos repos to get VirtualBox +# Guest Additions working correctly. + +git clone --depth=1 --branch=develop \ + git://github.com/dysinger/nixos.git \ + /etc/nixos/nixos + +git clone --depth=1 --branch=develop \ + git://github.com/dysinger/nixpkgs.git \ + /etc/nixos/nixpkgs + +# ***TEMPORARILY*** Rebuild with the lastest (now working) VirtualBox +# 4.2.6 Guest Additions from the develop branch @ our git repo in +# /etc/nixos/nixpkgs + +export NIX_PATH=\ +nixos-config=/etc/nixos/configuration.nix:\ +nixos=/etc/nixos/nixos:\ +nixpkgs=/etc/nixos/nixpkgs:\ +services=/etc/nixos/services + +nixos-rebuild --upgrade switch + +# Cleanup any previous generations and delete old packages that can be +# pruned. + +for x in `seq 0 6` ; 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