nix-community / nixos-anywhere-examples

Example flake for nixos-anywhere
https://nix-community.github.io/nixos-anywhere/ [maintainer=@Mic92]
33 stars 13 forks source link

DigitalOcean: Cannot ssh into the droplet #4

Closed fillon closed 9 months ago

fillon commented 9 months ago

Hi,

I tried to build a droplet with nixos-anywhere.

Once the install is completed, I cannot ssh or ping the droplet.

I tried with different size or config: Premium Intel, disk: NVMe SSD, 4GB

nix --extra-experimental-features "nix-command flakes" run github:numtide/nixos-anywhere -- --flake .#digitalocean root@<ip>

Any idea?

opdavies commented 7 months ago

I tried and also had this problem. How did you resolve it, @fillon?

fillon commented 7 months ago

I solved it by not using nixos-anywhere, in that case I don't think it was the right tool.

With DO you can build an image, upload it and use it to create new droplet. Which is faster than creating a droplet with an Ubuntu image for example and running nixos-anywhere.

Create a nixos image

# image.nix
{ pkgs ? import <nixpkgs> { } }:
let
  config = {
    imports =
      [ <nixpkgs/nixos/modules/virtualisation/digital-ocean-image.nix> ];
  };
in (pkgs.nixos config).digitalOceanImage

nix build --file ./image.nix

Upload the image in /result to DO.

Create a new Droplet

On DO, create a new droplet and select your custom nixos image.

Configure your droplets

Once the droplet is created, then I configure it with deploy-rs to maintain all my droplets remotely.

eureka-cpu commented 4 months ago

I'm running into this issue currently. I've checked on several things, seems that everything should be working, eg sshd is running as expected, ssh keys are present, no errors in dmesg.. I'm going to open a new issue and reference this one.

netpleb commented 4 months ago

I also ran into the same issue as @fillon. After many failed attempts of using nixos-anywhere with digital ocean droplets, I switched to hetzner-cloud and nixos-anywhere worked perfectly the first time!

eureka-cpu commented 4 months ago

@netpleb I've opened a new issue #5 with more information there. I also have a working configuration at github.com/versatus/versatus.nix/blob/eureka-cpu/digital-ocean-image then I'm using the DigitalOcean API to upload the image and rebuild the droplet with the new image.