Need help with nixops

Hi,

I am trying to learn nixops. But when I try to do deploy a configuration via the nixops deploy -d my-other-machine, it throws an error that the cat command is not found on the machine where I am deploying to. I checked it on the machine and it was installed there. I am stuck and can someone help me on this one?

Thanks

1 Like

Could you post your configuration and complete output?

backend-configuration.nix

{
  my-other-machine =
    { config, pkgs, ... }:
    {
      deployment.targetEnv = "none";
      deployment.targetHost = "192.168.1.114";
    };
}

configuration.nix

{
  network.description = "My Other Machine";

  my-other-machine =
    { config, pkgs, ... }:

    {
      imports = [
        ../../common.nix
        ../../common-graphical.nix
      ];

      boot.loader.grub.device = "/dev/sda";
      networking.hostName = "my-other-machine";
    };
}

output of nixops deploy -d my-other-machine

Enter passphrase for key '/home/macalimlim/.ssh/my-key': 
my-other-machine> zsh:1: command not found: cat
Traceback (most recent call last):
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/bin/..nixops-wrapped-wrapped", line 991, in <module>
    args.op()
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/bin/..nixops-wrapped-wrapped", line 412, in op_deploy
    max_concurrent_activate=args.max_concurrent_activate)
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/lib/python2.7/site-packages/nixops/deployment.py", line 1063, in deploy
    self.run_with_notify('deploy', lambda: self._deploy(**kwargs))
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/lib/python2.7/site-packages/nixops/deployment.py", line 1052, in run_with_notify
    f()
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/lib/python2.7/site-packages/nixops/deployment.py", line 1063, in <lambda>
    self.run_with_notify('deploy', lambda: self._deploy(**kwargs))
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/lib/python2.7/site-packages/nixops/deployment.py", line 996, in _deploy
    nixops.parallel.run_tasks(nr_workers=-1, tasks=self.active_resources.itervalues(), worker_fun=worker)
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/lib/python2.7/site-packages/nixops/parallel.py", line 44, in thread_fun
    result_queue.put((worker_fun(t), None, t.name))
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/lib/python2.7/site-packages/nixops/deployment.py", line 979, in worker
    os_release = r.run_command("cat /etc/os-release", capture_stdout=True)
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/lib/python2.7/site-packages/nixops/backends/__init__.py", line 337, in run_command
    return self.ssh.run_command(command, self.get_ssh_flags(), **kwargs)
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/lib/python2.7/site-packages/nixops/ssh_util.py", line 291, in run_command
    raise SSHCommandFailed(exc.message, exc.exitcode)
nixops.ssh_util.SSHCommandFailed: command ā€˜['ssh', '-oControlPath=/tmp/nixops-ssh-tmpaeVBE8/master-socket', '-p', '22', '-p', '22', '-x', 'root@192.168.1.114', '--', 'cat /etc/os-release']ā€™ failed on machine ā€˜dell-latitude-e6400ā€™ (exit code 127)

I can ssh into the other machine by
ssh root@192.168.1.114
but if I do this
ssh root@192.168.1.114 -- cat /etc/os-release
it will result in the same errorā€¦

Iā€™d check your zshrc and other startup/login scripts to see if path is being altered in any way.

@tomberek Hmmm you maybe right, somehow my configuration
users.defaultUserShell = pkgs.zsh;
is messing up with the deployment

I removed it and the deployment continued until it threw another error againā€¦

Traceback (most recent call last):
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/bin/..nixops-wrapped-wrapped", line 991, in <module>
    args.op()
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/bin/..nixops-wrapped-wrapped", line 412, in op_deploy
    max_concurrent_activate=args.max_concurrent_activate)
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/lib/python2.7/site-packages/nixops/deployment.py", line 1063, in deploy
    self.run_with_notify('deploy', lambda: self._deploy(**kwargs))
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/lib/python2.7/site-packages/nixops/deployment.py", line 1052, in run_with_notify
    f()
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/lib/python2.7/site-packages/nixops/deployment.py", line 1063, in <lambda>
    self.run_with_notify('deploy', lambda: self._deploy(**kwargs))
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/lib/python2.7/site-packages/nixops/deployment.py", line 1010, in _deploy
    max_concurrent_copy=max_concurrent_copy)
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/lib/python2.7/site-packages/nixops/deployment.py", line 694, in copy_closures
    tasks=self.active.itervalues(), worker_fun=worker)
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/lib/python2.7/site-packages/nixops/parallel.py", line 44, in thread_fun
    result_queue.put((worker_fun(t), None, t.name))
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/lib/python2.7/site-packages/nixops/deployment.py", line 690, in worker
    m.copy_closure_to(m.new_toplevel)
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/lib/python2.7/site-packages/nixops/backends/__init__.py", line 367, in copy_closure_to
    env=env)
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/lib/python2.7/site-packages/nixops/backends/__init__.py", line 324, in _logged_exec
    return nixops.util.logged_exec(command, self.logger, **kwargs)
  File "/nix/store/53s3m37hs8s7lvqwbqigj7kr65dvg3n4-nixops-1.7/lib/python2.7/site-packages/nixops/util.py", line 152, in logged_exec
    raise CommandFailed(err, res)
nixops.util.CommandFailed: command ā€˜['nix-copy-closure', '--to', 'root@192.168.1.114', u'/nix/store/1ivvk91c9l4n3df5w548nj6f3z8dgi4k-nixos-system-dell-latitude-e6400-19.03.173553.6420e2649fa', '--use-substitutes']ā€™ failed on machine ā€˜dell-latitude-e6400ā€™ (exit code 1)

Is that other machine NixOS?

yes it is NixOS. It was installed using this configurationā€¦

{ config, pkgs, ... }:

{
  imports = [
    ./hardware-configuration.nix
    ./openssh.nix
    ./users.nix
  ];

  # Load bootloader on this device
  boot.loader.grub.device = "/dev/sda";
  # boot.loader.grub.device = "/dev/nvme0n1";

  environment.systemPackages = with pkgs; [
    git
  ];

  # Enable wpa_supplicant
  networking.wireless.enable = true;
}

Can you run that command manually?

Just as an aside, and I could have been doing things ā€œwrongā€, but I had a lacklustre experience with nixops and wireless targets. When using wired Iā€™m a big nixops fan, though.

@tomberek it resulted in the same errorā€¦ :frowning:

@aanderse I tried doing it through a wired connection, it resulted in same errorā€¦ :frowning:

Then itā€™s a Nix problem, not nixops. Try to see why nix-copy-closure fails. Get that error message. Perhaps nix is installed in an odd way, daemon/multi-user/single-user. Permissions on /nix/store. Disk failure? Logs on the remote machine?

maybe i missed something, but from your initial question: the -d deployment_name of nixops specifies the deployment you want to work on. this is the same -d deployment_name you used when you did the nixops create step to create your deployment (since nixops is stateful).
if you want to deploy with nixops only to a single machine, you would use something like nixops deploy -d deployment_name --include my-other-machine.
i think this is documented nicely in the nixops manual and the nixops manpage.

Just to close this thread, The machine which I am deploying to is having a disk error. Its an old laptop (dell latitude e6400) of mine. I have deployed nixos using nixops to another machine and it all went well. Thankyou for all the help :slight_smile: