Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixopsUnstable: error: neither flake.nix nor nixops.nix exists in home directory #1474

Closed
Izorkin opened this issue Sep 22, 2021 · 6 comments

Comments

@Izorkin
Copy link

Izorkin commented Sep 22, 2021

Not working nixopsUnstable in master branch.

nixops info --all

error: while evaluating 'zipAttrs' at /nix/store/8cimyj57i2hjnzlhmss09gcqi2aap124-python3-3.9.6-env/lib/python3.9/site-packages/nix/eval-machine-info.nix:17:14, called from /nix/store/8cimyj57i2hjnzlhmss09gcqi2aap124-python3-3.9.6-env/lib/python3.9/site-packages/nix/eval-machine-info.nix:38:13:
while evaluating 'call' at /nix/store/8cimyj57i2hjnzlhmss09gcqi2aap124-python3-3.9.6-env/lib/python3.9/site-packages/nix/eval-machine-info.nix:12:10, called from /nix/store/8cimyj57i2hjnzlhmss09gcqi2aap124-python3-3.9.6-env/lib/python3.9/site-packages/nix/eval-machine-info.nix:36:11:
attribute 'getFlake' missing, at /nix/store/8cimyj57i2hjnzlhmss09gcqi2aap124-python3-3.9.6-env/lib/python3.9/site-packages/nix/eval-machine-info.nix:20:16
error: evaluation of the deployment specification failed

If use nixUnstable this error:

error: attribute 'nixopsConfigurations' missing

       at /nix/store/8cimyj57i2hjnzlhmss09gcqi2aap124-python3-3.9.6-env/lib/python3.9/site-packages/nix/eval-machine-info.nix:20:15:

           19|
           20|   flakeExpr = (builtins.getFlake flakeUri).outputs.nixopsConfigurations.default;
             |               ^
           21|

       … while evaluating the attribute 'outputs.nixopsConfigurations.default'

       at «string»:47:70:

           46|
           47|           result = outputs // sourceInfo // { inherit inputs; inherit outputs; inherit sourceInfo; };
             |                                                                      ^
           48|         in

       … while evaluating 'call'

       at /nix/store/8cimyj57i2hjnzlhmss09gcqi2aap124-python3-3.9.6-env/lib/python3.9/site-packages/nix/eval-machine-info.nix:12:10:

           11| let
           12|   call = x: if builtins.isFunction x then x args else x;
             |          ^
           13|

       … from call site

       at /nix/store/8cimyj57i2hjnzlhmss09gcqi2aap124-python3-3.9.6-env/lib/python3.9/site-packages/nix/eval-machine-info.nix:36:11:

           35|       ++ optional (flakeUri != null)
           36|         ((call flakeExpr) // { _file = "<${flakeUri}>"; });
             |           ^
           37|

       … while evaluating 'zipAttrs'

       at /nix/store/8cimyj57i2hjnzlhmss09gcqi2aap124-python3-3.9.6-env/lib/python3.9/site-packages/nix/eval-machine-info.nix:17:14:

           16|
           17|   zipAttrs = set: builtins.listToAttrs (
             |              ^
           18|     map (name: { inherit name; value = builtins.catAttrs name set; }) (builtins.concatMap builtins.attrNames set));

       … from call site

       at /nix/store/8cimyj57i2hjnzlhmss09gcqi2aap124-python3-3.9.6-env/lib/python3.9/site-packages/nix/eval-machine-info.nix:38:13:

           37|
           38|   network = zipAttrs networks;
             |             ^
           39|
error: evaluation of the deployment specification failed

in latest nixpkgs update:

Traceback (most recent call last):
  File "/nix/store/hy3mym0lgwnwhr6hfvmxwmbjpqhlmb1f-python3.9-nixops-2.0.0/bin/.nixops-wrapped", line 9, in <module>
    sys.exit(main())
  File "/nix/store/h60qfg5j087m127mb8sl617qwfskkl8c-python3-3.9.6-env/lib/python3.9/site-packages/nixops/__main__.py", line 56, in main
    args.op(args)
  File "/nix/store/h60qfg5j087m127mb8sl617qwfskkl8c-python3-3.9.6-env/lib/python3.9/site-packages/nixops/script_defs.py", line 403, in op_info
    with network_state(args) as sf:
  File "/nix/store/dqxic3j7csd4ywn94n4smmnz55p039g3-python3-3.9.6/lib/python3.9/contextlib.py", line 117, in __enter__
    return next(self.gen)
  File "/nix/store/h60qfg5j087m127mb8sl617qwfskkl8c-python3-3.9.6-env/lib/python3.9/site-packages/nixops/script_defs.py", line 98, in network_state
    network = eval_network(get_network_file(args))
  File "/nix/store/h60qfg5j087m127mb8sl617qwfskkl8c-python3-3.9.6-env/lib/python3.9/site-packages/nixops/script_defs.py", line 60, in get_network_file
    raise ValueError(f"Neither flake.nix nor nixops.nix exists in {network_dir}")
ValueError: Neither flake.nix nor nixops.nix exists in /home/user

Metadata

  • system: "x86_64-linux"
  • host os: Linux 5.12.19-hardened1, NixOS, 21.11 (Porcupine)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.3.15
  • channels(root): "nixos-21.11pre306131.39bce8345f3"
  • channels(user): "nixpkgs-2009-20.09beta1346.05334ad7852"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
@Izorkin
Copy link
Author

Izorkin commented Sep 24, 2021

I added nixops.nix file with this content to the home directory:

{
  network.storage.legacy = {
    databasefile = "~/.nixops/deployments.nixops";
  };
}

Nixops started working. If I change the working directory, then nixops stops working again.

How to make nixops always read ~/nixops.nix file?

@onny
Copy link

onny commented Sep 24, 2021

I guess you'll have to rename your main configuration or deployment file to nixops.nix. This is a naming convention introduced in NixOps 2.0 https://nixops.readthedocs.io/en/latest/manual/migrating.html

@Izorkin
Copy link
Author

Izorkin commented Sep 24, 2021

Even after renaming, nixops will look configuration in ./flake.nix.
If I go to the folder with the nixpkgs source files - cd ~/src/nixpkgs, then nixops stops working.
In the current variant, it becomes inconvenient to test changes in nixpkgs by deploying the configuration to a test variational machine using nixops.

@adisbladis
Copy link
Member

You can always explicitly pass the path to your deployment.

This is intended behaviour.

@Izorkin
Copy link
Author

Izorkin commented Sep 24, 2021

And if make such a parameter in the file ~/.config/nixpkgs/config.nix ?

{
  nixopsNetworkDir = "~/works/nixops/example";
}

@Izorkin
Copy link
Author

Izorkin commented Sep 25, 2021

cc @adisbladis
Problem not full resolved.
Next error:

nixops deploy -d works
resource ‘vm01-web’ is obsolete
resource ‘vm02-mail’ is obsolete
resource ‘vm03-tools’ is obsolete
building all machine configurations...
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
works> closures copied successfully
works> deployment finished successfully
nixops deploy -d labs
resource ‘vm11-tech’ is obsolete
building all machine configurations...
warning: you did not specify '--add-root'; the result might be removed by the garbage collector
labs> closures copied successfully
labs> deployment finished successfully
nixops info --all
+------------+------------+---------------+------+--------------------------------------------------------+------------+
| Deployment | Name       |     Status    | Type | Resource Id                                            | IP address |
+------------+------------+---------------+------+--------------------------------------------------------+------------+
| works      | vm01-web   | Up / Outdated | none | nixops-4bef9dae-734f-11eb-94ab-52cff3c67bdb-vm01-web   |            |
| works      | vm02-mail  | Up / Outdated | none | nixops-4bef9dae-734f-11eb-94ab-52cff3c67bdb-vm02-mail  |            |
| works      | vm03-tools | Up / Outdated | none | nixops-4bef9dae-734f-11eb-94ab-52cff3c67bdb-vm03-tools |            |
| labs       | vm11-tech  | Up / Outdated | none | nixops-500ff938-734f-11eb-a56c-52cff3c67bdb-vm11-tech  |            |
+------------+------------+---------------+------+--------------------------------------------------------+------------+

If add to nixops.nix:

  vm01-web = { config, lib, pkgs, ... }: {
    require = [ ./deploy/works/vm01-web/configuration.nix ];

    deployment.targetEnv = "none";
    deployment.targetHost = "192.168.0.201";
    deployment.targetPort = 22;
  };

  vm02-mail = { config, lib, pkgs, ... }: {
    require = [ ./deploy/works/vm02-mail/configuration.nix ];

    deployment.targetEnv = "none";
    deployment.targetHost = "192.168.0.202";
    deployment.targetPort = 22;
  };

  vm03-tools = { config, lib, pkgs, ... }: {
    require = [ ./deploy/works/vm03-tools/configuration.nix ];

    deployment.targetEnv = "none";
    deployment.targetHost = "192.168.0.203";
    deployment.targetPort = 22;
  };

  vm11-tech = { config, lib, pkgs, ... }: {
    require = [ ./deploy/labs/vm11-tech/configuration.nix ];

    deployment.targetEnv = "none";
    deployment.targetHost = "192.168.0.211";
    deployment.targetPort = 22;
  };

an error like this appears:

nixops info --all
+------------+------------+--------------+------+--------------------------------------------------------+------------+
| Deployment | Name       |    Status    | Type | Resource Id                                            | IP address |
+------------+------------+--------------+------+--------------------------------------------------------+------------+
| works      | vm01-web   | Up / Revived | none | nixops-4bef9dae-734f-11eb-94ab-52cff3c67bdb-vm01-web   |            |
| works      | vm02-mail  | Up / Revived | none | nixops-4bef9dae-734f-11eb-94ab-52cff3c67bdb-vm02-mail  |            |
| works      | vm03-tools | Up / Revived | none | nixops-4bef9dae-734f-11eb-94ab-52cff3c67bdb-vm03-tools |            |
| works      | vm11-tech  |   Missing    | none |                                                        |            |
| labs       | vm01-web   |   Missing    | none |                                                        |            |
| labs       | vm02-mail  |   Missing    | none |                                                        |            |
| labs       | vm03-tools |   Missing    | none |                                                        |            |
| labs       | vm11-tech  | Up / Revived | none | nixops-500ff938-734f-11eb-a56c-52cff3c67bdb-vm11-tech  |            |
+------------+------------+--------------+------+--------------------------------------------------------+------------+
nixops deploy -d works
resource ‘vm01-web’ is no longer obsolete
resource ‘vm02-mail’ is no longer obsolete
resource ‘vm03-tools’ is no longer obsolete
vm11-tech.> generating new SSH key pair... done
vm11-tech.> setting state version to 21.11
vm11-tech.> waiting for SSH...
building all machine configurations...
nixops deploy -d labs
vm01-web..> generating new SSH key pair...
vm02-mail.> generating new SSH key pair...
vm03-tools> generating new SSH key pair...
vm01-web..> done
vm02-mail.> done
vm03-tools> done
vm02-mail.> setting state version to 21.11
vm02-mail.> waiting for SSH...
vm01-web..> setting state version to 21.11
vm01-web..> waiting for SSH...
vm03-tools> setting state version to 21.11
vm03-tools> waiting for SSH...
building all machine configurations...

nixops is not working correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants