From 3df8bc3cf8fd433b621f480be11783b778353a1c Mon Sep 17 00:00:00 2001 From: Pierre Radermecker Date: Wed, 19 Dec 2018 17:56:37 +0100 Subject: [PATCH 1/7] Add hyperv provider It looks like you really need to create an network adapter (here named "Devbox") --- nixos-x86_64.json | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/nixos-x86_64.json b/nixos-x86_64.json index 41e42ee..3d6dbb0 100644 --- a/nixos-x86_64.json +++ b/nixos-x86_64.json @@ -52,6 +52,36 @@ "1024" ] ] + }, + { + "boot_wait": "40s", + "boot_command": [ + "echo http://{{.HTTPIP}}:{{.HTTPPort}} > .packer_http", + "mkdir -m 0700 .ssh", + "curl $(cat .packer_http)/install_rsa.pub > .ssh/authorized_keys", + "sed -i '5ivirtualisation.hypervGuest.enable = true;' /etc/nixos/configuration.nix", + "sed -i '6idocumentation.man.enable = false; documentation.enable = false;' /etc/nixos/configuration.nix", + "sed -i '7iservices.nixosManual.enable = false;' /etc/nixos/configuration.nix", + "nixos-rebuild switch", + "systemctl start sshd" + ], + "http_directory": "scripts", + "switch_name": "Devbox", + "iso_checksum_type": "sha256", + "shutdown_command": "shutdown -h now", + "ssh_private_key_file": "./scripts/install_rsa", + "ssh_port": 22, + "ssh_timeout": "600s", + "ssh_username": "root", + "type": "hyperv-iso", + "iso_url": "https://d3g5gsiof5omrk.cloudfront.net/nixos/18.09/nixos-18.09.1534.d45a0d7a4f5/nixos-minimal-18.09.1534.d45a0d7a4f5-x86_64-linux.iso", + "iso_checksum": "8da4c81d611f34c33a69f21aa353f08f3504ffb70f1c78417fdb7c5ed7a88eae", + "disk_size": 62000, + "cpu": 3, + "ram_size": 2048, + "enable_mac_spoofing": true, + "guest_additions_mode": "disable", + "enable_virtualization_extensions": false } ], "provisioners": [ From 600d6603fd11694deb2fe74b6c806d7f1a272ffe Mon Sep 17 00:00:00 2001 From: Pierre Radermecker Date: Wed, 19 Dec 2018 18:12:22 +0100 Subject: [PATCH 2/7] Add custom configuration hook file This is handy to configure locale, hypervisor or any other organisation specific configuration. --- scripts/configuration.nix | 1 + scripts/custom-configuration.nix | 6 ++++++ scripts/install.sh | 2 ++ 3 files changed, 9 insertions(+) create mode 100644 scripts/custom-configuration.nix diff --git a/scripts/configuration.nix b/scripts/configuration.nix index 877ff1e..3762bbb 100644 --- a/scripts/configuration.nix +++ b/scripts/configuration.nix @@ -6,6 +6,7 @@ ./hardware-configuration.nix ./hardware-builder.nix ./vagrant.nix + ./custom-configuration.nix ]; # Use the GRUB 2 boot loader. diff --git a/scripts/custom-configuration.nix b/scripts/custom-configuration.nix new file mode 100644 index 0000000..5361b91 --- /dev/null +++ b/scripts/custom-configuration.nix @@ -0,0 +1,6 @@ +{ config, pkgs, ... }: + +{ +# Place here any custom configuration specific to your organisation (locale, ...) +# if you want it to be part of the packer base image to be used with vagrant. +} diff --git a/scripts/install.sh b/scripts/install.sh index 3b8c2e7..9048410 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -22,11 +22,13 @@ mount LABEL=nixos /mnt # Setup system nixos-generate-config --root /mnt + curl -sf "$packer_http/vagrant.nix" > /mnt/etc/nixos/vagrant.nix curl -sf "$packer_http/vagrant-hostname.nix" > /mnt/etc/nixos/vagrant-hostname.nix curl -sf "$packer_http/vagrant-network.nix" > /mnt/etc/nixos/vagrant-network.nix curl -sf "$packer_http/builders/$PACKER_BUILDER_TYPE.nix" > /mnt/etc/nixos/hardware-builder.nix curl -sf "$packer_http/configuration.nix" > /mnt/etc/nixos/configuration.nix +curl -sf "$packer_http/custom-configuration.nix" > /mnt/etc/nixos/custom-configuration.nix ### Install ### nixos-install From 4f7649d6f5c0e4c497252ac16dc91c7873aa8277 Mon Sep 17 00:00:00 2001 From: Pierre Radermecker Date: Thu, 3 Jan 2019 16:27:02 +0100 Subject: [PATCH 3/7] Fix up iso_url for hyperv-iso provider --- nixos-x86_64.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos-x86_64.json b/nixos-x86_64.json index 3d6dbb0..0cbe9e2 100644 --- a/nixos-x86_64.json +++ b/nixos-x86_64.json @@ -74,8 +74,8 @@ "ssh_timeout": "600s", "ssh_username": "root", "type": "hyperv-iso", - "iso_url": "https://d3g5gsiof5omrk.cloudfront.net/nixos/18.09/nixos-18.09.1534.d45a0d7a4f5/nixos-minimal-18.09.1534.d45a0d7a4f5-x86_64-linux.iso", - "iso_checksum": "8da4c81d611f34c33a69f21aa353f08f3504ffb70f1c78417fdb7c5ed7a88eae", + "iso_url": "https://d3g5gsiof5omrk.cloudfront.net/nixos/18.09/nixos-18.09.1799.b9fa31cea0e/nixos-minimal-18.09.1799.b9fa31cea0e-x86_64-linux.iso", + "iso_checksum": "cc7c399c5fe4672383fe54cb1d648854a0d6732765fe1a61bb38b3fe3b7c6d2f", "disk_size": 62000, "cpu": 3, "ram_size": 2048, From e0b129aa5c25d99068732cec1829d27b7d6bf266 Mon Sep 17 00:00:00 2001 From: Pierre Radermecker Date: Thu, 3 Jan 2019 16:51:24 +0100 Subject: [PATCH 4/7] Remove the need for sed --- nixos-x86_64.json | 3 --- scripts/builders/hyperv-iso.nix | 5 +++++ 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 scripts/builders/hyperv-iso.nix diff --git a/nixos-x86_64.json b/nixos-x86_64.json index 0cbe9e2..722d3e6 100644 --- a/nixos-x86_64.json +++ b/nixos-x86_64.json @@ -59,9 +59,6 @@ "echo http://{{.HTTPIP}}:{{.HTTPPort}} > .packer_http", "mkdir -m 0700 .ssh", "curl $(cat .packer_http)/install_rsa.pub > .ssh/authorized_keys", - "sed -i '5ivirtualisation.hypervGuest.enable = true;' /etc/nixos/configuration.nix", - "sed -i '6idocumentation.man.enable = false; documentation.enable = false;' /etc/nixos/configuration.nix", - "sed -i '7iservices.nixosManual.enable = false;' /etc/nixos/configuration.nix", "nixos-rebuild switch", "systemctl start sshd" ], diff --git a/scripts/builders/hyperv-iso.nix b/scripts/builders/hyperv-iso.nix new file mode 100644 index 0000000..f7bf66e --- /dev/null +++ b/scripts/builders/hyperv-iso.nix @@ -0,0 +1,5 @@ +{ ... }: +{ + # Enable guest additions. + virtualisation.hypervGuest.enable = true; +} From 45b305171f1d074de016eed92a892b9eed14be93 Mon Sep 17 00:00:00 2001 From: Pierre Radermecker Date: Fri, 4 Jan 2019 23:25:43 +0100 Subject: [PATCH 5/7] Remove deprecated line --- nixos-x86_64.json | 1 - 1 file changed, 1 deletion(-) diff --git a/nixos-x86_64.json b/nixos-x86_64.json index 722d3e6..a822b7a 100644 --- a/nixos-x86_64.json +++ b/nixos-x86_64.json @@ -59,7 +59,6 @@ "echo http://{{.HTTPIP}}:{{.HTTPPort}} > .packer_http", "mkdir -m 0700 .ssh", "curl $(cat .packer_http)/install_rsa.pub > .ssh/authorized_keys", - "nixos-rebuild switch", "systemctl start sshd" ], "http_directory": "scripts", From af460d481bcc6b9fb318d4589c5390c51f8016bb Mon Sep 17 00:00:00 2001 From: Pierre Radermecker Date: Sat, 5 Jan 2019 23:00:23 +0100 Subject: [PATCH 6/7] Revert "Remove deprecated line" This reverts commit 45b305171f1d074de016eed92a892b9eed14be93. --- nixos-x86_64.json | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos-x86_64.json b/nixos-x86_64.json index a822b7a..722d3e6 100644 --- a/nixos-x86_64.json +++ b/nixos-x86_64.json @@ -59,6 +59,7 @@ "echo http://{{.HTTPIP}}:{{.HTTPPort}} > .packer_http", "mkdir -m 0700 .ssh", "curl $(cat .packer_http)/install_rsa.pub > .ssh/authorized_keys", + "nixos-rebuild switch", "systemctl start sshd" ], "http_directory": "scripts", From 8e94157f12534febdf781f2bad65f61efb8f5db8 Mon Sep 17 00:00:00 2001 From: Pierre Radermecker Date: Sat, 5 Jan 2019 23:00:49 +0100 Subject: [PATCH 7/7] Revert "Remove the need for sed" This reverts commit e0b129aa5c25d99068732cec1829d27b7d6bf266. --- nixos-x86_64.json | 3 +++ scripts/builders/hyperv-iso.nix | 5 ----- 2 files changed, 3 insertions(+), 5 deletions(-) delete mode 100644 scripts/builders/hyperv-iso.nix diff --git a/nixos-x86_64.json b/nixos-x86_64.json index 722d3e6..0cbe9e2 100644 --- a/nixos-x86_64.json +++ b/nixos-x86_64.json @@ -59,6 +59,9 @@ "echo http://{{.HTTPIP}}:{{.HTTPPort}} > .packer_http", "mkdir -m 0700 .ssh", "curl $(cat .packer_http)/install_rsa.pub > .ssh/authorized_keys", + "sed -i '5ivirtualisation.hypervGuest.enable = true;' /etc/nixos/configuration.nix", + "sed -i '6idocumentation.man.enable = false; documentation.enable = false;' /etc/nixos/configuration.nix", + "sed -i '7iservices.nixosManual.enable = false;' /etc/nixos/configuration.nix", "nixos-rebuild switch", "systemctl start sshd" ], diff --git a/scripts/builders/hyperv-iso.nix b/scripts/builders/hyperv-iso.nix deleted file mode 100644 index f7bf66e..0000000 --- a/scripts/builders/hyperv-iso.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ ... }: -{ - # Enable guest additions. - virtualisation.hypervGuest.enable = true; -}