nixcloud/nixcloud-webservices

porting from 20.03 to 20.09: '_module' missing

Opened this issue · 3 comments

Using nixcloud-webservices nixpkgs-20.03 and porting on nixpkgs for tags/20.09 the first commit in the bisect which fails is:

commit dcdd232939232d04c1132b4cc242dd3dac44be8c
Refs: [HEAD], 18.09-beta-65536-gdcdd23293923
Author:     Silvan Mosberger <contact@infinisil.com>
AuthorDate: Mon Mar 16 21:05:52 2020 +0100
Commit:     Silvan Mosberger <contact@infinisil.com>
CommitDate: Tue Mar 17 19:19:39 2020 +0100

    lib/modules: Remove internal _module attribute from config

    The _module option is added as an internal option set, and it messes up
    the results of module evaluations, requiring people to manually filter
    _modules out.

    If people depend on this, they can still use config._module from inside
    the modules, exposing _module as an explicitly declared user option. Or
    alternatively with the _module attribute now returned by evalModules.
---
 lib/modules.nix | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

error message nixos-rebuild build ...

while evaluating 'mkDict' at /etc/nixos/nixcloud-webservices/modules/core/dbshell/default.nix:6:14, called from /etc/nixos/nixcloud-webservices/modules/core/dbshell/default.nix:13:37:
while evaluating anonymous function at /etc/nixos/nixpkgs/lib/attrsets.nix:234:10, called from undefined position:
while evaluating 'mkEntry' at /etc/nixos/nixcloud-webservices/modules/core/dbshell/default.nix:7:22, called from /etc/nixos/nixpkgs/lib/attrsets.nix:234:16:
while evaluating 'toPython' at /etc/nixos/nixcloud-webservices/modules/core/dbshell/default.nix:4:14, called from /etc/nixos/nixcloud-webservices/modules/core/dbshell/default.nix:7:44:
while evaluating the attribute 'user' at /etc/nixos/nixcloud-webservices/modules/core/dbshell/default.nix:24:9:
attribute '_module' missing, at /etc/nixos/nixcloud-webservices/modules/core/dbshell/default.nix:24:16

commits between broken commit and 20.09

root@mail /e/n/nixpkgs# git log dcdd232939232d04c1132b4cc242dd3dac44be8c..cd63096d6d88 --oneline | cut -d " " -f 1 | wc
  27120   27120  352560

NixOS/nixpkgs@dcdd232

This line causing this error message is:

user = cfg._module.args.mkUniqueUser dbcfg.user;

And is gone once I hack it into:

    #user = cfg._module.args.mkUniqueUser dbcfg.user;
    user = dbcfg.user;

dbcfg.user is mattermost
cfg._module.args.mkUniqueUser dbcfg.user is mattermost-ncchat

mkUniqueUser is injected from base.nix:

    config = lib.mkMerge [
    { _module.args.mkUnique = suffix:
        if lib.hasPrefix config.uniqueName suffix then suffix
        else if isHashed suffix then suffix
        else if suffix == wsName then config.uniqueName
        else "${config.uniqueName}-${suffix}";

      _module.args.mkUniqueUser = mkUniqueUserGroup "user";
      _module.args.mkUniqueGroup = mkUniqueUserGroup "group";

I've added a quick fix but this needs some more thinking and also some test to check if the generated https://github.com/nixcloud/nixcloud-webservices/blob/master/documentation/nixcloud.webservices.md#database-abstraction-for-userdb-creation is working