Open zaphar opened 3 years ago
This is due to the fact that the old nixops code is trying to associate the bootstrap image with the latest image available in nixpkgs as sourceUri
nameValuePair ("bootstrap") [({ pkgs, ...}: {
inherit (gce) project serviceAccount accessKey;
sourceUri = images."${pkgs.lib.substring 0 5 pkgs.lib.nixpkgsVersion}" or images.latest;
})]
https://github.com/NixOS/nixops/blob/pre-plugins/nix/eval-machine-info.nix#L293-L296
While the latest source image has changed the format as described per https://github.com/NixOS/nixpkgs/pull/117021
# This format will be handled by the upcoming NixOPS 2.0 release.
# The old images based on a GS object are deprecated.
"20.09" = {
project = "nixos-cloud";
name = "nixos-image-20-09-3531-3858fbc08e6-x86-64-linux";
};
https://github.com/nixos/nixpkgs/blob/master/nixos/modules/virtualisation/gce-images.nix#L9-L14
This seems to happen only when using the old nixops 1.7 in combination with the 'master' branch of nixpkgs
@zaphar what exactly do you have control on? Is it possible to update the gce-images.nix file in nixpkgs? Or is it possible to tweak the nixops code? Even better, can you switch to the new nixops 2.0?
FYI @AmineChikhaoui
I was able to workaround this by adding a bootstrap image resource with the resourceUri and make it work. @tewfik-ghariani , is there a description or writeup anywhere of what I need to do to upgrade to 2.0?
@zaphar - I've looked around and I was able to use nixops 2.0 via a Hydra build ( or locally via poetry ) using this repo : https://github.com/tewfik-ghariani/my-nixops
Also, If I understood correctly, nixops-2.0 unstable was merged to nixpkgs master so there might be a way to fetch it from there and use it
I was able to workaround this by adding a bootstrap image resource with the resourceUri and make it work. @tewfik-ghariani , is there a description or writeup anywhere of what I need to do to upgrade to 2.0?
Can you please share your work around in detail?
Edit:
I figured it out. Here it is for anyone else trying to do the same. Add this to your network file:
# Prevent this error:
# A definition for option `sourceUri' is not of type `string'. Definition values:
# - In `<unknown-file>':
# {
# name = "nixos-image-20-09-3531-3858fbc08e6-x86-64-linux";
# project = "nixos-cloud";
# }
resources.gceImages.bootstrap = credentials // {
name = "bootstrap";
description = "Override bootstrap since the images in nixpkgs are now in a format incompatible with NixOps 1.7";
sourceUri = "gs://nixos-cloud-images/nixos-image-21.03.git.6bf223c82e0-x86_64-linux.raw.tar.gz";
};
I'm assuming, without much to back it up other than some brief reading that this is due to an incompatibility between the sourceUri for bootstrap images in an existing network and the new nixops code.