From 103be33ac103b86773599aad26a35e1d6db31cd4 Mon Sep 17 00:00:00 2001 From: Jonas Pfenniger Date: Sat, 23 Feb 2013 20:28:46 +0000 Subject: [PATCH 01/17] Source url updated --- definitions/nixos32/definition.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/definitions/nixos32/definition.rb b/definitions/nixos32/definition.rb index fdaf3da..2021aec 100644 --- a/definitions/nixos32/definition.rb +++ b/definitions/nixos32/definition.rb @@ -1,6 +1,6 @@ iso = { - :file => 'nixos-minimal-0.2pre4454_979117b-789154b-i686-linux.iso', - :md5 => '0f3a1a5a531b01819ec17a0feeea11e6', + :url => 'http://nixos.org/releases/nixos/nixos-0.2pre4476_a5e4432-b076ab9/nixos-minimal-0.2pre4476_a5e4432-b076ab9-i686-linux.iso', + :md5 => 'f035bb375f0fbcbbc4e33a12131e91d4', } session = { @@ -27,9 +27,9 @@ session = { :disk_size => '20400', :hostiocache => 'off', :iso_download_timeout => '1000', - :iso_file => iso[:file], + :iso_file => File.basename(iso[:url]), :iso_md5 => iso[:md5], - :iso_src => "http://nixos.org/releases/nixos/#{iso[:file].gsub(/-[^-]+-linux.iso$/,'')}/#{iso[:file]}", + :iso_src => iso[:url], :kickstart_file => 'configuration.nix', :kickstart_port => '7122', :kickstart_timeout => '10000', From b26c886090c8f071bd6e3e5fa824c3e7e04e25f9 Mon Sep 17 00:00:00 2001 From: Jonas Pfenniger Date: Fri, 29 Mar 2013 22:35:20 +0000 Subject: [PATCH 02/17] Gemfile updates --- Gemfile | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Gemfile b/Gemfile index 980d66e..259c9c7 100644 --- a/Gemfile +++ b/Gemfile @@ -1,15 +1,7 @@ # -*- 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 +source 'https://rubygems.org' group :vagrant do gem 'vagrant', '~> 1.0.5' From ebf0631239299f541be7e0a2db3dd40a2153906d Mon Sep 17 00:00:00 2001 From: Jonas Pfenniger Date: Fri, 29 Mar 2013 22:42:07 +0000 Subject: [PATCH 03/17] nixos 64bit edition. NOT tested. Vagrant 1.1.2 & veewee are in conflict on my system. --- definitions/nixos64/configuration.nix | 39 +++++++++++++++++++++ definitions/nixos64/definition.rb | 50 +++++++++++++++++++++++++++ definitions/nixos64/postinstall.sh | 28 +++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 definitions/nixos64/configuration.nix create mode 100644 definitions/nixos64/definition.rb create mode 100755 definitions/nixos64/postinstall.sh 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 From 9d1d77ebdb777ece8b7275476d3fed50a3f9eef6 Mon Sep 17 00:00:00 2001 From: Jonas Pfenniger Date: Fri, 5 Apr 2013 15:04:06 +0100 Subject: [PATCH 04/17] Fixes machine generation with Vagrant 1.1.x --- Gemfile | 4 ++-- Vagrantfile | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Gemfile b/Gemfile index 259c9c7..22c9312 100644 --- a/Gemfile +++ b/Gemfile @@ -4,6 +4,6 @@ source 'https://rubygems.org' group :vagrant do - gem 'vagrant', '~> 1.0.5' - gem 'veewee', '~> 0.3.1' + #gem 'vagrant', github: 'mitchellh/vagrant', branch: 'v1.1.5 ' + gem 'veewee', github: 'jedi4ever/veewee' end diff --git a/Vagrantfile b/Vagrantfile index 2a89fa3..f607a21 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,6 +1,6 @@ # -*- mode: ruby -*- # vi: set ft=ruby : -Vagrant::Config.run do |config| +Vagrant.configure("2") do |config| config.vm.box = 'nixos32' end From 45f52d3f18b9b02b53a93817124b990412b644ef Mon Sep 17 00:00:00 2001 From: Jonas Pfenniger Date: Fri, 5 Apr 2013 15:19:42 +0100 Subject: [PATCH 05/17] Nixos64 is still failing but it's getting closer --- definitions/nixos64/definition.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/definitions/nixos64/definition.rb b/definitions/nixos64/definition.rb index b746203..233ced2 100644 --- a/definitions/nixos64/definition.rb +++ b/definitions/nixos64/definition.rb @@ -1,6 +1,6 @@ iso = { - :url => 'http://nixos.org/releases/nixos/nixos-0.2pre4587_9000fd8-cfbdb33/nixos-minimal-0.2pre4587_9000fd8-cfbdb33-x86_64-linux.iso', - :md5 => 'f61180f387e72ee85b8f68273e5ff884', + :url => 'http://nixos.org/releases/nixos/nixos-0.2pre4476_a5e4432-b076ab9/nixos-minimal-0.2pre4476_a5e4432-b076ab9-x86_64-linux.iso', + :md5 => '3e0a95f0b7634022e1b0d88c6fc5ab17', } session = { @@ -34,7 +34,7 @@ session = { :kickstart_port => '7122', :kickstart_timeout => '10000', :memory_size => '256', - :os_type_id => 'Linux26', + :os_type_id => 'Linux26_64', :postinstall_files => [ 'postinstall.sh' ], :postinstall_timeout => '10000', :shutdown_cmd => 'shutdown -h now', From fdf050743b01dc6a858949b13d317d4bed157f78 Mon Sep 17 00:00:00 2001 From: Jonas Pfenniger Date: Fri, 5 Apr 2013 15:23:17 +0100 Subject: [PATCH 06/17] README.md added --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..156121b --- /dev/null +++ b/README.md @@ -0,0 +1,10 @@ +NixOS boxes for Vagrant +======================= + +``` +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. From 471bb553a16f8e43033096e62468d311a677ab54 Mon Sep 17 00:00:00 2001 From: Jonas Pfenniger Date: Fri, 5 Apr 2013 16:28:42 +0100 Subject: [PATCH 07/17] box url --- Vagrantfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Vagrantfile b/Vagrantfile index f607a21..d19f9a7 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -3,4 +3,5 @@ Vagrant.configure("2") do |config| config.vm.box = 'nixos32' + config.vm.box_url = 'http://zimbatm.s3.amazonaws.com/nixbox/nixos32.box' end From c4017fe605d4e0bcb2d6147d980f4c4914205fae Mon Sep 17 00:00:00 2001 From: Jonas Pfenniger Date: Mon, 22 Jul 2013 12:07:17 +0100 Subject: [PATCH 08/17] Porting to packer Still not working yet, it's blocking on the SSHd server after install. --- .gitignore | 1 + README.md | 12 ++-- http/configuration.nix | 39 ++++++++++++ nixos32-template.json | 131 +++++++++++++++++++++++++++++++++++++++++ scripts/postinstall.sh | 27 +++++++++ 5 files changed, 204 insertions(+), 6 deletions(-) create mode 100644 http/configuration.nix create mode 100644 nixos32-template.json create mode 100755 scripts/postinstall.sh diff --git a/.gitignore b/.gitignore index d3930f2..e976b47 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /Gemfile.lock /iso /vendor +/packer_cache diff --git a/README.md b/README.md index 156121b..41ca018 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ NixOS boxes for Vagrant ======================= -``` -bundle -bundle exec veewee vbox build nixos32 -bundle exec veewee vbox export nixos32 -``` +First install packer: http://packer.io (or `brew install packer`) -There's also a nixos64 version but it's still failing to build. +Then: + +``` +packer build --only=virtualbox nixos32-template.json +``` diff --git a/http/configuration.nix b/http/configuration.nix new file mode 100644 index 0000000..99df003 --- /dev/null +++ b/http/configuration.nix @@ -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" + ]; + } ]; + }; +} diff --git a/nixos32-template.json b/nixos32-template.json new file mode 100644 index 0000000..5aa7c87 --- /dev/null +++ b/nixos32-template.json @@ -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": [ + "", + "", + "root", + "", + "stop sshd", + "", + "fdisk /dev/sda", + "", + "n", + "", + "a", + "", + "1", + "", + "w", + "", + "mkfs.ext4 -j -L nixos /dev/sda1", + "", + "mount LABEL=nixos /mnt", + "", + "nixos-option --install", + "", + "curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/configuration.nix > /mnt/etc/nixos/configuration.nix &&", + "", + "nixos-install &&", + "", + "reboot", + "" + ], + "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": [ + "", + "", + "root", + "", + "stop sshd", + "", + "fdisk /dev/sda", + "", + "n", + "", + "a", + "", + "1", + "", + "w", + "", + "mkfs.ext4 -j -L nixos /dev/sda1", + "", + "mount LABEL=nixos /mnt", + "", + "nixos-option --install", + "", + "curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/configuration.nix > /mnt/etc/nixos/configuration.nix &&", + "", + "nixos-install &&", + "", + "reboot", + "" + ], + "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" + } + } + ] +} diff --git a/scripts/postinstall.sh b/scripts/postinstall.sh new file mode 100755 index 0000000..57ad04b --- /dev/null +++ b/scripts/postinstall.sh @@ -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 From 5ce953b09e55b6d6f0a2d47ee342442faf595816 Mon Sep 17 00:00:00 2001 From: Jonas Pfenniger Date: Tue, 22 Oct 2013 10:37:07 +0100 Subject: [PATCH 09/17] Removes untested vmware target --- nixos32-template.json | 53 ------------------------------------------- 1 file changed, 53 deletions(-) diff --git a/nixos32-template.json b/nixos32-template.json index 5aa7c87..9f6762a 100644 --- a/nixos32-template.json +++ b/nixos32-template.json @@ -8,9 +8,6 @@ "override": { "virtualbox": { "execute_command": "sudo '{{.Path}}'" - }, - "vmware": { - "execute_command": "sudo '{{.Path}}'" } } } @@ -76,56 +73,6 @@ "1" ] ] - }, - { - "type": "vmware", - "boot_command": [ - "", - "", - "root", - "", - "stop sshd", - "", - "fdisk /dev/sda", - "", - "n", - "", - "a", - "", - "1", - "", - "w", - "", - "mkfs.ext4 -j -L nixos /dev/sda1", - "", - "mount LABEL=nixos /mnt", - "", - "nixos-option --install", - "", - "curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/configuration.nix > /mnt/etc/nixos/configuration.nix &&", - "", - "nixos-install &&", - "", - "reboot", - "" - ], - "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" - } } ] } From dbc4ca0e43c8ec2b91001d62dd02ef23b9222ca7 Mon Sep 17 00:00:00 2001 From: Jonas Pfenniger Date: Tue, 22 Oct 2013 10:43:52 +0100 Subject: [PATCH 10/17] packer fix --- nixos32-template.json | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/nixos32-template.json b/nixos32-template.json index 9f6762a..7b0079a 100644 --- a/nixos32-template.json +++ b/nixos32-template.json @@ -1,20 +1,6 @@ { - "provisioners": [ - { - "type": "shell", - "scripts": [ - "scripts/postinstall.sh" - ], - "override": { - "virtualbox": { - "execute_command": "sudo '{{.Path}}'" - } - } - } - ], "builders": [ { - "type": "virtualbox", "boot_command": [ "", "", @@ -38,27 +24,27 @@ "", "nixos-option --install", "", - "curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/configuration.nix > /mnt/etc/nixos/configuration.nix &&", + "curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/configuration.nix > /mnt/etc/nixos/configuration.nix \u0026\u0026", "", - "nixos-install &&", + "nixos-install \u0026\u0026", "", "reboot", "" ], "boot_wait": "5s", "disk_size": 20400, + "guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso", "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", + "shutdown_command": "sudo shutdown -h now", "ssh_password": "vagrant", "ssh_port": 22, + "ssh_username": "vagrant", "ssh_wait_timeout": "10000s", - "shutdown_command": "sudo shutdown -h now", - "guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso", - "virtualbox_version_file": ".vbox_version", + "type": "virtualbox", "vboxmanage": [ [ "modifyvm", @@ -72,7 +58,22 @@ "--cpus", "1" ] - ] + ], + "virtualbox_version_file": ".vbox_version" + } + ], + "provisioners": [ + { + "override": { + "virtualbox": { + "execute_command": "sudo '{{.Path}}'" + } + }, + "scripts": [ + "scripts/postinstall.sh" + ], + "type": "shell" } ] } + From 007c1c5f641bdf76e865756dd30cbc820bff4c9f Mon Sep 17 00:00:00 2001 From: Jonas Pfenniger Date: Sat, 9 Nov 2013 15:01:02 +0000 Subject: [PATCH 11/17] Remove unused Gemfile --- Gemfile | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 Gemfile diff --git a/Gemfile b/Gemfile deleted file mode 100644 index 22c9312..0000000 --- a/Gemfile +++ /dev/null @@ -1,9 +0,0 @@ -# -*- mode: ruby -*- -# vi: set ft=ruby : - -source 'https://rubygems.org' - -group :vagrant do - #gem 'vagrant', github: 'mitchellh/vagrant', branch: 'v1.1.5 ' - gem 'veewee', github: 'jedi4ever/veewee' -end From 5dd24ec9fb07d2b0e4b4212a2245e01748256a41 Mon Sep 17 00:00:00 2001 From: Jonas Pfenniger Date: Sat, 9 Nov 2013 15:01:41 +0000 Subject: [PATCH 12/17] Use NixOS release 13.10 - build is still not working though --- nixos32-template.json | 42 ++++++++++-------------------------------- scripts/postinstall.sh | 12 ++---------- 2 files changed, 12 insertions(+), 42 deletions(-) diff --git a/nixos32-template.json b/nixos32-template.json index 7b0079a..22668d2 100644 --- a/nixos32-template.json +++ b/nixos32-template.json @@ -6,7 +6,7 @@ "", "root", "", - "stop sshd", + "stop sshd", "", "fdisk /dev/sda", "", @@ -24,55 +24,33 @@ "", "nixos-option --install", "", - "curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/configuration.nix > /mnt/etc/nixos/configuration.nix \u0026\u0026", + "curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/configuration.nix > /mnt/etc/nixos/configuration.nix &&", "", - "nixos-install \u0026\u0026", + "nixos-install &&", "", "reboot", "" ], - "boot_wait": "5s", - "disk_size": 20400, - "guest_additions_path": "VBoxGuestAdditions_{{.Version}}.iso", - "guest_os_type": "Linux26", + "guest_additions_mode": "disable", + "guest_os_type": "Linux", "http_directory": "http", - "iso_checksum": "b1a78fc1b72ea1a19957cb1422817ab6", + "iso_checksum": "d0e0a64fe9a5f3f946e6f9fe0b846e70", "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", + "iso_url": "http://nixos.org/releases/nixos/13.10/nixos-13.10.35445.be4e850/nixos-minimal-13.10.35445.be4e850-x86_64-linux.iso", "shutdown_command": "sudo shutdown -h now", "ssh_password": "vagrant", "ssh_port": 22, "ssh_username": "vagrant", "ssh_wait_timeout": "10000s", "type": "virtualbox", - "vboxmanage": [ - [ - "modifyvm", - "{{.Name}}", - "--memory", - "256" - ], - [ - "modifyvm", - "{{.Name}}", - "--cpus", - "1" - ] - ], "virtualbox_version_file": ".vbox_version" } ], "provisioners": [ { - "override": { - "virtualbox": { - "execute_command": "sudo '{{.Path}}'" - } - }, - "scripts": [ - "scripts/postinstall.sh" - ], - "type": "shell" + "type": "shell", + "execute_command": "sudo '{{.Path}}'", + "script": "scripts/postinstall.sh" } ] } diff --git a/scripts/postinstall.sh b/scripts/postinstall.sh index 57ad04b..7942f9a 100755 --- a/scripts/postinstall.sh +++ b/scripts/postinstall.sh @@ -1,17 +1,9 @@ #!/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 +nix-channel --add http://nixos.org/channels/nixos-13.10 nixos +nixos-rebuild switch --upgrade # Cleanup any previous generations and delete old packages that can be # pruned. From 98a66c044412a899b5f514c449bacab6113447b1 Mon Sep 17 00:00:00 2001 From: zimbatm Date: Wed, 27 Nov 2013 13:08:23 +0000 Subject: [PATCH 13/17] Still not working. It should but ssh timeout wait is indefinite --- http/configuration.nix | 64 +++++++++++++++++++++++++++++------------- nixos32-template.json | 51 +++++++++++++-------------------- nixos64-template.json | 44 +++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+), 52 deletions(-) create mode 100644 nixos64-template.json diff --git a/http/configuration.nix b/http/configuration.nix index 99df003..cd0ffb3 100644 --- a/http/configuration.nix +++ b/http/configuration.nix @@ -1,25 +1,37 @@ { 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; - }; + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + # Use the GRUB 2 boot loader. + boot.loader.grub.enable = true; + boot.loader.grub.version = 2; + boot.loader.grub.device = "/dev/sda"; + + networking.hostName = "nixbox"; + + # Services to enable: + + # Enable the OpenSSH daemon. + services.openssh.enable = true; + + # Enable DBus + services.dbus.enable = true; + + # Default packages + environment.systemPackages = with pkgs; [ + gcc + git + gnumake + python + ruby + rubygems + ]; + + # Creates a "vagrant" users with password-less sudo access users = { extraGroups = [ { name = "vagrant"; } { name = "vboxsf"; } ]; extraUsers = [ { @@ -36,4 +48,16 @@ ]; } ]; }; + + 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 + ''; + } diff --git a/nixos32-template.json b/nixos32-template.json index 22668d2..ffb60d8 100644 --- a/nixos32-template.json +++ b/nixos32-template.json @@ -1,48 +1,35 @@ { "builders": [ { + "type": "virtualbox", + "boot_wait": "1m", "boot_command": [ - "", - "", - "root", - "", - "stop sshd", - "", - "fdisk /dev/sda", - "", - "n", - "", - "a", - "", - "1", - "", - "w", - "", - "mkfs.ext4 -j -L nixos /dev/sda1", - "", - "mount LABEL=nixos /mnt", - "", - "nixos-option --install", - "", - "curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/configuration.nix > /mnt/etc/nixos/configuration.nix &&", - "", - "nixos-install &&", - "", - "reboot", - "" + "root", + "stop sshd", + "fdisk /dev/sda", + "n", + "", + "a", + "1", + "w", + "", + "mkfs.ext4 -j -L nixos /dev/sda1", + "mount LABEL=nixos /mnt", + "nixos-generate-config --root /mnt", + "curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/configuration.nix > /mnt/etc/nixos/configuration.nix", + "nixos-install && reboot" ], "guest_additions_mode": "disable", "guest_os_type": "Linux", "http_directory": "http", - "iso_checksum": "d0e0a64fe9a5f3f946e6f9fe0b846e70", + "iso_checksum": "c10f01734cb187e13068252e2cde565d", "iso_checksum_type": "md5", - "iso_url": "http://nixos.org/releases/nixos/13.10/nixos-13.10.35445.be4e850/nixos-minimal-13.10.35445.be4e850-x86_64-linux.iso", + "iso_url": "http://nixos.org/releases/nixos/13.10/nixos-13.10.35455.45219b9/nixos-minimal-13.10.35455.45219b9-i686-linux.iso", "shutdown_command": "sudo shutdown -h now", "ssh_password": "vagrant", "ssh_port": 22, "ssh_username": "vagrant", - "ssh_wait_timeout": "10000s", - "type": "virtualbox", + "ssh_wait_timeout": "5m", "virtualbox_version_file": ".vbox_version" } ], diff --git a/nixos64-template.json b/nixos64-template.json new file mode 100644 index 0000000..929090b --- /dev/null +++ b/nixos64-template.json @@ -0,0 +1,44 @@ +{ + "builders": [ + { + "type": "virtualbox", + "boot_wait": "1m", + "boot_command": [ + "root", + "stop sshd", + "fdisk /dev/sda", + "n", + "", + "a", + "1", + "w", + "", + "mkfs.ext4 -j -L nixos /dev/sda1", + "mount LABEL=nixos /mnt", + "nixos-generate-config --root /mnt", + "curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/configuration.nix > /mnt/etc/nixos/configuration.nix", + "nixos-install && reboot" + ], + "guest_additions_mode": "disable", + "guest_os_type": "Linux_64", + "http_directory": "http", + "iso_checksum": "fbac8c11661028e6f9c4ec293e1329e1", + "iso_checksum_type": "md5", + "iso_url": "http://nixos.org/releases/nixos/13.10/nixos-13.10.35455.45219b9/nixos-minimal-13.10.35455.45219b9-x86_64-linux.iso", + "shutdown_command": "sudo shutdown -h now", + "ssh_password": "vagrant", + "ssh_port": 22, + "ssh_username": "vagrant", + "ssh_wait_timeout": "5m", + "virtualbox_version_file": ".vbox_version" + } + ], + "provisioners": [ + { + "type": "shell", + "execute_command": "sudo '{{.Path}}'", + "script": "scripts/postinstall.sh" + } + ] +} + From b8843dd22575c8b0b2d2a56795e92ac7817824a0 Mon Sep 17 00:00:00 2001 From: zimbatm Date: Wed, 27 Nov 2013 20:11:51 +0000 Subject: [PATCH 14/17] Working ! --- Makefile | 17 ++++++++++++++++ nixos-template.json.orig | 44 ++++++++++++++++++++++++++++++++++++++++ nixos32-template.json | 2 +- nixos64-template.json | 4 ++-- 4 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 Makefile create mode 100644 nixos-template.json.orig diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c1922a0 --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ + +ISO_URL_32=http://nixos.org/releases/nixos/13.10/nixos-13.10.35455.45219b9/nixos-minimal-13.10.35455.45219b9-i686-linux.iso +ISO_MD5_32=c10f01734cb187e13068252e2cde565d +GUEST_OS_32=Linux + +ISO_URL_64=http://nixos.org/releases/nixos/13.10/nixos-13.10.35455.45219b9/nixos-minimal-13.10.35455.45219b9-x86_64-linux.iso +ISO_MD5_64=fbac8c11661028e6f9c4ec293e1329e1 +GUEST_OS_64=Linux_64 + +all: nixos32-template.json nixos64-template.json + +nixos32-template.json: nixos-template.json.orig + cat $< | sed -e 's|ISO_URL|$(ISO_URL_32)|g' -e 's|ISO_MD5|$(ISO_MD5_32)|g' -e 's|GUEST_OS|$(GUEST_OS_32)|g' > $@ + +nixos64-template.json: nixos-template.json.orig + cat $< | sed -e 's|ISO_URL|$(ISO_URL_64)|g' -e 's|ISO_MD5|$(ISO_MD5_64)|g' -e 's|GUEST_OS|$(GUEST_OS_64)|g' > $@ + diff --git a/nixos-template.json.orig b/nixos-template.json.orig new file mode 100644 index 0000000..032c47f --- /dev/null +++ b/nixos-template.json.orig @@ -0,0 +1,44 @@ +{ + "builders": [ + { + "type": "virtualbox", + "boot_wait": "1m", + "boot_command": [ + "root", + "stop sshd", + "fdisk /dev/sda", + "n", + "", + "a", + "1", + "w", + "", + "mkfs.ext4 -j -L nixos /dev/sda1", + "mount LABEL=nixos /mnt", + "nixos-generate-config --root /mnt", + "curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/configuration.nix > /mnt/etc/nixos/configuration.nix", + "nixos-install && reboot" + ], + "guest_additions_mode": "disable", + "guest_os_type": "GUEST_OS", + "http_directory": "http", + "iso_checksum": "ISO_MD5", + "iso_checksum_type": "md5", + "iso_url": "ISO_URL", + "shutdown_command": "sudo shutdown -h now", + "ssh_password": "vagrant", + "ssh_port": 22, + "ssh_username": "vagrant", + "ssh_wait_timeout": "5m", + "virtualbox_version_file": ".vbox_version" + } + ], + "provisioners": [ + { + "type": "shell", + "execute_command": "sudo sh '{{.Path}}'", + "script": "scripts/postinstall.sh" + } + ] +} + diff --git a/nixos32-template.json b/nixos32-template.json index ffb60d8..314eb49 100644 --- a/nixos32-template.json +++ b/nixos32-template.json @@ -36,7 +36,7 @@ "provisioners": [ { "type": "shell", - "execute_command": "sudo '{{.Path}}'", + "execute_command": "sudo sh '{{.Path}}'", "script": "scripts/postinstall.sh" } ] diff --git a/nixos64-template.json b/nixos64-template.json index 929090b..dd7b3e5 100644 --- a/nixos64-template.json +++ b/nixos64-template.json @@ -13,7 +13,7 @@ "1", "w", "", - "mkfs.ext4 -j -L nixos /dev/sda1", + "mkfs.ext4 -j -L nixos /dev/sda1", "mount LABEL=nixos /mnt", "nixos-generate-config --root /mnt", "curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/configuration.nix > /mnt/etc/nixos/configuration.nix", @@ -36,7 +36,7 @@ "provisioners": [ { "type": "shell", - "execute_command": "sudo '{{.Path}}'", + "execute_command": "sudo sh '{{.Path}}'", "script": "scripts/postinstall.sh" } ] From d29caed78e708b00783ced964196004823f5412f Mon Sep 17 00:00:00 2001 From: zimbatm Date: Wed, 27 Nov 2013 20:36:32 +0000 Subject: [PATCH 15/17] Now generates a vagrant box at the end --- nixos-template.json.orig | 3 +++ nixos32-template.json | 3 +++ nixos64-template.json | 3 +++ 3 files changed, 9 insertions(+) diff --git a/nixos-template.json.orig b/nixos-template.json.orig index 032c47f..ddf44bf 100644 --- a/nixos-template.json.orig +++ b/nixos-template.json.orig @@ -39,6 +39,9 @@ "execute_command": "sudo sh '{{.Path}}'", "script": "scripts/postinstall.sh" } + ], + "post-processors": [ + { "type": "vagrant" } ] } diff --git a/nixos32-template.json b/nixos32-template.json index 314eb49..550cffe 100644 --- a/nixos32-template.json +++ b/nixos32-template.json @@ -39,6 +39,9 @@ "execute_command": "sudo sh '{{.Path}}'", "script": "scripts/postinstall.sh" } + ], + "post-processors": [ + { "type": "vagrant" } ] } diff --git a/nixos64-template.json b/nixos64-template.json index dd7b3e5..52c768e 100644 --- a/nixos64-template.json +++ b/nixos64-template.json @@ -39,6 +39,9 @@ "execute_command": "sudo sh '{{.Path}}'", "script": "scripts/postinstall.sh" } + ], + "post-processors": [ + { "type": "vagrant" } ] } From 711d906b1f280c5f8dff90fe3f9ba12500724e4d Mon Sep 17 00:00:00 2001 From: zimbatm Date: Wed, 27 Nov 2013 20:48:07 +0000 Subject: [PATCH 16/17] Rename everything into nixbox --- Makefile | 10 +++++----- nixos-template.json.orig => nixbox-template.json.orig | 7 +++++-- nixos32-template.json => nixbox32-template.json | 7 +++++-- nixos64-template.json => nixbox64-template.json | 7 +++++-- 4 files changed, 20 insertions(+), 11 deletions(-) rename nixos-template.json.orig => nixbox-template.json.orig (88%) rename nixos32-template.json => nixbox32-template.json (88%) rename nixos64-template.json => nixbox64-template.json (88%) diff --git a/Makefile b/Makefile index c1922a0..dcac0ac 100644 --- a/Makefile +++ b/Makefile @@ -7,11 +7,11 @@ ISO_URL_64=http://nixos.org/releases/nixos/13.10/nixos-13.10.35455.45219b9/nixos ISO_MD5_64=fbac8c11661028e6f9c4ec293e1329e1 GUEST_OS_64=Linux_64 -all: nixos32-template.json nixos64-template.json +all: nixbox32-template.json nixbox64-template.json -nixos32-template.json: nixos-template.json.orig - cat $< | sed -e 's|ISO_URL|$(ISO_URL_32)|g' -e 's|ISO_MD5|$(ISO_MD5_32)|g' -e 's|GUEST_OS|$(GUEST_OS_32)|g' > $@ +nixbox32-template.json: nixbox-template.json.orig + cat $< | sed -e 's|ISO_URL|$(ISO_URL_32)|g' -e 's|ISO_MD5|$(ISO_MD5_32)|g' -e 's|GUEST_OS|$(GUEST_OS_32)|g' -e 's|NIXBOX|nixbox32|g' > $@ -nixos64-template.json: nixos-template.json.orig - cat $< | sed -e 's|ISO_URL|$(ISO_URL_64)|g' -e 's|ISO_MD5|$(ISO_MD5_64)|g' -e 's|GUEST_OS|$(GUEST_OS_64)|g' > $@ +nixbox64-template.json: nixbox-template.json.orig + cat $< | sed -e 's|ISO_URL|$(ISO_URL_64)|g' -e 's|ISO_MD5|$(ISO_MD5_64)|g' -e 's|GUEST_OS|$(GUEST_OS_64)|g' -e 's|NIXBOX|nixbox64|g' > $@ diff --git a/nixos-template.json.orig b/nixbox-template.json.orig similarity index 88% rename from nixos-template.json.orig rename to nixbox-template.json.orig index ddf44bf..806f3b1 100644 --- a/nixos-template.json.orig +++ b/nixbox-template.json.orig @@ -16,7 +16,7 @@ "mkfs.ext4 -j -L nixos /dev/sda1", "mount LABEL=nixos /mnt", "nixos-generate-config --root /mnt", - "curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/configuration.nix > /mnt/etc/nixos/configuration.nix", + "curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/configuration.nix | sed -e 's|nixbox|NIXBOX|g' > /mnt/etc/nixos/configuration.nix", "nixos-install && reboot" ], "guest_additions_mode": "disable", @@ -41,7 +41,10 @@ } ], "post-processors": [ - { "type": "vagrant" } + { + "type": "vagrant", + "output": "NIXBOX-{{.Provider}}.box" + } ] } diff --git a/nixos32-template.json b/nixbox32-template.json similarity index 88% rename from nixos32-template.json rename to nixbox32-template.json index 550cffe..6cdaf2c 100644 --- a/nixos32-template.json +++ b/nixbox32-template.json @@ -16,7 +16,7 @@ "mkfs.ext4 -j -L nixos /dev/sda1", "mount LABEL=nixos /mnt", "nixos-generate-config --root /mnt", - "curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/configuration.nix > /mnt/etc/nixos/configuration.nix", + "curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/configuration.nix | sed -e 's|nixbox|nixbox32|g' > /mnt/etc/nixos/configuration.nix", "nixos-install && reboot" ], "guest_additions_mode": "disable", @@ -41,7 +41,10 @@ } ], "post-processors": [ - { "type": "vagrant" } + { + "type": "vagrant", + "output": "nixbox32-{{.Provider}}.box" + } ] } diff --git a/nixos64-template.json b/nixbox64-template.json similarity index 88% rename from nixos64-template.json rename to nixbox64-template.json index 52c768e..fbd6e96 100644 --- a/nixos64-template.json +++ b/nixbox64-template.json @@ -16,7 +16,7 @@ "mkfs.ext4 -j -L nixos /dev/sda1", "mount LABEL=nixos /mnt", "nixos-generate-config --root /mnt", - "curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/configuration.nix > /mnt/etc/nixos/configuration.nix", + "curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/configuration.nix | sed -e 's|nixbox|nixbox64|g' > /mnt/etc/nixos/configuration.nix", "nixos-install && reboot" ], "guest_additions_mode": "disable", @@ -41,7 +41,10 @@ } ], "post-processors": [ - { "type": "vagrant" } + { + "type": "vagrant", + "output": "nixbox64-{{.Provider}}.box" + } ] } From 0ba9ebc54a8aa8c67e3ca083b58a8763910b9d00 Mon Sep 17 00:00:00 2001 From: zimbatm Date: Wed, 27 Nov 2013 20:54:15 +0000 Subject: [PATCH 17/17] Readme --- README.md | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 41ca018..2b588c2 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,34 @@ NixOS boxes for Vagrant ======================= -First install packer: http://packer.io (or `brew install packer`) +[NixOS](http://nixos.org) is a linux distribution based on a purely functional +package manager. This project builds .box images that can be used by +[vagrant](http://vagrantup.com), the VM manager. + +Status +------ + +stable + +Building the images +------------------- + +First install [packer](http://packer.io) and +[virtualbox](https://www.virtualbox.org/) Then: ``` -packer build --only=virtualbox nixos32-template.json +packer build nixbox32-template.json +# or +packer build nixbox64-template.json ``` + +The .box image is now ready to go and you can use it in vagrant: + +``` +vagrant box add nixbox32 nixbox32-virtualbox.box +# or +vagrant box add nixbox64-nixbox64-virtualbox.box +``` +