我想将 root 的startGid
和设置startUid
为另一个用户的 GID 和 UID。我怎样才能做到这一点无需对它们进行硬编码?我尝试了以下几种变体:
users.users = {
root = {
subGidRanges = [
{
count = 1;
startGid = users.users.username.group;
}
];
subUidRanges = [
{
count = 1;
startUid = config.ids.uids.username;
}
];
};
username = {
isNormalUser = true;
};
};
答案1
这似乎有效:
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;
};
};
奇怪的是,config.users.users.username.group
即使我没有明确设置它,似乎也解决得很好,但我仍然必须设置config.users.users.username.uid
来解决这个问题:
错误:选项值
users.users.root.subUidRanges.[definition 2-entry 1].startUid' in
/etc/nixos/common.nix' 不是“有符号整数”类型。