Skip to content

nixos/continuwuity: no way to use DynamicUser #427025

Description

@sodiboo

Nixpkgs version

  • Unstable (25.11)

Describe the bug

The continuwuity module has this snippet:

DynamicUser = true;
User = cfg.user;
Group = cfg.group;

That's all good; it will allocate a dynamic user and try to give it the configured name (instead of a random/default one). Unless the user already exists.

It also creates the user by default:

users.users = lib.mkIf (cfg.user == defaultUser) {
${defaultUser} = {
group = cfg.group;
home = cfg.settings.global.database_path;
isSystemUser = true;
};
};
users.groups = lib.mkIf (cfg.group == defaultGroup) {
${defaultGroup} = { };
};

This is strange, because it immediately negates the effects of DynamicUser= by default? In particular, the matrix-conduit module never did this, which is the one i've been using and i'm trying to upgrade from.

But i guess i can just give it a garbage name and group, which isn't allocated? Then i get DynamicUser=? Well, no, because it also asserts that the user is statically allocated:

{
assertion = cfg.user != defaultUser -> config ? users.users.${cfg.user};
message = "If `services.continuwuity.user` is changed, the configured user must already exist.";
}
{
assertion = cfg.group != defaultGroup -> config ? users.groups.${cfg.group};
message = "If `services.continuwuity.group` is changed, the configured group must already exist.";
}

So there is literally no way to make it use a dynamic user. ????? . Why is it configuring DynamicUser = true?

I would normally just open a PR to fix this, but i'm actually not sure how best to do that. If i was reviewing the original PR, i would have said to remove the assertions that the user is statically allocated, as well as not statically allocating the default user either. But i don't think just removing that is necessarily backwards-compatible now? Some care has to be taken.

Additional context

https://www.freedesktop.org/software/systemd/man/latest/systemd.exec.html#DynamicUser=

If a statically allocated user or group of the configured name already exists, it is used and no dynamic user/group is allocated.

System metadata

  • system: "x86_64-linux"
  • host os: Linux 6.12.34, NixOS, 25.11 (Xantusia), 25.11.20250708.9807714
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.28.4
  • channels(root): "nixos"
  • channels(sodiboo): ""
  • nixpkgs: /nix/store/bgl6ldj5ihbwcq8p42z3a0qzgqafgk2b-source

Notify maintainers

@nyabinary @snaakey


Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)

I assert that this issue is relevant for Nixpkgs

Is this issue important to you?

Add a 👍 reaction to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: nixosIssues or PRs affecting NixOS modules, or package usability issues specific to NixOS

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions