Install NixOS on OCI Oracle Cloud

Hi!
I’m trying to install NixOS in a oracle cloud account, using the “Always Free Tier” resources…
Actually i tried using nixos-infect, but without luck… I got some errors about nixos-rebuild not found, or some problems in the PATH with non-interactive shell sessions.
Also in the ARM instances, i always got errors about the /boot partition full.
Then i tried using the kexec method, but got a bunch of network errors…

Any tips?

Maybe this will help you.

i succeed using nixos-infect and Oracle Linux as base host. Actually no problems with x86 VMs, i managed to deploy both using deploy-rs. But i got a bunch of problems with the aarch64 ones:

bash: line 1: /run/current-system/sw/bin/nix-store: cannot execute binary file: Exec format error
error: cannot connect to 'root@XXX.XXX.XXX.XXX'
🚀 ❌ [deploy] [ERROR] Failed to push profile: Nix copy command resulted in a bad exit code: Some(1)

This while deploying with deploy-rs, and got this error while executing any nix related command:

nix-channel --list
-bash: /run/current-system/sw/bin/nix-channel: cannot execute binary file: Exec format error

This for reference:
uname -a Linux freeinstance0 5.15.36 #1-NixOS SMP Wed Apr 27 12:39:02 UTC 2022 aarch64 GNU/Linux

I guess that the only option available for me is using kexec
But i have some questions about your gist; let’s say that i have an Ubuntu Host with IP 123.456.7.89.
I can connect to it with something like ssh -i /path/to/ssk-key ubuntu@123.456.7.89, upload the tar.gz built from the kexec.nix file, and run the kexec. But how can i reconnect within the kexec ?
Do i need to specify the public IP somewhere in the kexec.nix ?

No, DHCP will do its thing. You only need to specify public ssh key for root. kexec boot can take a long time so make sure to wait at least 5-10 minutes. You can debug kexec boot using vnc or serial connection.

This while deploying with deploy-rs, and got this error while executing any nix related command:

Make sure you are using proper value for system attribute. It must be aarch64-linux.

Oh, so can i reconnect using ubuntu@123.456.7.89 right?

I have deploy-rs.lib.aarch64-linux.activate.nixos.self.nixosConfiguratioons."${server}"; and in nixosConfiguration system = "aarch64-linux"

Oh, so can i reconnect using ubuntu@123.456.7.89 right?

Only if you declare ubuntu user in your kexec config.

I have deploy-rs.lib.aarch64-linux.activate.nixos.self.nixosConfiguratioons."${server}"; and in nixosConfiguration system = "aarch64-linux"

Maybe you need deploy-rs.lib.x86_64-linux, I haven’t used deploy-rs with mixed architectures.

I got a bunch of errors like this:

tar: nix/store/rgk1qjfj70ajj5adwfibqsrp3sm5mhj5-extra-utils: Cannot mkdir: Read-only file system
tar: nix/store/rgk1qjfj70ajj5adwfibqsrp3sm5mhj5-extra-utils/lib/libudev.so.1: Cannot open: No such file or directory
tar: nix/store/rgk1qjfj70ajj5adwfibqsrp3sm5mhj5-extra-utils: Cannot mkdir: Read-only file system
tar: nix/store/rgk1qjfj70ajj5adwfibqsrp3sm5mhj5-extra-utils/lib/libuuid.so.1: Cannot open: No such file or directory
tar: nix/store/rgk1qjfj70ajj5adwfibqsrp3sm5mhj5-extra-utils: Cannot mkdir: Read-only file system
tar: nix/store/rgk1qjfj70ajj5adwfibqsrp3sm5mhj5-extra-utils/lib/libzstd.so.1: Cannot open: No such file or directory
tar: nix/store/rgk1qjfj70ajj5adwfibqsrp3sm5mhj5-extra-utils: Cannot mkdir: Read-only file system
tar: nix/store/rgk1qjfj70ajj5adwfibqsrp3sm5mhj5-extra-utils/sbin: Cannot open: No such file or directory
tar: nix/store/x90dhc8k96xpfa87p1bzwfcnhdjafihn-keymap: Cannot open: Read-only file system
tar: nix/store: Cannot utime: Read-only file system
tar: nix/store: Cannot change ownership to uid 0, gid 0: Read-only file system
tar: nix/store: Cannot change mode to rwxr-xr-x: Read-only file system
tar: Exiting with failure status due to previous errors

Executing kexec on the ARM host

I tried building the kexec.nix file directly on the ARM host, but got this error:

lrwxrwxrwx  1 ubuntu ubuntu   56 May 18 15:34 kexec -> /nix/store/x2gf1yr1s0pa44sh248jl0q2j9vhwyvi-kexec_bundle*

root@instance-20220518-1702:/tmp# ./kexec
-bash: ./kexec: Permission denied