diff --git a/README.md b/README.md index fc22bc3..f67aeb9 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ First install [packer](http://packer.io) and [virtualbox](https://www.virtualbox Then: ``` -packer build cycle64-template.json +packer build template.json ``` The .box image is now ready to go. Install it into Vagrant via: diff --git a/keys/install.key b/keys/install.key new file mode 100644 index 0000000..6e9cddd --- /dev/null +++ b/keys/install.key @@ -0,0 +1,27 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEAr2QdWgfsKKXCPIjrPHZ0YRzsqEcIjj2Apg62qylsh4DPZ2tw +XV3mtJVj9QchOHoeDiD1l4jUeebmijkYGCi/NkiO3pl6mM6LvVhfWSaCu3tlEzwI +XLxLR5W+wGgUs+Tkxd3QTLuHCCKwu9mxH6luoH5iNuZ9ZcfP131DEX6xLIOKjenr +NbIb8famtiF4GhzjeQ/hTYCQk5vYxcI1+O5UOV3eyjVqo0b4WugdNMZERT5ZwyN2 +rKWA1FumngCNsMh1demYj+ii/lxn6scOBHy9uTyLWrTt/H2U117XcK0jrGLSQTnY +Jqu1vlr/0Vp0xQgemPHZftm5OZPvVvwYWprsYwIDAQABAoIBAQCGMuMmfQNcgqAh +M15ScAxSNhB6HYfVVge2h3GLe3GYKJ4JcrKSLgQVTm0iEaeAkCepBd0EamSxNVRW +lKLz8VGFFnWCqwqcGwXfBdxG2WmUTDElS3zWgBhVmKVQkRKuJshJAZSc8au7NNfn +lASrxjdoQ+ugODHgi8djCWwk2bx04pexVh6k3iMtzQ3kF5aureh3PdTVqudpwGPy +BuRJeMSLCrYvJtJayoYoV/i4NpLYmXHCpGlZ2R+Ig+JdAX6C6Nf3vBrnyEksV/Rc +5ls2zN5bprJi5ESImQTAuweJUo3SvyWQU/4TtOu+taYMLgo9UBdSr4+g08fY4kiO +aITPwYpBAoGBAOfNfaa3K2f+pYztWD13dNq/M9ljl7oLEU7JT/Ft1JhF8578X5nc +7NGyQyWGMytZUQE7M7mnCJ0W1jLtoL9xrUap757eEQ4vHoOAFlOCfq3ccjjeICAr +WGe1ccZgV/RL8vtYR1wTBEAjcefk/eBMXkf0+8Al2hk9OdRdBq/ivcEDAoGBAMGz +H/XWrHC3IWY73rka4XYw2t8kHXzLxxAJRC56Ew0o/3PXjOU7ue9YO1iGyx3JNIky +yTrbyeZxXCBADjojPDBCTzVcFDdGKAsj8akzS6EmB3eJgmcV+HvPWcKPNjIfLBY8 +ysY/H/hm8Ahbwa0OYG7FdQSFhiIX5iDf3ZdaWVkhAoGAVrdMC0M4zMW5nvfna881 +euPOfMPCLgoX5nZvHq1su65njhFxnjjEq0nZzr7eg5f9Ms238vrmwQWbCiBVY2ke +XnISP0dp7/l2m9EeCQ2nYFk4rceDEyXEA8AgGQtPvAdxlc+Xmn1OuMPJx+ulgfRv +zNF8IIzIg2qhKK3IY6IaRIsCgYAKpuMXDdslx6xahuhUnZnQehdPNhk5B6vGwfux +4pyxmJOTt0LUSFiNRPjegWsiFDKDaPuP9Q5BUfKTA3LE17MzpDHe6VVjRMRm+G8N +svhxwDmg5Tr6mEa16E0zWdTNJNGz11v/UvFbI64Hh6Q69BNxhAJPYVhi/5V0MVtq +O1m2gQKBgQDVip9tC4WVD9H342Ijf9FnUrXtdhTrceo6vPdYpaEkWfmW8+T7v4W7 +qzgyMseGPleh2jNID7xLLLJLXVJ4Whcg5PDWCYu14bs2mxm29pmqyZsLMPY512NM +10i562nONoR+rvOUQCBF1omv/JHB4FhHSQasSrnS0eZhyuaVRwVfTw== +-----END RSA PRIVATE KEY----- diff --git a/keys/install.key.pub b/keys/install.key.pub new file mode 100644 index 0000000..d09c34e --- /dev/null +++ b/keys/install.key.pub @@ -0,0 +1 @@ +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCvZB1aB+wopcI8iOs8dnRhHOyoRwiOPYCmDrarKWyHgM9na3BdXea0lWP1ByE4eh4OIPWXiNR55uaKORgYKL82SI7emXqYzou9WF9ZJoK7e2UTPAhcvEtHlb7AaBSz5OTF3dBMu4cIIrC72bEfqW6gfmI25n1lx8/XfUMRfrEsg4qN6es1shvx9qa2IXgaHON5D+FNgJCTm9jFwjX47lQ5Xd7KNWqjRvha6B00xkRFPlnDI3aspYDUW6aeAI2wyHV16ZiP6KL+XGfqxw4EfL25PItatO38fZTXXtdwrSOsYtJBOdgmq7W+Wv/RWnTFCB6Y8dl+2bk5k+9W/Bhamuxj public@installkey diff --git a/nixos/basic.nix b/nixos/basic.nix index 3778557..6f9312b 100644 --- a/nixos/basic.nix +++ b/nixos/basic.nix @@ -1,10 +1,14 @@ { config, pkgs, ... }: +# +# This file is only used for the inital install. It is a bare-bones +# system configuration with just grub and openssh. +# +# This file should be removed by the postinstall scripts. +# + { - imports = - [ # Include the results of the hardware scan. - ./hardware-configuration.nix - ]; + imports =[ ./hardware-configuration.nix ]; # Use the GRUB 2 boot loader. boot.loader.grub.enable = true; @@ -16,8 +20,15 @@ # Enable the OpenSSH daemon. services.openssh.enable = true; + services.openssh.permitRootLogin = "yes"; + users.extraUsers.root.openssh.authorizedKeys.keys = [ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCvZB1aB+wopcI8iOs8dnRhHOyoRwiOPYCmDrarKWyHgM9na3BdXea0lWP1ByE4eh4OIPWXiNR55uaKORgYKL82SI7emXqYzou9WF9ZJoK7e2UTPAhcvEtHlb7AaBSz5OTF3dBMu4cIIrC72bEfqW6gfmI25n1lx8/XfUMRfrEsg4qN6es1shvx9qa2IXgaHON5D+FNgJCTm9jFwjX47lQ5Xd7KNWqjRvha6B00xkRFPlnDI3aspYDUW6aeAI2wyHV16ZiP6KL+XGfqxw4EfL25PItatO38fZTXXtdwrSOsYtJBOdgmq7W+Wv/RWnTFCB6Y8dl+2bk5k+9W/Bhamuxj public@installkey" ]; # Enable DBus services.dbus.enable = true; + # Default packages + environment.systemPackages = with pkgs; [ + git + ]; + } diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 1bf16df..a335823 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -1,10 +1,7 @@ { config, pkgs, ... }: { - imports = - [ # Include the results of the hardware scan. - ./hardware-configuration.nix - ]; + imports = [ ./hardware-configuration.nix ]; # Use the GRUB 2 boot loader. boot.loader.grub.enable = true; @@ -17,6 +14,9 @@ # Enable the OpenSSH daemon. services.openssh.enable = true; + # Virtualbox guess + services.virtualbox.enable = true; + # Enable DBus services.dbus.enable = true; @@ -57,15 +57,14 @@ } ]; }; - 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 - ''; + 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/scripts/postinstall.sh b/scripts/postinstall.sh index ac17ac9..742b7b2 100755 --- a/scripts/postinstall.sh +++ b/scripts/postinstall.sh @@ -1,13 +1,15 @@ #!/bin/sh +set -e + # Checkout our nixpkg tree -NIXREPO=/etc/nixos/oxdi -mkdir -p $NIXREPO -cd $NIXREPO -git clone https://github.com/oxdi/nixpkgs.git +git config --global http.sslVerify false +NIXREPO=/etc/nixos +# (cd $NIXREPO && git clone http://github.com/oxdi/nixpkgs.git) # Update and initialize our new configuration -nixos-rebuild -I nixos=$NIXREPO/nixos -I nixpkgs=$NIXREPO/nixpkgs switch +# nixos-rebuild -I nixos=$NIXREPO/nixpkgs/nixos -I nixpkgs=$NIXREPO/nixpkgs switch +nixos-rebuild switch # Cleanup any previous generations and delete old packages that can be # pruned. @@ -17,5 +19,5 @@ for x in `seq 0 2` ; do done # Zero out the disk (for better compression) -dd if=/dev/zero of=/EMPTY bs=1M -rm -rf /EMPTY +# dd if=/dev/zero of=/EMPTY bs=1M +# rm -rf /EMPTY diff --git a/template.json b/template.json index ddcbe7a..ff2bdf1 100644 --- a/template.json +++ b/template.json @@ -2,7 +2,7 @@ "builders": [ { "type": "virtualbox-iso", - "boot_wait": "2m", + "boot_wait": "1m", "boot_command": [ "root", "stop sshd", @@ -16,18 +16,18 @@ "mkfs.ext4 -j -L nixos /dev/sda1", "mount LABEL=nixos /mnt", "nixos-generate-config --root /mnt", + "curl http://{{ .HTTPIP }}:{{ .HTTPPort }}/basic.nix > /mnt/etc/nixos/configuration.nix", "nixos-install && reboot" ], "guest_additions_mode": "disable", - "guest_os_type": "Gentoo_64", - "http_directory": "http", - "iso_checksum": "fbac8c11661028e6f9c4ec293e1329e1", + "guest_os_type": "Linux_64", + "http_directory": "nixos", + "iso_checksum": "48395b4bd21675703c87cfae1feb68ed", "iso_checksum_type": "md5", "iso_url": "http://releases.nixos.org/nixos/unstable/nixos-14.02pre38596.1dd0e05/nixos-minimal-14.02pre38596.1dd0e05-x86_64-linux.iso", "shutdown_command": "sudo shutdown -h now", - "ssh_password": "vagrant", - "ssh_port": 22, - "ssh_username": "vagrant", + "ssh_username": "root", + "ssh_key_path": "keys/install.key", "ssh_wait_timeout": "10m", "virtualbox_version_file": ".vbox_version" }