Skip to content

modules/common/user: refer to users.‹username›.name as the username#126

Open
GetPsyched wants to merge 1 commit intofeel-co:mainfrom
GetPsyched:custom-username
Open

modules/common/user: refer to users.‹username›.name as the username#126
GetPsyched wants to merge 1 commit intofeel-co:mainfrom
GetPsyched:custom-username

Conversation

@GetPsyched
Copy link
Copy Markdown
Contributor

Hjem assumes that username in hjem.users.‹username› is the actual username of the user, which is true in most cases, except when users.users.‹name›.name is set to a different value.

This causes hjem-activate@ to fail because it tries to determine the user based on attrNames hjem.users.

Oct 26 02:40:38 piglin systemd[1]: Starting Link files for primary from their manifest...
Oct 26 02:40:38 piglin (e_-start)[31313]: hjem-activate@primary.service: Failed to determine user credentials: No such process
Oct 26 02:40:38 piglin (e_-start)[31313]: hjem-activate@primary.service: Failed at step USER spawning /nix/store/9x329kaihmbj82m74q7mb1ra2vadba39-unit-script-hjem-activate_-start/bin/hjem-activate_-start: No such process

This patch adds hjem.users.‹username›.name as a configurable option, and uses users.users.name as its default (nixos and nix-darwin alike).

Note that I don't know if I've covered all of the places where a change should be made, which won't be obvious from the PR diff. Happy to go back and add changes in such places if so.

Sanity Checking

  • My changes fit the guidelines found in CONTRIBUTING guide
  • I have tested, and self-reviewed my code
  • The unit tests for Hjem pass (nix flake check/nix-build -A checks)
  • Style and consistency
    • I formatted all relevant code (nix fmt/nix run -f . formatter)
    • My changes are consistent with the rest of the codebase
    • My commit messages fit the guidelines found in CONTRIBUTING
  • If new changes are particularly complex:
    • My code includes comments in particularly complex areas
    • I have included a section in the documentation
  • Tested on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin

Add a 👍 reaction to pull requests you find important.

};

name = mkOption {
default = name;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've set a default here, but also in L98 (modules/nixos/base.nix). Either one of these is probably redundant. What should I do?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm under the impression that L98 in modules/nixos/base.nix is the redundant one, and it's also implicit. Technically, anyway.

However I do not see an issue with keeping both for the sake of consistency.

y0usaf added a commit to y0usaf/bayt that referenced this pull request Mar 26, 2026
Add `bayt.users.‹key›.name` option that defaults to `users.users.‹key›.name`,
allowing the attrset key to differ from the actual username.

Fixes activation failures when users set a custom name in NixOS/darwin.

Ref: feel-co#126
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

Successfully merging this pull request may close these issues.

2 participants