Porting to packer
Still not working yet, it's blocking on the SSHd server after install.
This commit is contained in:
parent
471bb553a1
commit
c4017fe605
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,3 +5,4 @@
|
||||||
/Gemfile.lock
|
/Gemfile.lock
|
||||||
/iso
|
/iso
|
||||||
/vendor
|
/vendor
|
||||||
|
/packer_cache
|
||||||
|
|
12
README.md
12
README.md
|
@ -1,10 +1,10 @@
|
||||||
NixOS boxes for Vagrant
|
NixOS boxes for Vagrant
|
||||||
=======================
|
=======================
|
||||||
|
|
||||||
```
|
First install packer: http://packer.io (or `brew install packer`)
|
||||||
bundle
|
|
||||||
bundle exec veewee vbox build nixos32
|
|
||||||
bundle exec veewee vbox export nixos32
|
|
||||||
```
|
|
||||||
|
|
||||||
There's also a nixos64 version but it's still failing to build.
|
Then:
|
||||||
|
|
||||||
|
```
|
||||||
|
packer build --only=virtualbox nixos32-template.json
|
||||||
|
```
|
||||||
|
|
39
http/configuration.nix
Normal file
39
http/configuration.nix
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
{
|
||||||
|
require = [ ./hardware-configuration.nix ];
|
||||||
|
boot = {
|
||||||
|
loader.grub.device = "/dev/sda";
|
||||||
|
};
|
||||||
|
environment.systemPackages = with pkgs; [ git gnumake gcc ruby rubygems python ];
|
||||||
|
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"
|
||||||
|
];
|
||||||
|
} ];
|
||||||
|
};
|
||||||
|
}
|
131
nixos32-template.json
Normal file
131
nixos32-template.json
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
{
|
||||||
|
"provisioners": [
|
||||||
|
{
|
||||||
|
"type": "shell",
|
||||||
|
"scripts": [
|
||||||
|
"scripts/postinstall.sh"
|
||||||
|
],
|
||||||
|
"override": {
|
||||||
|
"virtualbox": {
|
||||||
|
"execute_command": "sudo '{{.Path}}'"
|
||||||
|
},
|
||||||
|
"vmware": {
|
||||||
|
"execute_command": "sudo '{{.Path}}'"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"builders": [
|
||||||
|
{
|
||||||
|
"type": "virtualbox",
|
||||||
|
"boot_command": [
|
||||||
|
"<enter><wait>",
|
||||||
|
"<wait><wait><wait><wait><wait><wait><wait><wait><wait><wait><wait><wait><wait><wait><wait><wait>",
|
||||||
|
"root<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"stop sshd<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"fdisk /dev/sda<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"n<wait>",
|
||||||
|
"<enter><enter><enter><enter><enter><wait>",
|
||||||
|
"a<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"1<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"w<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"mkfs.ext4 -j -L nixos /dev/sda1<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"mount LABEL=nixos /mnt<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"nixos-option --install<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/configuration.nix > /mnt/etc/nixos/configuration.nix &&<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"nixos-install &&<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"reboot<wait>",
|
||||||
|
"<enter><wait>"
|
||||||
|
],
|
||||||
|
"boot_wait": "5s",
|
||||||
|
"disk_size": 20400,
|
||||||
|
"guest_os_type": "Linux26",
|
||||||
|
"http_directory": "http",
|
||||||
|
"iso_checksum": "b1a78fc1b72ea1a19957cb1422817ab6",
|
||||||
|
"iso_checksum_type": "md5",
|
||||||
|
"iso_url": "http://nixos.org/releases/nixos/nixos-13.07pre4871_18de9f6-3c35dae/nixos-minimal-13.07pre4871_18de9f6-3c35dae-i686-linux.iso",
|
||||||
|
"ssh_username": "vagrant",
|
||||||
|
"ssh_password": "vagrant",
|
||||||
|
"ssh_port": 22,
|
||||||
|
"ssh_wait_timeout": "10000s",
|
||||||
|
"shutdown_command": "sudo shutdown -h now",
|
||||||
|
"guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso",
|
||||||
|
"virtualbox_version_file": ".vbox_version",
|
||||||
|
"vboxmanage": [
|
||||||
|
[
|
||||||
|
"modifyvm",
|
||||||
|
"{{.Name}}",
|
||||||
|
"--memory",
|
||||||
|
"256"
|
||||||
|
],
|
||||||
|
[
|
||||||
|
"modifyvm",
|
||||||
|
"{{.Name}}",
|
||||||
|
"--cpus",
|
||||||
|
"1"
|
||||||
|
]
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "vmware",
|
||||||
|
"boot_command": [
|
||||||
|
"<enter><wait>",
|
||||||
|
"<wait><wait><wait><wait><wait><wait><wait><wait><wait><wait><wait><wait><wait><wait><wait><wait>",
|
||||||
|
"root<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"stop sshd<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"fdisk /dev/sda<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"n<wait>",
|
||||||
|
"<enter><enter><enter><enter><enter><wait>",
|
||||||
|
"a<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"1<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"w<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"mkfs.ext4 -j -L nixos /dev/sda1<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"mount LABEL=nixos /mnt<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"nixos-option --install<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/configuration.nix > /mnt/etc/nixos/configuration.nix &&<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"nixos-install &&<wait>",
|
||||||
|
"<enter><wait>",
|
||||||
|
"reboot<wait>",
|
||||||
|
"<enter><wait>"
|
||||||
|
],
|
||||||
|
"boot_wait": "5s",
|
||||||
|
"disk_size": 20400,
|
||||||
|
"guest_os_type": "other26xlinux",
|
||||||
|
"http_directory": "http",
|
||||||
|
"iso_checksum": "b1a78fc1b72ea1a19957cb1422817ab6",
|
||||||
|
"iso_checksum_type": "md5",
|
||||||
|
"iso_url": "http://nixos.org/releases/nixos/nixos-13.07pre4871_18de9f6-3c35dae/nixos-minimal-13.07pre4871_18de9f6-3c35dae-i686-linux.iso",
|
||||||
|
"ssh_username": "vagrant",
|
||||||
|
"ssh_password": "vagrant",
|
||||||
|
"ssh_port": 22,
|
||||||
|
"ssh_wait_timeout": "10000s",
|
||||||
|
"shutdown_command": "sudo shutdown -h now",
|
||||||
|
"vmx_data": {
|
||||||
|
"memsize": "256",
|
||||||
|
"numvcpus": "1",
|
||||||
|
"cpuid.coresPerSocket": "1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
27
scripts/postinstall.sh
Executable file
27
scripts/postinstall.sh
Executable file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/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
|
Loading…
Reference in a new issue