我想將 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' 不是「有符號整數」類型。