Initial commit

This commit is contained in:
Tim Dysinger 2012-12-24 17:02:03 -10:00
commit 0e33fb92ec
6 changed files with 172 additions and 0 deletions

7
.gitignore vendored Normal file
View file

@ -0,0 +1,7 @@
.DS_Store
/*.box
/.bundle
/.vagrant
/Gemfile.lock
/iso
/vendor

17
Gemfile Normal file
View file

@ -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

6
Vagrantfile vendored Normal file
View file

@ -0,0 +1,6 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant::Config.run do |config|
config.vm.box = 'nixos32'
end

View file

@ -0,0 +1,45 @@
{ config, pkgs, ... }:
{
require = [
<nixos/modules/installer/scan/not-detected.nix>
<nixos/modules/profiles/headless.nix>
<nixos/modules/profiles/minimal.nix>
];
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"
];
} ];
};
}

View file

@ -0,0 +1,50 @@
iso = {
:file => 'nixos-minimal-0.1pre4019_3582393-45635e9-i686-linux.iso',
:md5 => '603bdbf453c47d1592ade77a0fcb7a40',
}
session = {
:boot_cmd_sequence =>
[
'<Enter>', '<Wait>'*15,
'root', '<Enter>',
'fdisk /dev/sda', '<Enter>',
'n', '<Enter>'*5,
'a', '<Enter>',
'1', '<Enter>',
'w', '<Enter>',
'mkfs.ext4 -j -L nixos /dev/sda1', '<Enter>',
'mount LABEL=nixos /mnt', '<Enter>',
'curl -O http://10.0.2.2:7122/configuration.nix &&', '<Enter>',
'mkdir -p /mnt/etc/nixos &&', '<Enter>',
'mv configuration.nix /mnt/etc/nixos &&', '<Enter>',
'nixos-install &&', '<Enter>',
'reboot', '<Enter>'
],
: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

View file

@ -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