Install NixOS on Rackspace Cloud Servers: Difference between revisions
imported>Fadenb Created page with "This page is a slightly modified version of the instructions for Online.net, which in turn are based on Install_NixOS_on_Linode|the instructi..." |
imported>Fadenb m Syntax highlighting |
||
Line 11: | Line 11: | ||
You'll need bzip2 later. Also, you'll need to set up some group permissions so NixOS can install properly: | You'll need bzip2 later. Also, you'll need to set up some group permissions so NixOS can install properly: | ||
< | <syntaxhighlight lang="bash"> | ||
$ apt-get update && apt-get install bzip2 | $ apt-get update && apt-get install bzip2 | ||
$ addgroup nixbld && adduser --disabled-password nixbld0 && usermod -a -G nixbld nixbld0 | $ addgroup nixbld && adduser --disabled-password nixbld0 && usermod -a -G nixbld nixbld0 | ||
</ | </syntaxhighlight> | ||
The user is temporary; you'll be erasing everything, after all. | The user is temporary; you'll be erasing everything, after all. | ||
Line 28: | Line 28: | ||
Now, make sure your partitions are where you expect them, on <tt>/dev/xvdb</tt>. | Now, make sure your partitions are where you expect them, on <tt>/dev/xvdb</tt>. | ||
< | <syntaxhighlight lang="bash"> | ||
fdisk -l /dev/xvdb | fdisk -l /dev/xvdb | ||
</ | </syntaxhighlight> | ||
Here's what mine look like on a 2gb cloud image: | Here's what mine look like on a 2gb cloud image: | ||
< | <syntaxhighlight lang="bash"> | ||
Disk /dev/xvdb: 40 GiB, 42949672960 bytes, 83886080 sectors | Disk /dev/xvdb: 40 GiB, 42949672960 bytes, 83886080 sectors | ||
Units: sectors of 1 * 512 = 512 bytes | Units: sectors of 1 * 512 = 512 bytes | ||
Line 44: | Line 44: | ||
Device Boot Start End Blocks Id System | Device Boot Start End Blocks Id System | ||
/dev/xvda1 * 2048 83875364 41936658+ 83 Linux | /dev/xvda1 * 2048 83875364 41936658+ 83 Linux | ||
</ | </syntaxhighlight> | ||
===Format your partitions=== | ===Format your partitions=== | ||
Line 50: | Line 50: | ||
This will blast away any existing data on your main disk, so make sure you're okay with that. | This will blast away any existing data on your main disk, so make sure you're okay with that. | ||
< | <syntaxhighlight lang="bash"> | ||
mkfs.ext4 /dev/xvdb1 -L nixos | mkfs.ext4 /dev/xvdb1 -L nixos | ||
</ | </syntaxhighlight> | ||
===Mount your freshly minted filesystems=== | ===Mount your freshly minted filesystems=== | ||
Line 58: | Line 58: | ||
and mount the new ones we made: | and mount the new ones we made: | ||
< | <syntaxhighlight lang="bash"> | ||
$ mount /dev/xvdb1 /mnt && mkdir /mnt/boot | $ mount /dev/xvdb1 /mnt && mkdir /mnt/boot | ||
</ | </syntaxhighlight> | ||
==Nix-flavored stuff== | ==Nix-flavored stuff== | ||
Line 68: | Line 68: | ||
We'll need some nix packages to install nix on the target: | We'll need some nix packages to install nix on the target: | ||
< | <syntaxhighlight lang="bash"> | ||
bash <(curl https://nixos.org/nix/install) | bash <(curl https://nixos.org/nix/install) | ||
. /root/.nix-profile/etc/profile.d/nix.sh | . /root/.nix-profile/etc/profile.d/nix.sh | ||
Line 84: | Line 84: | ||
export NIXOS_CONFIG=/root/configuration.nix | export NIXOS_CONFIG=/root/configuration.nix | ||
nix-env -i -A config.system.build.nixos-install -A config.system.build.nixos-option -A config.system.build.nixos-generate-config -f "<nixos>" | nix-env -i -A config.system.build.nixos-install -A config.system.build.nixos-option -A config.system.build.nixos-generate-config -f "<nixos>" | ||
</ | </syntaxhighlight> | ||
===Make configuration for your target system=== | ===Make configuration for your target system=== | ||
Line 90: | Line 90: | ||
Generate a default configuration: | Generate a default configuration: | ||
< | <syntaxhighlight lang="bash"> | ||
nixos-generate-config --root /mnt | nixos-generate-config --root /mnt | ||
</ | </syntaxhighlight> | ||
This will generate <tt>/mnt/etc/nixos/configuration.nix</tt> and <tt>/mnt/etc/nixos/hardware-configuration.nix</tt>. Eyeball the latter (<tt>nano</tt> is preinstalled) to make sure the filesystem config looks reasonable and that it's detected your cores correctly. Then customize the former to your liking. You'll need to explicitly set up your networking information accordingly. | This will generate <tt>/mnt/etc/nixos/configuration.nix</tt> and <tt>/mnt/etc/nixos/hardware-configuration.nix</tt>. Eyeball the latter (<tt>nano</tt> is preinstalled) to make sure the filesystem config looks reasonable and that it's detected your cores correctly. Then customize the former to your liking. You'll need to explicitly set up your networking information accordingly. | ||
Line 100: | Line 100: | ||
Here's a sample config from my box: | Here's a sample config from my box: | ||
< | <syntaxhighlight lang="nix"> | ||
{ config, pkgs, ... }: | { config, pkgs, ... }: | ||
Line 145: | Line 145: | ||
}; | }; | ||
} | } | ||
</ | </syntaxhighlight> | ||
Note something <b>very important</b>: we set GRUB to install to <tt>/dev/xvdb</tt>, which is the right thing to do when we install <i>from the rescue image</i>. Once we reboot, we need to change this to point back to `/dev/xvda`, in case of GRUB updates. | Note something <b>very important</b>: we set GRUB to install to <tt>/dev/xvdb</tt>, which is the right thing to do when we install <i>from the rescue image</i>. Once we reboot, we need to change this to point back to `/dev/xvda`, in case of GRUB updates. | ||
Line 151: | Line 151: | ||
===Actually install the system=== | ===Actually install the system=== | ||
< | <syntaxhighlight lang="bash"> | ||
unset NIXOS_CONFIG | unset NIXOS_CONFIG | ||
nixos-install | nixos-install | ||
</ | </syntaxhighlight> | ||
That should spend some time downloading and copying stuff around, and then should fail without error. After that, tell the web console to exit rescue mode - your machine will be rebooted, and then you can login to NixOS! | That should spend some time downloading and copying stuff around, and then should fail without error. After that, tell the web console to exit rescue mode - your machine will be rebooted, and then you can login to NixOS! |