Skip to content

nixos: fix setups where users.users.<id>.name is not <id>#306

Open
taliyahwebb wants to merge 1 commit intonix-community:masterfrom
taliyahwebb:master
Open

nixos: fix setups where users.users.<id>.name is not <id>#306
taliyahwebb wants to merge 1 commit intonix-community:masterfrom
taliyahwebb:master

Conversation

@taliyahwebb
Copy link

TL;DR

This PR is pretty similar to #252 but achives a few extra goals.

  • evaluated which "name" should be used where (more on that in # Description)
  • documents the behavior around names in the option descriptions
  • properly tested all apparent cases (see feature matrix in # Testing)

It is properly tested, test cases and results see below.

In Depth

Description

Guideline for which "name" should be used where

  • the name as in the module (users.users.<name>) for nixos whenever its a submodule name
  • the name as in the final linux system (users.users.<user>.name) whenever it's a .name option
  • since groups are only ever set as .group those are always final group names and never resolved from users.groups.<group>.name

Testing

I have tested and verified the following cases:

  • "same" = where: users.users.<user>.name == "<user>"
  • "diff" = where: users.users.<user>.name != "<user>" (in this case I assume home-manager.users.<user>.home.username == users.users.<user>.name if not that's prob wrong in of it self)

Support Matrix Before PR

same diff case description
environment.persistence dirs without explicit user config (1)
environment.persistence dirs with explicit user config (2)
❌ (runtime, dir is owned by root instead) environment.persistence.users.<user> dirs without explicit user config (3)
❌ (eval error, cant find associated group when making homedir) environment.persistence.users.<user> dirs with explicit user config (4)
❌ (eval error, cant find associated group when making homedir) home.persistence dirs without explicit user config (5)
❌ (eval error, cant find associated group when making homedir) home.persistence dirs with explicit user config (6)
❌ (eval error, cant find associated group when making homedir) explicit group (only one case since this was barely touched) (7)

Support Matrix After PR

same diff case description
environment.persistence dirs without explicit user config (1)
environment.persistence dirs with explicit user config (2)
environment.persistence.users.<user> dirs without explicit user config (3)
environment.persistence.users.<user> dirs with explicit user config (4)
home.persistence dirs without explicit user config (5)
home.persistence dirs with explicit user config (6)
explicit group (7)

Numbered Test Cases

In the diff cases this was used

 users.users.someuser.name = "otheruser";

In the tests the permissions of dirs and parent dirs was verified to be ok

1

environment.persistence."/persistence" = {
  directories = [
    "/var/lib/nixos"
  ];
};

2

environment.persistence."/persistence" = {
  directories = [
    { directory = "/data"; user = config.users.users.someuser.name; }
  ];
};

3

environment.persistence."/persistence" = {
  users.someuser = {
    directories = [
      "data"
    ];
  };
};

4

environment.persistence."/persistence" = {
  users.someuser = {
    directories = [
      { directory = "data"; user = config.users.users.someuser.name; }
    ];
  };
};

5

home.persistence."/persistence" = {
    directories = [
      "data"
    ];
};

6

home.persistence."/persistence" = {
    directories = [
      { directory = "data"; user = config.users.users.someuser.name; }
    ];
};

7

home.persistence."/persistence" = {
    directories = [
      { directory = "data"; user = config.users.users.someuser.name; group = "wheel"; }
    ];
};

also adds wording to the toplevel option descriptions which "name" should be used where
- the name as in the module for nixos whenever its a submodule name
- the name as in the final linux system whenever it's a .name option
- since groups are only ever set as .group those are always final group names and never resolved from `users.groups.<group>.name`
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.

1 participant