pinpox / lollypops

Lollypop Operations - NixOS Deployment Tool
https://pinpox.github.io/lollypops/
GNU General Public License v3.0
118 stars 17 forks source link

Basic example doesn't seem to work #11

Closed pf56 closed 1 year ago

pf56 commented 1 year ago

I can't get the basic example from the readme to work. Adding it to my flake.nix returns error: attribute 'lollypops' missing.

I tried to narrow it down by removing my other nixosConfigurations and packages, but then it complained about home-manager being missing.

Any idea whats going on?

➜ nix run '.' --show-trace -- --list-all
error: attribute 'lollypops' missing

       at /nix/store/gqjhbn5vwaj3izsvap015wpkihkb7ij7-source/flake.nix:74:38:

           73|                 ])
           74|                 (builtins.attrValues config.lollypops.secrets.files));
             |                                      ^
           75|

       … while evaluating 'flatten'

       at /nix/store/dk1bqlz87dzsd8g4fq92pscgd60ji2vr-source/lib/lists.nix:138:13:

          137|   */
          138|   flatten = x:
             |             ^
          139|     if isList x

       … from call site

       at /nix/store/gqjhbn5vwaj3izsvap015wpkihkb7ij7-source/flake.nix:58:35:

           57|
           58|               mkSeclist = config: pkgs.lib.lists.flatten (map
             |                                   ^
           59|                 (x: [

       … while evaluating 'mkSeclist'

       at /nix/store/gqjhbn5vwaj3izsvap015wpkihkb7ij7-source/flake.nix:58:27:

           57|
           58|               mkSeclist = config: pkgs.lib.lists.flatten (map
             |                           ^
           59|                 (x: [

       … from call site

       at /nix/store/gqjhbn5vwaj3izsvap015wpkihkb7ij7-source/flake.nix:111:30:

          110|                           ]
          111|                           ++ mkSeclist hostConfig.config
             |                              ^
          112|                           ++ mkSeclistUser hostConfig.config.home-manager.users;

       … while evaluating the attribute 'text' of the derivation 'CommonTasks.yml'

       at /nix/store/dk1bqlz87dzsd8g4fq92pscgd60ji2vr-source/pkgs/stdenv/generic/make-derivation.nix:270:7:

          269|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          270|       name =
             |       ^
          271|         let

       … while evaluating the attribute 'text' of the derivation 'Taskfile.yml'

       at /nix/store/dk1bqlz87dzsd8g4fq92pscgd60ji2vr-source/pkgs/stdenv/generic/make-derivation.nix:270:7:

          269|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          270|       name =
             |       ^
          271|         let

       … while evaluating the attribute 'text' of the derivation 'go-task-runner'

       at /nix/store/dk1bqlz87dzsd8g4fq92pscgd60ji2vr-source/pkgs/stdenv/generic/make-derivation.nix:270:7:

          269|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          270|       name =
             |       ^
          271|         let

With the other nixosConfigurations and packages removed:

➜ nix run '.' --show-trace -- --list-all
error: attribute 'home-manager' missing

       at /nix/store/gqjhbn5vwaj3izsvap015wpkihkb7ij7-source/flake.nix:112:44:

          111|                           ++ mkSeclist hostConfig.config
          112|                           ++ mkSeclistUser hostConfig.config.home-manager.users;
             |                                            ^
          113|                         };

       … while evaluating the attribute 'config.home-manager.users'

       at /nix/store/0ljv28gdwhlfm9629qaxg95g04jzcf9j-source/lib/modules.nix:341:9:

          340|         options = checked options;
          341|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          342|         _module = checked (config._module);

       … while evaluating 'flatten'

       at /nix/store/dk1bqlz87dzsd8g4fq92pscgd60ji2vr-source/lib/lists.nix:138:13:

          137|   */
          138|   flatten = x:
             |             ^
          139|     if isList x

       … from call site

       at /nix/store/gqjhbn5vwaj3izsvap015wpkihkb7ij7-source/flake.nix:32:42:

           31|               # Build steps for all secrets of all users
           32|               mkSeclistUser = homeUsers: pkgs.lib.lists.flatten (builtins.attrValues (builtins.mapAttrs
             |                                          ^
           33|                 (user: userconfig: [

       … while evaluating 'mkSeclistUser'

       at /nix/store/gqjhbn5vwaj3izsvap015wpkihkb7ij7-source/flake.nix:32:31:

           31|               # Build steps for all secrets of all users
           32|               mkSeclistUser = homeUsers: pkgs.lib.lists.flatten (builtins.attrValues (builtins.mapAttrs
             |                               ^
           33|                 (user: userconfig: [

       … from call site

       at /nix/store/gqjhbn5vwaj3izsvap015wpkihkb7ij7-source/flake.nix:112:30:

          111|                           ++ mkSeclist hostConfig.config
          112|                           ++ mkSeclistUser hostConfig.config.home-manager.users;
             |                              ^
          113|                         };

       … while evaluating the attribute 'text' of the derivation 'CommonTasks.yml'

       at /nix/store/dk1bqlz87dzsd8g4fq92pscgd60ji2vr-source/pkgs/stdenv/generic/make-derivation.nix:270:7:

          269|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          270|       name =
             |       ^
          271|         let

       … while evaluating the attribute 'text' of the derivation 'Taskfile.yml'

       at /nix/store/dk1bqlz87dzsd8g4fq92pscgd60ji2vr-source/pkgs/stdenv/generic/make-derivation.nix:270:7:

          269|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          270|       name =
             |       ^
          271|         let

       … while evaluating the attribute 'text' of the derivation 'go-task-runner'

       at /nix/store/dk1bqlz87dzsd8g4fq92pscgd60ji2vr-source/pkgs/stdenv/generic/make-derivation.nix:270:7:

          269|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          270|       name =
             |       ^
          271|         let
rcorrear commented 1 year ago

Getting the same behavior here.

pinpox commented 1 year ago

Adding it to my flake.nix returns error: attribute 'lollypops' missing.

This means it tried to find lollypops in one of your nixosConfigurations but could not find it. That is expected because you have only imported it here but it is missing in the other ones. You can either import it in all of them or you have to change the configFlake = self here so you only pass the ones that have it imported.

For example this should work to only pass the one nixosConfigration where you have it imported:

{
    apps."x86_64-linux".default = lollypops.apps."x86_64-linux".default { 
      configFlake = {
        nixosConfigurations.nomadserver-01 = self.nixosConfigurations.nomadserver-01; 
      };
    };
}

As for the second error (missing home-manager) I see where this is coming from: It is expecting home-manager to be present in the configuration and not finding it. This is a bug, I'll add a check to only try to get it when it exists.

pinpox commented 1 year ago

If added a check, let me know if it works now

pf56 commented 1 year ago

Thanks for the quick response. I shuffled some code around and could get it working.

I want to point out that importing lollypops.hmModule was necessary for me. Without it, it would fail with the error message below. The docs make it seem like it's supposed to be optional, so I'm not sure if this is intended.

For reference: These are the two changesets I needed to set up lollypops (one two).

➜ nix run '.' --show-trace -- --list-all
error: attribute 'lollypops' missing

       at /nix/store/y6cpf5dxqn9f8vckrq9sxkmqqlifi0vy-source/flake.nix:53:21:

           52|                     ])
           53|                     userconfig.lollypops.secrets.files))
             |                     ^
           54|

       … while evaluating 'flatten'

       at /nix/store/0b1s6l5i9izifskg8kgc29jn5bzgdjnv-source/lib/lists.nix:138:13:

          137|   */
          138|   flatten = x:
             |             ^
          139|     if isList x

       … from call site

       at /nix/store/0b1s6l5i9izifskg8kgc29jn5bzgdjnv-source/lib/lists.nix:140:24:

          139|     if isList x
          140|     then concatMap (y: flatten y) x
             |                        ^
          141|     else [x];

       … while evaluating anonymous lambda

       at /nix/store/0b1s6l5i9izifskg8kgc29jn5bzgdjnv-source/lib/lists.nix:140:21:

          139|     if isList x
          140|     then concatMap (y: flatten y) x
             |                     ^
          141|     else [x];

       … from call site

       at /nix/store/0b1s6l5i9izifskg8kgc29jn5bzgdjnv-source/lib/lists.nix:140:10:

          139|     if isList x
          140|     then concatMap (y: flatten y) x
             |          ^
          141|     else [x];

       … while evaluating 'flatten'

       at /nix/store/0b1s6l5i9izifskg8kgc29jn5bzgdjnv-source/lib/lists.nix:138:13:

          137|   */
          138|   flatten = x:
             |             ^
          139|     if isList x

       … from call site

       at /nix/store/0b1s6l5i9izifskg8kgc29jn5bzgdjnv-source/lib/lists.nix:140:24:

          139|     if isList x
          140|     then concatMap (y: flatten y) x
             |                        ^
          141|     else [x];

       … while evaluating anonymous lambda

       at /nix/store/0b1s6l5i9izifskg8kgc29jn5bzgdjnv-source/lib/lists.nix:140:21:

          139|     if isList x
          140|     then concatMap (y: flatten y) x
             |                     ^
          141|     else [x];

       … from call site

       at /nix/store/0b1s6l5i9izifskg8kgc29jn5bzgdjnv-source/lib/lists.nix:140:10:

          139|     if isList x
          140|     then concatMap (y: flatten y) x
             |          ^
          141|     else [x];

       … while evaluating 'flatten'

       at /nix/store/0b1s6l5i9izifskg8kgc29jn5bzgdjnv-source/lib/lists.nix:138:13:

          137|   */
          138|   flatten = x:
             |             ^
          139|     if isList x

       … from call site

       at /nix/store/y6cpf5dxqn9f8vckrq9sxkmqqlifi0vy-source/flake.nix:32:42:

           31|               # Build steps for all secrets of all users
           32|               mkSeclistUser = homeUsers: pkgs.lib.lists.flatten (builtins.attrValues (builtins.mapAttrs
             |                                          ^
           33|                 (user: userconfig: [

       … while evaluating 'mkSeclistUser'

       at /nix/store/y6cpf5dxqn9f8vckrq9sxkmqqlifi0vy-source/flake.nix:32:31:

           31|               # Build steps for all secrets of all users
           32|               mkSeclistUser = homeUsers: pkgs.lib.lists.flatten (builtins.attrValues (builtins.mapAttrs
             |                               ^
           33|                 (user: userconfig: [

       … from call site

       at /nix/store/y6cpf5dxqn9f8vckrq9sxkmqqlifi0vy-source/flake.nix:113:29:

          112|                           ++ (if builtins.hasAttr "home-manager" hostConfig.config then
          113|                             mkSeclistUser hostConfig.config.home-manager.users else [ ]);
             |                             ^
          114|                         };

       … while evaluating the attribute 'text' of the derivation 'CommonTasks.yml'

       at /nix/store/0b1s6l5i9izifskg8kgc29jn5bzgdjnv-source/pkgs/stdenv/generic/make-derivation.nix:270:7:

          269|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          270|       name =
             |       ^
          271|         let

       … while evaluating the attribute 'text' of the derivation 'Taskfile.yml'

       at /nix/store/0b1s6l5i9izifskg8kgc29jn5bzgdjnv-source/pkgs/stdenv/generic/make-derivation.nix:270:7:

          269|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          270|       name =
             |       ^
          271|         let

       … while evaluating the attribute 'text' of the derivation 'go-task-runner'

       at /nix/store/0b1s6l5i9izifskg8kgc29jn5bzgdjnv-source/pkgs/stdenv/generic/make-derivation.nix:270:7:

          269|     // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
          270|       name =
             |       ^
          271|         let
pinpox commented 1 year ago

I think I see what I missed here. I'm checking only if home-manager exists in the system, but not if the hmModule of lollypops is imported. Thanks for reporting, Looking into it!

pinpox commented 1 year ago

@pf56 Should be fixed by 4a211f494721dba036c9ce8f9c505683f58de95b

We now check for home-manager and hmModule. The use of the module should be optional that way.