0

I want to set root's startGid and startUid to the GID and UID of another user. How can I do that without hardcoding them? I've tried several variations on the following:

  users.users = {
    root = {
      subGidRanges = [
        {
          count = 1;
          startGid = users.users.username.group;
        }
      ];
      subUidRanges = [
        {
          count = 1;
          startUid = config.ids.uids.username;
        }
      ];
    };
    username = {
      isNormalUser = true;
    };
  };
0

This seems to work:

  users.users = {
    root = {
      subGidRanges = [
        {
          count = 1;
          startGid = config.ids.gids."${config.users.users.username.group}";
        }
      ];
      subUidRanges = [
        {
          count = 1;
          startUid = config.users.users.username.uid;
        }
      ];
    };
    username = {
      isNormalUser = true;
      uid = 1000;
    };
  };

Strangely, config.users.users.username.group seems to resolve fine even though I've not set it explicitly, but I still had to set config.users.users.username.uid to fix this issue:

error: The option value users.users.root.subUidRanges.[definition 2-entry 1].startUid' in/etc/nixos/common.nix' is not of type `signed integer'.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.