NixOS / nixops

NixOps is a tool for deploying to NixOS machines in a network or cloud.
https://nixos.org/nixops
GNU Lesser General Public License v3.0
1.86k stars 365 forks source link

digitalocean.DataReadError creating new droplet #1502

Open GlennS opened 2 years ago

GlennS commented 2 years ago

Using NixOps 1.7 from the Nixos 21.11 channel, I get the following error when I try to create a DigitalOcean droplet:

digitalocean.DataReadError: You specified an invalid image for Droplet creation.

My best guess is that the image we use as a precursor to nixos-infect is out of date.

Things I've tried so far with no effect:

Things I plan to try next:

Instructions to reproduce.

shell.nix:

let
  nixpkgsVersion = "21.11";

  ## `git ls-remote https://github.com/nixos/nixpkgs nixos-${nixPkgsVersion}`
  commitRev = "6f07605b6916abee5435ea1145a7541299a87c1b";

  nixpkgs = builtins.fetchTarball {
    name = "nixos-${nixpkgsVersion}-from-2022-01-22";
    url = "https://github.com/nixos/nixpkgs/archive/${commitRev}.tar.gz";
    ## Hash obtained using `nix-prefetch-url --unpack <url>`
    sha256 = "0w3ffnrzxirsjxc9ajr7q9250qcm5hpz104g2yr9v7z4373glc87";
  };

  pkgs = import nixpkgs {};
in pkgs.mkShell {
  shellHook = ''
    export NIX_PATH="nixpkgs=${nixpkgs}:."
  '';

  buildInputs = with pkgs; [
    nixops
  ];
}

machine.nix:

{
  network.description = "blah";

  machine = {pkgs, config, ...}: {
    system.stateVersion = "21.11";

    networking = {
      firewall = {
        allowedTCPPorts = [ 22 80 443 ];
      };
    };

    services.openssh = {
      enable = true;
    };
}

deployment.nix:

{
  resources.sshKeyPairs.ssh-key = {};

  machine =
  {config, pkgs, ...}: {

    deployment = {
      targetEnv = "digitalOcean";
      digitalOcean = {
        enableIpv6 = true;
        region = "lon1";
        size = "1gb";
      };
    };
  };
}

Then run

nix-shell
export NIXOPS_DEPLOYMENT="glenn-server"
export NIXOPS_STATE="state.nixops"
export DIGITAL_OCEAN_AUTH_TOKEN=$(cat /home/glenn/.ssh/digital-ocean-nixops)
nixops create machine.nix deployment.nix -d glenn-server
# This last line will cause the error
nixops deploy