Install NixOS on Online.Net: Difference between revisions

imported>Mic92
No edit summary
imported>Fadenb
m Syntax highlighting
Line 10: Line 10:


No reason not to be:
No reason not to be:
<pre>
<syntaxhighlight lang="bash">
sudo su
sudo su
cd  
cd  
</pre>
</syntaxhighlight>


===Change the UI language===
===Change the UI language===
Line 19: Line 19:
All the Online.net images are set to French by default, which I don't want:
All the Online.net images are set to French by default, which I don't want:


<pre>
<syntaxhighlight lang="bash">
export LANG=POSIX
export LANG=POSIX
export LC_ALL=POSIX
export LC_ALL=POSIX
</pre>
</syntaxhighlight>


===Check your partitions===
===Check your partitions===
Line 28: Line 28:
Now, make sure your partitions are where you expect them, on /dev/sda.
Now, make sure your partitions are where you expect them, on /dev/sda.


<pre>
<syntaxhighlight lang="bash">
fdisk -l /dev/sda
fdisk -l /dev/sda
</pre>
</syntaxhighlight>


Here's what mine look like on a Dedibox XC:
Here's what mine look like on a Dedibox XC:


<pre>
<syntaxhighlight lang="bash">
/dev/sda1 *          2048    391167    194560  83 Linux
/dev/sda1 *          2048    391167    194560  83 Linux
/dev/sda2          391168 1949523967 974566400  83 Linux
/dev/sda2          391168 1949523967 974566400  83 Linux
/dev/sda3      1949523968 1953523711  1999872  82 Linux swap / Solaris
/dev/sda3      1949523968 1953523711  1999872  82 Linux swap / Solaris
</pre>
</syntaxhighlight>


===Format your partitions===
===Format your partitions===
Line 44: Line 44:
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.


<pre>
<syntaxhighlight lang="bash">
mkfs.ext2 /dev/sda1
mkfs.ext2 /dev/sda1
mkfs.ext4 /dev/sda2 -L nixos
mkfs.ext4 /dev/sda2 -L nixos
Line 50: Line 50:
swapoff -a
swapoff -a
mkswap /dev/sda3
mkswap /dev/sda3
</pre>
</syntaxhighlight>


===Mount your freshly minted filesystems===
===Mount your freshly minted filesystems===
Line 56: Line 56:
and mount the new ones we made:
and mount the new ones we made:


<pre>
<syntaxhighlight lang="bash">
mount /dev/sda2 /mnt
mount /dev/sda2 /mnt
mkdir /mnt/boot
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot
mount /dev/sda1 /mnt/boot
swapon /dev/sda3
swapon /dev/sda3
</pre>
</syntaxhighlight>


==Nix-flavored stuff==
==Nix-flavored stuff==
Line 69: Line 69:
We'll need some nix packages to install nix on the target:
We'll need some nix packages to install nix on the target:


<pre>
<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 85: Line 85:
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>"
</pre>
</syntaxhighlight>


===Make configuration for your target system===
===Make configuration for your target system===
Line 91: Line 91:
Generate a default configuration:
Generate a default configuration:


<pre>
<syntaxhighlight lang="bash">
nixos-generate-config --root /mnt
nixos-generate-config --root /mnt
</pre>
</syntaxhighlight>


This will generate <tt>/mnt/etc/nixos/configuration.nix</tt> and <tt>/mnt/etc/nixos/hardware-configuration.nix</tt>. Eyeball the latter (nano 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. By default it'll use DHCP, which didn't seem to work for me on online.net (please tinker and tell me if you got it working with DHCP though), so make sure to customize the network settings if you don't change anything else.
This will generate <tt>/mnt/etc/nixos/configuration.nix</tt> and <tt>/mnt/etc/nixos/hardware-configuration.nix</tt>. Eyeball the latter (nano 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. By default it'll use DHCP, which didn't seem to work for me on online.net (please tinker and tell me if you got it working with DHCP though), so make sure to customize the network settings if you don't change anything else.
Line 101: Line 101:
Here's a sample config from my box:
Here's a sample config from my box:


<pre>
<syntaxhighlight lang="nix">
{ config, pkgs, ... }:
{ config, pkgs, ... }:


Line 144: Line 144:
     };
     };
}
}
</pre>
</syntaxhighlight>


===Actually install the system===
===Actually install the system===


<pre>
<syntaxhighlight lang="bash">
unset NIXOS_CONFIG
unset NIXOS_CONFIG
nixos-install
nixos-install
</pre>
</syntaxhighlight>


That should spend some time downloading and copying stuff around, and then should fail without error. After that, tell the web console to reboot back into normal mode and your machine will be beautifully nixified. Except for the logo stuck on the Online.net console page. Let me know if you figure out how to get rid of that!
That should spend some time downloading and copying stuff around, and then should fail without error. After that, tell the web console to reboot back into normal mode and your machine will be beautifully nixified. Except for the logo stuck on the Online.net console page. Let me know if you figure out how to get rid of that!