pinpox / lollypops

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

Clashing declarations of `lollypops.secrets.files` in basic usage #13

Closed cmacrae closed 1 year ago

cmacrae commented 1 year ago

Hey @pinpox 👋

Trying out Lollypops by following the README results in the output at the bottom for me.

Here's the relevant part of my flake:

{
  inputs = {
    nixpkgs.url = github:nixos/nixpkgs/nixpkgs-unstable;
    home-manager.url = github:nix-community/home-manager;
    lollypops.url = github:pinpox/lollypops;

    home-manager.inputs.nixpkgs.follows = "nixpkgs";
    lollypops.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs = { self, nixpkgs, home-manager, lollypops, ... }@inputs:

    let
      commonLinuxConfig = [
        ./modules/common.nix
        home-manager.nixosModules.home-manager
        lollypops.nixosModules.lollypops
        lollypops.hmModule
        { lollypops.secrets.cmd-name-prefix = "Tech/nix-secrets/"; }
      ];

    in
    {
      nixosConfigurations.net1 = nixpkgs.lib.nixosSystem {
        system = "aarch64-linux";
        modules = commonLinuxConfig ++ [
          ./modules/net1.nix

          {
            lollypops.secrets = {
              files = {
                "net1/wireguard-privatekey" = { };
                "net1/acme-dnsimple-envfile" = { };
              };
            };
          }
        ];
      };

      apps."x86_64-darwin".default = lollypops.apps."x86_64-darwin".default { configFlake = self; };
    };
}
$ nix run '.' --show-trace -- --list-all

error: The option `lollypops.secrets.files' in `/nix/store/1zzy0v6laha6r67l0n3wqkgqiwvvj7hv-source/flake.nix' is already declared in `/nix/store/1zzy0v6laha6r67l0n3wqkgqiwvvj7hv-source/flake.nix'.

       … while calling anonymous lambda

       at /nix/store/1zzy0v6laha6r67l0n3wqkgqiwvvj7hv-source/lib/modules.nix:663:18:

          662|    loc: opts:
          663|     foldl' (res: opt:
             |                  ^
          664|       let t  = res.type;

       … from call site

       at /nix/store/1zzy0v6laha6r67l0n3wqkgqiwvvj7hv-source/lib/modules.nix:663:5:

          662|    loc: opts:
          663|     foldl' (res: opt:
             |     ^
          664|       let t  = res.type;

       … while calling 'mergeOptionDecls'

       at /nix/store/1zzy0v6laha6r67l0n3wqkgqiwvvj7hv-source/lib/modules.nix:662:9:

          661|   mergeOptionDecls =
          662|    loc: opts:
             |         ^
          663|     foldl' (res: opt:

       … from call site

       at /nix/store/1zzy0v6laha6r67l0n3wqkgqiwvvj7hv-source/lib/modules.nix:591:44:

          590|           if length optionDecls == length decls then
          591|             let opt = fixupOptionType loc (mergeOptionDecls loc decls);
             |                                            ^
          592|             in {

       … while calling 'fixupOptionType'

       at /nix/store/1zzy0v6laha6r67l0n3wqkgqiwvvj7hv-source/lib/modules.nix:871:26:

          870|   # TODO: Merge this into mergeOptionDecls
          871|   fixupOptionType = loc: opt:
             |                          ^
          872|     if opt.type.getSubModules or null == null

       … from call site

       at /nix/store/1zzy0v6laha6r67l0n3wqkgqiwvvj7hv-source/lib/modules.nix:591:23:

          590|           if length optionDecls == length decls then
          591|             let opt = fixupOptionType loc (mergeOptionDecls loc decls);
             |                       ^
          592|             in {

       … while calling 'warnIf'

       at /nix/store/1zzy0v6laha6r67l0n3wqkgqiwvvj7hv-source/lib/trivial.nix:357:18:

          356|   */
          357|   warnIf = cond: msg: if cond then warn msg else x: x;
             |                  ^
          358|

       … from call site

       at /nix/store/1zzy0v6laha6r67l0n3wqkgqiwvvj7hv-source/lib/modules.nix:719:9:

          718|       warnDeprecation =
          719|         warnIf (opt.type.deprecationMessage != null)
             |         ^
          720|           "The type `types.${opt.type.name}' of option `${showOption loc}' defined in ${showFiles opt.declarations} is deprecated. ${opt.type.deprecationMessage}";

       … while calling 'evalOptionValue'

       at /nix/store/1zzy0v6laha6r67l0n3wqkgqiwvvj7hv-source/lib/modules.nix:694:31:

          693|      config value. */
          694|   evalOptionValue = loc: opt: defs:
             |                               ^
          695|     let

       … from call site

       at /nix/store/1zzy0v6laha6r67l0n3wqkgqiwvvj7hv-source/lib/modules.nix:593:32:

          592|             in {
          593|               matchedOptions = evalOptionValue loc opt defns';
             |                                ^
          594|               unmatchedDefns = [];

       … while evaluating the attribute 'matchedOptions'

       at /nix/store/1zzy0v6laha6r67l0n3wqkgqiwvvj7hv-source/lib/modules.nix:593:15:

          592|             in {
          593|               matchedOptions = evalOptionValue loc opt defns';
             |               ^
          594|               unmatchedDefns = [];

       … while calling anonymous lambda

       at /nix/store/1zzy0v6laha6r67l0n3wqkgqiwvvj7hv-source/lib/modules.nix:623:37:

          622|
          623|       matchedOptions = mapAttrs (n: v: v.matchedOptions) resultsByName;
             |                                     ^
          624|

       … from call site

       … while calling 'g'

       at /nix/store/1zzy0v6laha6r67l0n3wqkgqiwvvj7hv-source/lib/attrsets.nix:529:19:

          528|           g =
          529|             name: value:
             |                   ^
          530|             if isAttrs value && cond value

       … from call site

       … while calling 'flatten'

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

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

       … from call site

       at /nix/store/4j85s6wjcip9fncm3n47j44gj31wrwn1-source/flake.nix:58:35:

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

       … while calling 'mkSeclist'

       at /nix/store/4j85s6wjcip9fncm3n47j44gj31wrwn1-source/flake.nix:58:27:

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

       … from call site

       at /nix/store/4j85s6wjcip9fncm3n47j44gj31wrwn1-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/v3h6hhxf4f5l5ix3p70jap046zl2plm1-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/v3h6hhxf4f5l5ix3p70jap046zl2plm1-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/v3h6hhxf4f5l5ix3p70jap046zl2plm1-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

Hey :wave:

You have imported the hmModule as nixos module instead of importing it as home-manager module. The hmModule should go in the imports of your home-manager configuration (home-manager.users.your-username)

  home-manager.users.your-username = {
    /* Here goes your home-manager config, eg home.packages = [ pkgs.foo ]; */
    imports = [ lollypops.hmModule ];
  };
cmacrae commented 1 year ago

You're right! 🤦 Thanks for clarifying 👍