Nixops stopped working

I have been playing around with nixops on my Mac for awhile. I have remote builds working, and various small scripts. I’ve been creating machines inside VirtualBox. Today every deploy or destroy gets an error,

error: anonymous function at /Users/johnson/.nix-defexpr/channels/nixpkgs/nixos/lib/testing.nix :1:1 called without required argument ‘pkgs’, at /nix/store/shx6ki82b8vq110q55v0295v1in8yc1j-nixops-1.6/share/nix/nixops/eval-machine-info.nix :9:6

error: evaluation of the deployment specification failed

Any idea what could have happened, and how I could fix it?

Looking through nixops commit history turns up this:

https://github.com/NixOS/nixops/commit/daf78732bc5991504bac8d79f3dd343c17f87663

Not sure if this commit is included in any nixopsUnstable packaged in
nixpkgs, but if not it probably will be shortly-- can someone take care
of this or comment regarding the situation?

Hope this helps, and thanks!

I’ve pushed Fix nixops evaluation · NixOS/nixpkgs@56e12aa · GitHub that should fix the issue - once it hits the channel.

1 Like

I also prepared a new release that would fix the issue: Update release notes. by Mic92 · Pull Request #1050 · NixOS/nixops · GitHub

How long does it take to “hit the channel”? I just did a nix-channel --update and tried to deploy again and got the same error. I don’t remember doing an update the other day, but I suppose I did.

I’m expecting to use nixops to control a large system. There must be some way to make sure that nixops stays reliable, such as testing updates on a test system before deploying them to the production system. I don’t want the tools on my production system to break. Has anybody written about the strategy for this?

1 Like

That problem was introduced in the unstable channel not in the stable channel. Nixops and nixpkgs are independent developed, which makes the testing tricky.
I also bumped nixopsUnstable to 1.6.1pre2706_d5ad09c, which carried the fix. However I cannot issue nixops releases myself.

Channel updates can be monitored here: https://howoldis.herokuapp.com/
When you want to increase the reliability, you probably want to stick to stable releases instead.

1 Like

Yes, I just took the default channel. Once it is fixed I will switch to stable. What is the impact of switching channels? In other words, what would happen if I switch now? Would I fix the problem? Make sure the problem is buried and can never be fixed without reinstalling nix? I’m too new at nix to predict what would happen.

You probably want to use pinning. The channels are a convenience, but pinning gives you the ultimate control over what is running and when to update. In this case it would have enabled you to easily resolve your issue by either upgrading/downgrading/patching your way around the issue.

https://nixos.wiki/wiki/FAQ/Pinning_Nixpkgs

In fact, I pin nixops sperately from nixpkgs because I am developing and relying on features not yet merged into master.

The channel I am on is nixpkgs-unstable. There is no channel nixpkgs that shows in the list of channel updates. Just three nixpkgs channels for Darwin. Is that because stable releases are not handled through channels, but by normal installs? That would make sense. Does that mean that I should uninstall nixops and install the stable version?

Hadn’t read the page on pinning. That makes sense, and I will try it.

Your easiest option may be to only change your nixops rather than the whole system. I’d recommend an overlay focused only on that. It would be something like: (insert the revision and sha256 you need)

self: super: {
  nixops =
     let                 
       nixopsUnstable = self.fetchFromGitHub {                                
         owner = "NixOS";
         repo = "nixops";
         rev = "<REVISION>";                    
         sha256 = "<SHA256_HASH>";     
       };
     in (import "${nixopsUnstable}/release.nix" {}).build.${builtins.currentSystem};
}

I created the file, put in the revision I wanted with the hash of the commit, and then moved the file into ~/config/nix/overlays. The manual seemed to imply that when I did this, the next use of nixops would use the revision I chose. However, I couldn’t see any difference in the system. Is this the right way to enable an overlay, or do you recommend another way?

You will need to reinstall NixOps before that overlays has any effect. I’m not sure what your exact setup is, but another nix-env -iA nixpkgs.nixops. (Or similar) should do the trick.

I have a more or less vanilla installation on a Mac. I’ve been learning nix and nixops with VisualBox.

I tried reinstalling NixOps and it said:
replacing old ‘nixops-1.6’
installing ‘nixops-1.6’
these derivations will be built:
/nix/store/rx27qlrqq0885103vwy1fgg3f7lnq6wz-python2.7-PyJWT-1.6.4.drv
/nix/store/id8bzhmd23ymmib7f97yh2inkgrrh1v9-python2.7-adal-1.2.0.drv
/nix/store/g661qnnm3a6zhyz0g5jr54pdmvsjrkv3-nixops-1.6.drv
these paths will be fetched (173.94 MiB download, 950.72 MiB unpacked):

It then downloaded the paths and started to build PyJWT. It complained about a few things, and a bunch of the tests for PyJWT failed because of warnings for using something deprecated. At the end, the builder for PyJWT failed.

I’m thinking I should erase nix from my machine and reinstall it. Shouldn’t I expect all the prerequisites for nixops-1.6 to be loaded from the store? Does the fact that it is trying to build PyJWT show that something funny is going on?

I deleted nix and reinstalled it. The first thing I tried to install was nixops, and the installation dies the same way that it did when I tried to reinstall nixops over the existing one.

I decided to try to install nix and nixops on another Mac, and it installed it without problems. When it came to python2.7-PyJWT-1.6.4, it loaded it from the store on cache.nixos.org

So, why is it trying to build it on my first Mac instead of loading it from the cache?

I remembered I had written an overlay. Sure enough, it was still there. I removed it from the overlays directory but nixops still wouldn’t load. So, I removed nix, reinstalled it, and then could install nixops!

But nixops still doesn’t work. I get the same error that testing.nix is called without the required argument ‘pkgs’.

When you install nix, it automatically comes up with the nixpkgs channel installed, which depends on the nixpkgs-unstable channel. If I remove that channel, I cannot load anything from nixpkgs, including nixops. Hmm. So, how do I avoid the bad update to the nixpkgs channel? Pinning? Overlays?

I was putting the overlay in the wrong file at first, then I realized the sha256 hash was wrong. Now I am using the following.

self: super: {
  nixops =
     let                 
       nixopsUnstable = self.fetchFromGitHub {                                
         owner = "NixOS";
         repo = "nixops";
         rev = "v1.6";
         sha256 = "0nfw05l3z2vdz2k4mj7qp3sfvpph7gss2qriabm92fi357i31643";     
       };
     in (import "${nixopsUnstable}/release.nix" {}).build.${builtins.currentSystem};
}

When I first put this into the right place (~/.config/nixpkgs/overlays) I was able to install nixops and docker and was even able to deploy a simple system into VisualBox. Success! I was surprised to see that docker started up my old container for remote building, showing that something was a holdover from when I removed nix. But then I had to reboot my Mac, and when it came back up docker didn’t work. So, I removed nix once again and started over. But this time I can’t install nixops. Or docker. In fact, even a “nixops -qa” will result in an error.

The error is
error: cannot import ‘/nix/store/w484gxhpicpclrgw5hr4by47w657bb3z-source/release.nix’, since path ‘/nix/store/jdrcgvvyya1i8lj3da51b4zfjzjwmpz3-source.drv’ is not valid, at /Users/johnson/.config/nixpkgs/overlays/fix-nixops.nix :10:10

There is no file in /nix/store corresponding to either of these. Very mysterious.

The thing that bothers me the most is that removing /nix does NOT seem to completely undo nix, in spite of what the manual says.